cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

Re: Autobuild hung today

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Sat, 31 Mar 2007 09:17:32 -0700

On Sat, Mar 31, 2007 at 08:31:12AM -0400, Daniel Johnson wrote:
> My autobuild today, around 11:20 UTC, hung for around 20 minutes
> before I finally killed it. Judging by the presence of stderr600 in
> tests/log, it hung during test 600 although the build log ends part
> way through test 531; stdout must not have gotten flushed.
> Yesterday's build completed normally. I don't have time to look into
> it more right now, but I'll try again later to diagnose it better.

I reported a hanging problem to the libssh2 list a couple of weeks ago and
again yesterday, but noone has responded to it there. The problem I had
occurred when trying to download a nonexistent file using scp, but it could
happen elsewhere. Here's my message to the list which includes a patch.
If that works for you, please put in a vote for it on the libssh2 list!

On Mon, Mar 26, 2007 at 05:09:24PM -0700, Dan Fandrich wrote:
> On Thu, Mar 22, 2007 at 04:44:48PM -0700, Dan Fandrich wrote:
> > If I run the unmodified example/simple/scp program (CVS version), specifying
> > a valid username and password on the command line and an invalid file name,
> > the program hangs. The final output is:
> [...]
> > It seems that libssh2_channel_free is waiting for SSH_MSG_CHANNEL_EXTENDED_DATA
> > that is never received. If I specify a valid file name, all is well.
>
> I've solved this problem with this patch:
[...]
> This sets the poll_socket flag on these calls to false. Otherwise, when
> libssh2_channel_free is called from libssh2_scp_recv, it blocks while
> waiting for a data packet that will never arrive because the channel has
> already been closed.
>
> I'm not quite sure under which cases the poll_socket flag ought to be set--
> I would have thought it should be a nonblocking operation, otherwise, callers
> should be using libssh2_packet_require_ex instead of libssh2_packet_ask_ex.
> I'm not sure what other implications this patch has. Maybe only the second
> line above should be called with poll_socket 0--that fixes the problem as well.

After some more reflection, it looks to me like this patch is the right
way to go. The purpose of these calls is to clear out any packets that
may have arrived already, so there's no need to poll for more. There's
a similar loop in libssh2_channel_free that hasn't caused me a problem yet,
but looks like it suffers from the same problem.

The following patch fixes both sections (please ignore the fuzz).

Index: channel.c
===================================================================
RCS file: /cvsroot/libssh2/libssh2/src/channel.c,v
retrieving revision 1.38
diff -u -p -r1.38 channel.c
--- channel.c 7 Feb 2007 21:42:45 -0000 1.38
+++ channel.c 31 Mar 2007 04:40:18 -0000
@@ -317,10 +317,10 @@ libssh2_channel_open_ex(LIBSSH2_SESSION
                 libssh2_htonu32(channel_id, channel->local.id);
                 while ((libssh2_packet_ask_ex(session, SSH_MSG_CHANNEL_DATA,
                                                &data, &data_len, 1, channel_id,
- 4, 1) >= 0) ||
+ 4, 0) >= 0) ||
                         (libssh2_packet_ask_ex(session, SSH_MSG_CHANNEL_EXTENDED_DATA,
                                                &data, &data_len, 1, channel_id,
- 4, 1) >= 0)) {
+ 4, 0) >= 0)) {
                         LIBSSH2_FREE(session, data);
                 }
 
@@ -1457,8 +1466,8 @@ LIBSSH2_API int libssh2_channel_free(LIB
 
         /* Clear out packets meant for this channel */
         libssh2_htonu32(channel_id, channel->local.id);
- while ((libssh2_packet_ask_ex(session, SSH_MSG_CHANNEL_DATA, &data, &data_len, 1, channel_id, 4, 1) >= 0) ||
- (libssh2_packet_ask_ex(session, SSH_MSG_CHANNEL_EXTENDED_DATA, &data, &data_len, 1, channel_id, 4, 1) >= 0)) {
+ while ((libssh2_packet_ask_ex(session, SSH_MSG_CHANNEL_DATA, &data, &data_len, 1, channel_id, 4, 0) >= 0) ||
+ (libssh2_packet_ask_ex(session, SSH_MSG_CHANNEL_EXTENDED_DATA, &data, &data_len, 1, channel_id, 4, 0) >= 0)) {
                 LIBSSH2_FREE(session, data);
         }

This e-mail thread gets pretty lonely when I'm the only one talking.
This is causing me real problems--I've avoided putting a test for this into
curl's test suite because it causes a total hang. The protocol violation
on close I mentioned in another thread causes intermittent problems,
but there is now a test for it in curl; it can be seen as a test 603
failure in the curl autobuild page at http://curl.haxx.se/auto/ .

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2007-03-31

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET