70 lines
1.9 KiB
Diff
70 lines
1.9 KiB
Diff
Description: avoid sleeps
|
||
Author: Frank Heckenbach
|
||
--- a/prott.c
|
||
+++ b/prott.c
|
||
@@ -88,7 +88,7 @@ ftstart (qdaemon, pzlog)
|
||
zTbuf[0] = 0;
|
||
zTbuf[1] = 0;
|
||
fTfile = FALSE;
|
||
- usysdep_sleep (2);
|
||
+ // usysdep_sleep (2); -- why? protocol t is meant to be used over an error-free connection
|
||
return TRUE;
|
||
}
|
||
|
||
--- a/unix/pipe.c
|
||
+++ b/unix/pipe.c
|
||
@@ -36,6 +36,7 @@ const char pipe_rcsid[] = "$Id: pipe.c,v
|
||
#include "sysdep.h"
|
||
|
||
#include <errno.h>
|
||
+#include <sys/wait.h>
|
||
|
||
#if HAVE_FCNTL_H
|
||
#include <fcntl.h>
|
||
@@ -164,10 +165,43 @@ fspipe_close (qconn, puuconf, qdialer, f
|
||
if (qsysdep->ipid >= 0)
|
||
{
|
||
if (kill (qsysdep->ipid, SIGHUP) == 0)
|
||
- usysdep_sleep (2);
|
||
+ {
|
||
+ #if defined (HAVE_USLEEP) && defined (HAVE_WAITPID)
|
||
+ /* Avoid wasting 4 seconds (including the SIGPIPE case below).
|
||
+ Quick and dirty work-around to avoid depending on SIGCHLD:
|
||
+ Just sleep up to 20 times 0.1s as long as the child exists. */
|
||
+ int i, status;
|
||
+ for (i = 20; i > 0; i--)
|
||
+ {
|
||
+ if (waitpid (qsysdep->ipid, &status, WNOHANG) == qsysdep->ipid)
|
||
+ {
|
||
+ qsysdep->ipid = -1;
|
||
+ return fret;
|
||
+ }
|
||
+ usleep (100000);
|
||
+ }
|
||
+ #else
|
||
+ usysdep_sleep (2);
|
||
+ #endif
|
||
+ }
|
||
#ifdef SIGPIPE
|
||
if (kill (qsysdep->ipid, SIGPIPE) == 0)
|
||
- usysdep_sleep (2);
|
||
+ {
|
||
+ #if HAVE_USLEEP
|
||
+ int i, status;
|
||
+ for (i = 20; i > 0; i--)
|
||
+ {
|
||
+ if (waitpid (qsysdep->ipid, &status, WNOHANG) == qsysdep->ipid)
|
||
+ {
|
||
+ qsysdep->ipid = -1;
|
||
+ return fret;
|
||
+ }
|
||
+ usleep (100000);
|
||
+ }
|
||
+ #else
|
||
+ usysdep_sleep (2);
|
||
+ #endif
|
||
+ }
|
||
#endif
|
||
if (kill (qsysdep->ipid, SIGKILL) < 0 && errno == EPERM)
|
||
{
|