Package: uucp
Version: 1.07-20.1
Severity: normal
Tags: upstream patch

I had reported this bug against 1.07-20 before (#675101), but it was
ignored. Since bug reports against stable packages generally seem to
get ignored, I'm reporting it again against the version in unstable.
(I could also report it against experimental (1.07-22), the version
there is unchanged in the respective places.)

I've been using uucp with my patch for over 2 years now and had no
problems with it.

--------------------------------------------------------------------

Original report:

I noticed that uucico (using protocol t over ssh) takes rather long,
even though the actual connection and data transfer is quite fast.

Digging through the source, I found 3 apparently unneccesary sleeps
of 2s each:

- prott.c: ftstart(): sleeps "just so" before returning (at least
  nothing indicates why, probably just copied from other protocols
  that may need it). Since protocol t is meant to be used over an
  error-free connection, I removed it.

- Two sleeps just for killing the child process. I replaced them
  with a loop or shorter sleeps while checking whether the process
  still exists. This is not the most elegant solution, but a rather
  simple one that works, and it won't break on other systems, since
  I make the change only if HAVE_USLEEP and HAVE_WAITPID are set.

With those two changes (see patch), it runs much faster for me
without any discernible drawback.

--- prott.c.orig        2012-05-29 21:14:51.000000000 +0200
+++ prott.c     2012-05-29 21:15:45.000000000 +0200
@@ -88,7 +88,7 @@
   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;
 }
 
--- unix/pipe.c.orig    2012-05-29 21:33:16.000000000 +0200
+++ unix/pipe.c 2012-05-29 21:41:34.000000000 +0200
@@ -164,10 +164,43 @@
   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)
        {


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to