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

*** Please type your report below this line ***

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.

-- System Information:
Debian Release: 6.0.2
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 3.2.2 (SMP w/6 CPU cores)
Locale: LANG=de_DE, LC_CTYPE=de_DE (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash

Versions of packages uucp depends on:
ii  cron                  3.0pl1-116         process scheduling daemon
hi  cu                    1.07-20            call up another system
ii  heirloom-mailx [mailx 12.4-2             feature-rich BSD mail(1)
ii  libc6                 2.13-10            Embedded GNU C Library: Shared lib
ii  libpam-runtime        1.1.1-6.1          Runtime support for the PAM librar
ii  libpam0g              1.1.1-6.1+squeeze1 Pluggable Authentication Modules l
ii  logrotate             3.7.8-6            Log rotation utility
ii  netbase               4.45               Basic TCP/IP networking system
ii  openbsd-inetd [inet-s 0.20080125-6       The OpenBSD Internet Superserver

Versions of packages uucp recommends:
ii  exim4                    4.72-6+squeeze2 metapackage to ease Exim MTA (v4) 

uucp suggests no packages.

-- no debconf information

--- 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