[PATCH 1/2] examples: Make sure the timeout parameter to select is valid

Martin Storsjo martin at martin.st
Mon Oct 29 14:44:25 CET 2012


This makes the example work properly on Mac OS X (tested on 10.8).
---
 doc/examples/ex-serv-dtls.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/doc/examples/ex-serv-dtls.c b/doc/examples/ex-serv-dtls.c
index adcc7eb..04cc26b 100644
--- a/doc/examples/ex-serv-dtls.c
+++ b/doc/examples/ex-serv-dtls.c
@@ -296,6 +296,12 @@ pull_timeout_func (gnutls_transport_ptr_t ptr, unsigned int ms)
   tv.tv_sec = 0;
   tv.tv_usec = ms * 1000;
 
+  while(tv.tv_usec >= 1000000)
+    {
+      tv.tv_usec -= 1000000;
+      tv.tv_sec++;
+    }
+
   ret = select (priv->fd + 1, &rfds, NULL, NULL, &tv);
 
   if (ret <= 0)
-- 
1.7.9.4





More information about the Gnutls-devel mailing list