THREAD_LOCAL FILE *state_f;
THREAD_LOCAL uint16_t clock_seq;
struct timeval tv;
+ struct flock fl;
unsigned long long clock_reg;
mode_t save_umask;
state_fd = -1;
}
}
+ fl.l_type = F_WRLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_pid = 0;
if (state_fd >= 0) {
rewind(state_f);
- while (lockf(state_fd, F_LOCK, 0) < 0) {
+ while (fcntl(state_fd, F_SETLKW, &fl) < 0) {
if ((errno == EAGAIN) || (errno == EINTR))
continue;
fclose(state_f);
close(state_fd);
state_fd = -1;
+ break;
}
}
if (state_fd >= 0) {
clock_seq, last.tv_sec, last.tv_usec, adjustment);
fflush(state_f);
rewind(state_f);
- lockf(state_fd, F_ULOCK, 0);
+ fl.l_type = F_UNLCK;
+ fcntl(state_fd, F_SETLK, &fl);
}
*clock_high = clock_reg >> 32;