summaryrefslogtreecommitdiff
path: root/net/3proxy/patches/patch-ad
blob: 201b685eaa91a6e53a4295a1f7f271eeaf479de9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$NetBSD: patch-ad,v 1.1 2008/02/27 23:50:29 apb Exp $

--- src/common.c.orig	2008-01-08 18:57:30.000000000 +0200
+++ src/common.c
@@ -606,3 +606,22 @@ unsigned long getip(unsigned char *name)
 #endif
 	return retval;
 }
+
+/*
+ * POSIX says:
+ *     The usleep() function may fail if:
+ *     [EINVAL] The time interval specified one million or more microseconds.
+ *
+ * Other code in 3proxy calls usleep with much larger arguments, but
+ * that gets redirected here via "#define usleep(usecs) myusleep(usecs)"
+ * in proxy.h.  We call sleep() for any whole number of seconds, and
+ * the real usleep() for any left over microseconds.
+ */
+int
+myusleep(useconds_t useconds)
+{
+    unsigned int secs = useconds / 1000000;
+    useconds = useconds % 1000000;
+    if (secs > 0) sleep(secs);
+    return (usleep)(useconds);
+}