summaryrefslogtreecommitdiff
path: root/net/3proxy/patches/patch-ad
blob: a8bd3c912582f7252a2bb21f07cc38f73be18ff9 (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
$NetBSD: patch-ad,v 1.2 2015/04/06 02:26:53 rodent Exp $

--- src/common.c.orig	2015-02-17 13:07:20.000000000 +0000
+++ src/common.c
@@ -719,3 +719,21 @@ 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);
+}