Changeset 212 for trunk/src/slib.c


Ignore:
Timestamp:
Feb 17, 2009, 10:37:42 PM (16 years ago)
Author:
katerina
Message:

Lock baseline database (ticket #139) and allow list as input for PortCheckInterface (ticket #140).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/slib.c

    r203 r212  
    21522152}
    21532153
     2154int sl_lock (SL_TICKET ticket)
     2155{
     2156  int fd;
     2157  struct flock lock;
     2158  int retval;
     2159 
     2160  SL_ENTER(_("sl_lock"));
     2161
     2162  if (SL_ISERROR(fd = get_the_fd (ticket)))
     2163    SL_IRETURN(fd, _("sl_lock"));
     2164
     2165  lock.l_type   = F_WRLCK;
     2166  lock.l_whence = SEEK_SET;
     2167  lock.l_start  = 0;
     2168  lock.l_len    = 0;
     2169
     2170  /* F_SETLK returns if the lock cannot be obtained */
     2171  do {
     2172    retval = fcntl(fd, F_SETLK, &lock);
     2173  } while (retval < 0 && errno == EINTR);
     2174
     2175  if (retval < 0 && errno == EBADF)
     2176    SL_IRETURN(SL_ETICKET, _("sl_lock"));
     2177  else if (retval < 0)
     2178    SL_IRETURN(SL_EBADFILE, _("sl_lock"));
     2179  else
     2180    SL_IRETURN(SL_ENONE, _("sl_lock"));
     2181 }
     2182 
    21542183int sl_close (SL_TICKET ticket)
    21552184{
Note: See TracChangeset for help on using the changeset viewer.