trinity-devel@lists.pearsoncomputing.net

Message: previous - next
Month: April 2012

Re: [trinity-devel] sftp_kio - fix ssh port number read

From: "David C. Rankin" <drankinatty@...>
Date: Wed, 25 Apr 2012 13:18:28 -0500
On 04/25/2012 12:16 PM, Timothy Pearson wrote:
> Generally I read the code and insert debug printf() statements in the most
> likely execution paths, near any chunks of code that I think are directly
> handling the feature that has the bug in it.  These printf() statements
> spew the status of any local variables that I think might be relevant to
> the bug report; i.e. if there is a problem with port numbers, I look for
> the sections of code that deal with port numbers, then print the port
> numbers (at a minimum) at the beginning and end of those sections.
> 
> Tim

OK, that I can do -- I just need a faster box to build on :)

The reversion I was talking about was this stuff. They are not part of the final
fix, but I saw them in the diffs I did between old/new and now they are gone again:

diff -uNrb tdebase.orig/kioslave/sftp/ksshprocess.cpp
tdebase/kioslave/sftp/ksshprocess.cpp
--- tdebase.orig/kioslave/sftp/ksshprocess.cpp  2012-02-08 20:13:49.000000000 -0600
+++ tdebase/kioslave/sftp/ksshprocess.cpp       2012-04-23 15:39:54.000000000 -0500
@@ -569,7 +569,9 @@
         // If we still don't have anything in our buffer so there must
         // not be anything on the pty or stderr. Setup a select()
         // to wait for some data from SSH.
-        if( buffer.empty() ) {
+        // Hack around select() failure on newer systems
+        unsigned long milliseconds = 0;
+        while ((buffer.size() == 0) && (milliseconds < (60*1000))) {
             //kdDebug(KSSHPROC) << "KSshProcess::getLine(): " <<
             //    "Line buffer empty, calling select() to wait for data." << endl;
             int errfd = ssh.stderrFd();
@@ -616,14 +618,18 @@
             // had data on it first.
             if( FD_ISSET(ptyfd, &rfds) ) {
                 ptyLine = ssh.readLineFromPty(false);
+                if (ptyLine.size() > 0) {
                 buffer.prepend(TQString(ptyLine));
+                }
                 //kdDebug(KSSHPROC) << "KSshProcess::getLine(): "
                 //    "line from pty -" << ptyLine  << endl;
             }

             if( FD_ISSET(errfd, &rfds) ) {
                 errLine = ssh.readLineFromStderr(false);
+                if (errLine.size() > 0) {
                 buffer.prepend(TQString(errLine));
+                }
                 //kdDebug(KSSHPROC) << "KSshProcess::getLine(): "
                 //    "line from err -" << errLine << endl;
             }
@@ -638,6 +644,10 @@
                     "Exception on std err file descriptor." << endl;
             }

+            if (buffer.size() == 0) {
+                milliseconds++;
+                usleep(1000);
+            }
         }
     }


-- 
David C. Rankin, J.D.,P.E.