RE: PATCH: Microsecond sleep time

Werner Coetzee <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <86E9DA9FF04EBD468B3574F22A0B0DB648811780C4@comms01-cpt.internal.clickatell.com>
Hi Stipe

Diffs attached.
I hope it's the right format this time.

Regards
Werner



-----Original Message-----
From: Stipe Tolj [mailto:[email protected]]
Sent: 02 July 2008 16:48
To: Werner Coetzee
Cc: [email protected]
Subject: Re: PATCH: Microsecond sleep time

Werner Coetzee schrieb:
> Hi Stipe
>
> Patch attached.

Hi Werner,

you attached a file micro.c, but not a 'diff -u' formated patch ;)

Can you please resend in diff style as you did in your initial posting, but
simply attach the patch file so we don't get it clobbered. Thanks.

Stipe

-------------------------------------------------------------------
Kölner Landstrasse 419
40589 Düsseldorf, NRW, Germany

tolj.org system architecture      Kannel Software Foundation (KSF)
http://www.tolj.org/              http://www.kannel.org/

mailto:st_{at}_tolj.org           mailto:stolj_{at}_kannel.org
-------------------------------------------------------------------
gwthread.h.diff (application/octet-stream, 787 B)
Index: gwthread.h
===================================================================
RCS file: /home/cvs/gateway/gwlib/gwthread.h,v
retrieving revision 1.23
diff -u -r1.23 gwthread.h
--- gwthread.h  9 Jan 2008 20:06:55 -0000       1.23
+++ gwthread.h  2 Jul 2008 16:28:16 -0000
@@ -142,6 +142,10 @@
  * calls gwthread_wakeup on us.  Fractional seconds are allowed. */
 void gwthread_sleep(double seconds);

+/* Sleep until "seconds" seconds have elapsed, or until another thread
+ * calls gwthread_wakeup on us.  Fractional seconds are allowed. */
+void gwthread_sleep_micro(double dseconds);
+
 /* Force a specific thread to terminate. Returns 0 on success, -1 if the
  * thread has been terminated while calling and non-zero for the pthread
  * specific error code.
gwthread-pthread.c.diff (application/octet-stream, 1.3 KB)
Index: gwthread-pthread.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/gwthread-pthread.c,v
retrieving revision 1.53
diff -u -r1.53 gwthread-pthread.c
--- gwthread-pthread.c  9 Jan 2008 20:06:55 -0000       1.53
+++ gwthread-pthread.c  2 Jul 2008 16:29:51 -0000
@@ -781,6 +781,42 @@
 }


+void gwthread_sleep_micro(double dseconds)
+{
+    fd_set fd_set_recv;
+    struct threadinfo *threadinfo;
+    int fd;
+    int ret;
+
+    threadinfo = getthreadinfo();
+    fd = threadinfo->wakefd_recv;
+
+    FD_ZERO(&fd_set_recv);
+    FD_SET(fd, &fd_set_recv);
+
+    if (dseconds < 0) {
+        ret = select(fd + 1, &fd_set_recv, NULL, NULL, NULL);
+    }
+    else {
+        struct timeval timeout;
+        timeout.tv_sec = dseconds;
+        timeout.tv_usec = (dseconds - timeout.tv_sec) * 1000000;
+
+        ret = select(fd + 1, &fd_set_recv, NULL, NULL, &timeout);
+    }
+
+    if (ret < 0) {
+        if (errno != EINTR && errno != EAGAIN) {
+            warning(errno, "gwthread_sleep_micro: error in select()");
+        }
+    }
+
+    if (FD_ISSET(fd, &fd_set_recv)) {
+        flushpipe(fd);
+    }
+}
+
+
 int gwthread_cancel(long thread)
 {
     struct threadinfo *threadinfo;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.