Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 1474815 Details for
Bug 1507361
[GSS] glusterfsd processes consuming high memory on all gluster nodes from trusted pool
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
locks program
locks.c (text/x-csrc), 2.54 KB, created by
Raghavendra Bhat
on 2018-08-09 20:49:40 UTC
(
hide
)
Description:
locks program
Filename:
MIME Type:
Creator:
Raghavendra Bhat
Created:
2018-08-09 20:49:40 UTC
Size:
2.54 KB
patch
obsolete
>#include <fcntl.h> >#include <stdio.h> >#include <stdlib.h> >#include <unistd.h> >#include <string.h> >#include <errno.h> >#include <sys/stat.h> >#include <sys/types.h> > > > >void >lock_test (int fd) >{ > > char *buffer1 = "aaaaa"; > char *buffer2 = "bbbbb"; > int flag = -1; > char *my_buffer = NULL; > int ret = -1; > > while (1) { > struct flock fl; > memset(&fl, 0, sizeof(fl)); > > // lock in shared mode > fl.l_type = F_RDLCK; > > // lock entire file > fl.l_whence = SEEK_SET; // offset base is start of the file > fl.l_start = 0; // starting offset is zero > fl.l_len = 0; // len is zero, which is a special value representing end > // of file (no matter how large the file grows in future) > > // F_SETLKW specifies blocking mode > if (fcntl(fd, F_SETLKW, &fl) == -1) { > exit(1); > } > > // atomically upgrade shared lock to exclusive lock, but only > // for bytes in range [10; 15) > // > // after this call, the process will hold three lock regions: > // [0; 10) - shared lock > // [10; 15) - exclusive lock > // [15; SEEK_END) - shared lock > fl.l_type = F_WRLCK; > fl.l_start = 10; > fl.l_len = 5; > > // F_SETLKW specifies non-blocking mode > if (fcntl(fd, F_SETLK, &fl) == -1) { > exit(1); > } > > ret = lseek (fd, 10, SEEK_SET); > if (ret == -1) { > fprintf (stderr, "seeking to the offset 10 failed (%s)\n", > strerror (errno)); > goto unlock; > } > > if (flag == -1 || flag == 1) { > my_buffer = buffer1; > flag = 0; > } else { > flag = 1; > my_buffer = buffer2; > } > > ret = write (fd, my_buffer, strlen (my_buffer)); > if (ret == -1) > fprintf (stderr, "failed to write the buffer %s to the\n" > "file (error: %s)\n", buffer1, strerror (errno)); > > unlock: > // release lock for bytes in range [10; 15) > fl.l_type = F_UNLCK; > > if (fcntl(fd, F_SETLK, &fl) == -1) { > exit(1); > } > > // close file and release locks for all regions > // remember that locks are released when process calls close() > // on any descriptor for a lock file > //close(fd); > > printf ("finished one run\n"); > sleep (5); > } > > return; >} > >int main (int argc, char *argv[]) >{ > > char *file_name = argv[1]; > int fd = -1; > int ret = -1; > > /* > * Assumes the file to be created already. Not that intelligent > */ > > fd = open (file_name, O_RDWR); > if (fd == -1) { > fprintf (stderr, "open failed on %s (%s)\n", file_name, strerror (errno)); > goto out; > } > > lock_test (fd); > > ret = 0; > >out: > if (fd) > close (fd); > > return ret; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1507361
: 1474815