about summary refs log tree commit homepage
path: root/sig.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-02-15 02:40:50 +0000
committerEric Wong <normalperson@yhbt.net>2013-02-15 02:40:50 +0000
commit5629899a12649b9b21f41efc29b92adbd82afe6c (patch)
tree8f97f684d65356623af0610e5587bebaa9af6129 /sig.c
parent44f4f76d06899b1a0e4719671a4fde3c0851764a (diff)
downloadcmogstored-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.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/sig.c b/sig.c
index 63a40fe..7fa2708 100644
--- a/sig.c
+++ b/sig.c
@@ -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");
+}