IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 1, 2005, 6:32:51 PM (21 years ago)
Author:
eugene
Message:

cleaning up setlockfile2/fsetlockfile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/elixir.c

    r3462 r3648  
    6262int WriteMsg (char *fifo, char *message) {
    6363
    64   int fd, state, mode;
     64  int state, mode;
    6565  FILE *f;
    6666
    6767  /* 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);
    7770
    7871  /* write message to end of file */
     
    8174
    8275  mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
    83   fchmod (fd, mode);
     76  chmod (fifo, mode);
    8477
    85   clearlockfile2 (fifo, fd, LCK_XCLD, &state);
    86   fclose (f);
    87 
     78  fclearlockfile (fifo, f, LCK_XCLD, &state);
    8879  return (1);
    89 
    9080}
    9181
     
    9484  int i, nbytes, Nbytes, NBYTES;
    9585  char *buffer;
    96   int fd, state, mode;
     86  int state, mode;
    9787  FILE *f;
    9888  struct stat filestat;
     
    10898
    10999  /* check lockfile */
    110   fd = setlockfile2 (fifo, 2.0, LCK_XCLD, &state);
    111   if (fd == -1) {
     100  f = fsetlockfile (fifo, 2.0, LCK_XCLD, &state);
     101  if (f == NULL) {
    112102    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);
    121103    return (0);
    122104  }
     
    125107  if (state == LCK_EMPTY) {
    126108    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);
    130111    return (0);
    131112  } 
     
    148129
    149130  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);
    153133
    154134  if (Nbytes == 0) {
Note: See TracChangeset for help on using the changeset viewer.