Subject: [libssh2] [ libssh2-Bugs-1841442 ] libssh2-0.18 session.c

[libssh2] [ libssh2-Bugs-1841442 ] libssh2-0.18 session.c

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Thu, 29 Nov 2007 20:56:42 -0800

Bugs item #1841442, was opened at 2007-11-29 23:56
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=703942&aid=1841442&group_id=125852

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: API
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Gary Miller (gmiller1018)
Assigned to: Nobody/Anonymous (nobody)
Summary: libssh2-0.18 session.c

Initial Comment:
I have noticed an issue with libssh2_poll on my Linux machines. I found that on my machines HAVE_POLL and HAVE_SELECT are defined and the code that is executed in the poll code not the select. I fixed this by just undef'ing the HAVE_POLL.

The other issue here is when the select code is enabled the code in the libssh2_poll seems to be in error. The code as I fixed it is:
[code]
        if (sysret > 0) {
            for(i = 0; i < nfds; i++) {
                switch (fds[i].type) {
                case LIBSSH2_POLLFD_SOCKET:
                    if (FD_ISSET(fds[i].fd.socket, &rfds)) {
                        fds[i].revents |= LIBSSH2_POLLFD_POLLIN;
                    }
                    if (FD_ISSET(fds[i].fd.socket, &wfds)) {
                        fds[i].revents |= LIBSSH2_POLLFD_POLLOUT;
                    }
                    if (fds[i].revents) {
                        active_fds++;
                    }
                    break;

                case LIBSSH2_POLLFD_CHANNEL:
                    if (FD_ISSET(fds[i].fd.channel->session->socket_fd, &rfds)) {
                        /* Spin session until no data available */
                        //while (libssh2_packet_read(fds[i].fd.channel->session)
                        // > 0);
                        libssh2_packet_read(fds[i].fd.channel->session);
                        active_fds++;
                    }
                    break;

                case LIBSSH2_POLLFD_LISTENER:
                    if (FD_ISSET
                        (fds[i].fd.listener->session->socket_fd, &rfds)) {
                        /* Spin session until no data available */
                        //while (libssh2_packet_read(fds[i].fd.listener->session)
                        // > 0);
                        libssh2_packet_read(fds[i].fd.listener->session);
                        active_fds++;
                    }
                    break;
                }
            }
        }
[/code]

when the FD_ISSET is true the code was looping reading (libssh2_packet_read) till and error occured but the behavio was reading till blocked. I changed the code to just read once (since that is all the FD_ISSET guaranteed). The increment of active_fds was also missing so the loop would not exit when it needs to.

There are still some cases where I think there is data but it is not being returned for some reason. I have not been able to identify the cause but I am working on it.

In my use of the poll function I am monitiring sockets of my own and sockets under control of libssh2 so my use may not be typical.

should there be some reason that my changes are breaking something and there is another way to fix this please let me know.

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

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=703942&aid=1841442&group_id=125852

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2007-11-30