diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-02-15 02:40:50 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-02-15 02:40:50 +0000 |
commit | 5629899a12649b9b21f41efc29b92adbd82afe6c (patch) | |
tree | 8f97f684d65356623af0610e5587bebaa9af6129 /sig.c | |
parent | 44f4f76d06899b1a0e4719671a4fde3c0851764a (diff) | |
download | cmogstored-5629899a12649b9b21f41efc29b92adbd82afe6c.tar.gz |
This will inform the user of why cmogstored may be slow to start, since we need the mountlist to be populated at startup. We also throw a pthread_cancel() in there to load libgcc_s under glibc, so we can avoid loading libgcc_s once we're under FD pressure. This makes test/http_idle_expire.rb more reliable.
Diffstat (limited to 'sig.c')
-rw-r--r-- | sig.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -23,3 +23,24 @@ void mog_intr_enable(void) CHECK(int, 0, sigemptyset(&set)); CHECK(int, 0, pthread_sigmask(SIG_SETMASK, &set, NULL)); } + +/* thread-safe, interruptible sleep, negative seconds -> sleep forever */ +void mog_sleep(long seconds) +{ + sigset_t set; + struct timespec ts; + struct timespec *tsp; + + if (seconds < 0) { + tsp = NULL; + } else { + ts.tv_sec = seconds; + ts.tv_nsec = 0; + tsp = &ts; + } + + CHECK(int, 0, sigemptyset(&set)); + if (pselect(0, NULL, NULL, NULL, tsp, &set) < 0) + assert((errno == EINTR || errno == ENOMEM) && + "BUG in pselect usage"); +} |