Changeset 3648 for trunk/Ohana/src/opihi/dvo/elixir.c
- Timestamp:
- Apr 1, 2005, 6:32:51 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/dvo/elixir.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/elixir.c
r3462 r3648 62 62 int WriteMsg (char *fifo, char *message) { 63 63 64 int fd,state, mode;64 int state, mode; 65 65 FILE *f; 66 66 67 67 /* check lockfile */ 68 fd = setlockfile2 (fifo, 2.0, LCK_XCLD, &state); 69 if (fd == -1) return (0); 70 f = fdopen (fd, "r+"); 71 if (f == (FILE *) NULL) { 72 mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; 73 fchmod (fd, mode); 74 clearlockfile2 (fifo, fd, LCK_XCLD, &state); 75 return (0); 76 } 68 f = fsetlockfile (fifo, 2.0, LCK_XCLD, &state); 69 if (f == NULL) return (0); 77 70 78 71 /* write message to end of file */ … … 81 74 82 75 mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; 83 fchmod (fd, mode);76 chmod (fifo, mode); 84 77 85 clearlockfile2 (fifo, fd, LCK_XCLD, &state); 86 fclose (f); 87 78 fclearlockfile (fifo, f, LCK_XCLD, &state); 88 79 return (1); 89 90 80 } 91 81 … … 94 84 int i, nbytes, Nbytes, NBYTES; 95 85 char *buffer; 96 int fd,state, mode;86 int state, mode; 97 87 FILE *f; 98 88 struct stat filestat; … … 108 98 109 99 /* check lockfile */ 110 f d = setlockfile2(fifo, 2.0, LCK_XCLD, &state);111 if (f d == -1) {100 f = fsetlockfile (fifo, 2.0, LCK_XCLD, &state); 101 if (f == NULL) { 112 102 fprintf (stderr, "message locked (%d)\n", state); 113 return (0);114 }115 f = fdopen (fd, "r+");116 if (f == (FILE *) NULL) {117 fprintf (stderr, "message blocked\n");118 mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;119 fchmod (fd, mode);120 clearlockfile2 (fifo, fd, LCK_XCLD, &state);121 103 return (0); 122 104 } … … 125 107 if (state == LCK_EMPTY) { 126 108 mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; 127 fchmod (fd, mode); 128 clearlockfile2 (fifo, fd, LCK_XCLD, &state); 129 fclose (f); 109 chmod (fifo, mode); 110 fclearlockfile (fifo, f, LCK_XCLD, &state); 130 111 return (0); 131 112 } … … 148 129 149 130 mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; 150 fchmod (fd, mode); 151 clearlockfile2 (fifo, fd, LCK_XCLD, &state); 152 fclose (f); 131 chmod (f, mode); 132 fclearlockfile (fifo, f, LCK_XCLD, &state); 153 133 154 134 if (Nbytes == 0) {
Note:
See TracChangeset
for help on using the changeset viewer.
