Ticket #111 (closed defect)

Opened 8 years ago

Last modified 8 years ago

libssh2_poll intermittent hang on Solaris (old version)

Reported by: listmail Owned by: bagder
Priority: normal Milestone:
Component: API Version:
Keywords: Cc: listmail, bagder
Blocked By: Blocks:

Description

I'm still using libssh2-0.18 because I was getting new issues (basically no output) when testing libssh2-1.1 on Solaris 10 + Net::SSH2. My guess is that piece could be related to recent blocking changes in 1.1 since 1.0 worked with the same code.

Anyway, The only problem I've had is that, at random, libssh2_poll will hang indefinitely. It could be a couple of days or more or even just a matter of minutes before this happens. I call a perl/Net::SSH2 app at regular intervals to exec some "health check" commands on some servers. I finally tracked the true hang down to the C recv() function call in libssh2_packet_read. The following code from libssh2_poll is calling libssh2_packet_read consecutively before recv eventually hangs. Its as if it was expected that there would be data (since libssh2_packet_reads return value > 0), but recv ended up waiting for more data.

(session.c, libssh2_poll, near #ifdef HAVE_POLL section)

case LIBSSH2_POLLFD_CHANNEL:

if (sockets[i].events & POLLIN) {

/* Spin session until no data available */
while (libssh2_packet_read(fds[i].fd.channel->session)

0);

}

(transport.c, libssh2_packet_read, I put before/after debug code here to catch the hang)

/* now read a big chunk from the network into the temp buffer */
nread =

recv(session->socket_fd, &p->buf[remainbuf],

PACKETBUFSIZE - remainbuf,
LIBSSH2_SOCKET_RECV_FLAGS(session));

Simply removing the while loop avoids the hang and my initial tests are still showing all expected data being returned. I'm not fluent in C nor do I understand sockets. Should there be some additional poll done before each iteration as if even though the return value indicates more packets there is a chance recv could still hang? I see that you may be deprecating libssh2_poll but right now I can't get 1.1 to read any output.

Change History

comment:1 Changed 8 years ago by bagder

Sorry, but we can't deal with bugs in old versions. In addition to this, the libssh2_poll() function has been marked deprecated so we won't do any bugfixing of that function at all. Switch to (non-blocking sockets and) using plain normal poll() instead.

Note: See TracTickets for help on using tickets.