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 829924 Details for
Bug 1035491
File lock propagates on failover but not failback
[?]
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.
test C lock program
locktest.c (text/x-c++src), 2.94 KB, created by
Mike Watkins
on 2013-11-27 22:17:13 UTC
(
hide
)
Description:
test C lock program
Filename:
MIME Type:
Creator:
Mike Watkins
Created:
2013-11-27 22:17:13 UTC
Size:
2.94 KB
patch
obsolete
>#include <stdio.h> >#include <stdlib.h> >#include <unistd.h> >#include <errno.h> >#include <string.h> >#include <fcntl.h> >#include <time.h> >#include <sys/stat.h> >#include <sys/utsname.h> > >int WriteLock(int fd); >int ReadLock(int fd); >int UnLock(int fd); > >int main(void) { > const char *filename = "/mnt/amqrhss/jboss_a-mq.lock"; > int fd = -1; > char writestr[100]; > const int readmax = 128; > char readbuffer[readmax]; > int myerr = errno; > > struct tm *newtime; > time_t ltime; > time(<ime); > newtime = localtime(<ime); > > struct tm tnow = *gmtime(<ime); > char timestr[100]; > strftime( timestr, sizeof timestr, "%a %b %d %Y %T %Z%z", &tnow ); > > memset(writestr,0,100); > > struct utsname my_uname; > if(uname(&my_uname) == -1) > printf("uname call failed!"); > else > sprintf(writestr,"Server: %s\nLock Creation Time: %s\n", my_uname.nodename, timestr); > > > if ((fd = open(filename, O_RDWR| O_CREAT, S_IRUSR| S_IWUSR)) == -1) { > printf("ERROR: open errno(%d): %s\n", errno,strerror(myerr)); > return EXIT_FAILURE; > > } > > if (WriteLock(fd) == EXIT_FAILURE) { > printf("ERROR: WriteLock errno(%d): %s\n", errno,strerror(myerr)); > return EXIT_FAILURE; > } else > printf("Got the file lock...\n"); > > if (write(fd, (const void *) writestr, strlen(writestr) + 1) == -1) { > printf("ERROR: write errno(%d): %s\n", errno,strerror(myerr)); > return EXIT_FAILURE; > } > fsync(fd); > > int i; > for (i=0; i<200;i++) { > system("clear; date; ls -lrt /mnt/amqrhss"); > printf("%d ",i); fflush(stdout); > sleep(1); > } > printf("\n"); > > > if (UnLock(fd) == EXIT_FAILURE) { > return EXIT_FAILURE; > } > > if (close(fd) == -1) { > printf("ERROR: close errno(%d): %s\n", errno,strerror(myerr)); > return EXIT_FAILURE; > } > >/* > if (unlink(filename) == -1) { > printf("ERROR: unlink errno(%d): %s\n", errno,strerror(myerr)); > return EXIT_FAILURE; > } >*/ > > return EXIT_SUCCESS; >} > >int WriteLock(int fd) { > struct flock fd_flock; > fd_flock.l_type = F_WRLCK;/*Write lock*/ > fd_flock.l_whence = SEEK_SET; > fd_flock.l_start = 0; > fd_flock.l_len = 0;/*Lock whole file*/ > > if (fcntl(fd, F_SETLKW,&fd_flock) == -1) { > int myerr = errno; > printf("ERROR: fcntl errno(%d): %s\n", errno,strerror(myerr)); > return EXIT_FAILURE; > } > return EXIT_SUCCESS; >} > >int ReadLock(int fd) { > struct flock fd_flock; > fd_flock.l_type = F_RDLCK;/*Write lock*/ > fd_flock.l_whence = SEEK_SET; > fd_flock.l_start = 0; > fd_flock.l_len = 0;/*Lock whole file*/ > > if (fcntl(fd, F_SETLKW,&fd_flock) == -1) { > int myerr = errno; > printf("ERROR: fcntl errno(%d): %s\n", errno,strerror(myerr)); > return EXIT_FAILURE; > } > return EXIT_SUCCESS; >} > >int UnLock(int fd) { > struct flock fd_flock; > fd_flock.l_type = F_UNLCK;/*Write lock*/ > fd_flock.l_whence = SEEK_SET; > fd_flock.l_start = 0; > fd_flock.l_len = 0;/*Lock whole file*/ > > if (fcntl(fd, F_SETLKW,&fd_flock) == -1) { > int myerr = errno; > printf("ERROR: fcntl errno(%d): %s\n", errno,strerror(myerr)); > return EXIT_FAILURE; > } > return EXIT_SUCCESS; >} >
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 1035491
: 829924