From 5315068bcff700d2daff57376ea4f32041f2c73d Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Thu, 19 Nov 1998 17:27:40 +0000 Subject: [PATCH] Give up attempting to lock a file unless the resulting error was `EWOULDBLOCK'. This prevents DeleGate to hang upon writing the transfer log to stderr when running as an FTP proxy in foreground (-v) mode. --- net/delegate/files/patch-aa | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 net/delegate/files/patch-aa diff --git a/net/delegate/files/patch-aa b/net/delegate/files/patch-aa new file mode 100644 index 000000000000..7232ff8e7894 --- /dev/null +++ b/net/delegate/files/patch-aa @@ -0,0 +1,47 @@ +--- src/lock.c.orig Tue Aug 4 09:13:18 1998 ++++ src/lock.c Thu Nov 19 18:17:09 1998 +@@ -18,6 +18,7 @@ + History: + 970403 extracted from cache.c + //////////////////////////////////////////////////////////////////////#*/ ++#include + #include + #include + extern double Time(); +@@ -112,6 +113,22 @@ + rcode = 0; + break; + } ++#ifdef EWOULDBLOCK ++ /* ++ * Only retry the lock if it was busy. Other ++ * possible sources for the lock to fail are: ++ * invalid argument, bad filedescriptor, and ++ * operation not supported by device. The latter ++ * happens if you start DeleGateD with -v, so it ++ * logs to stderr (which usually doesn't support ++ * locking at all). ++ */ ++ if (rcode == -1 && errno != EWOULDBLOCK) { ++ /* pretend lock succeeded */ ++ rcode = 0; ++ break; ++ } ++#endif + remain = timeout - elapsed; + if( remain <= 0 ) + break; +@@ -122,6 +139,13 @@ + + start = Time(); + rcode = callFuncTimeout(remain/1000,-1,func,fd); ++#ifdef EWOULDBLOCK ++ if (rcode == -1 && errno != EWOULDBLOCK) { ++ /* pretend lock succeeded */ ++ rcode = 0; ++ break; ++ } ++#endif + elapse1 = (Time() - start) * 1000; + /*{ + static int n;