[prev in list] [next in list] [prev in thread] [next in thread] 

List:       libssh2-devel
Subject:    Re: [libssh2] recent change in channel_read_ex
From:       "Paul Thomas" <thomaspu () gmail ! com>
Date:       2008-10-20 17:22:47
Message-ID: c52222ba0810201022u372f9a99p84ee9e7daa29dd96 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


That patch that I added that changed the line you are referring to was done
to fix an issue where small amounts of data weren't getting picked up on the
channel_read when it only recieved 1~8 chars of data. Looks like I forgot a
case dealing with the while loop on line 1533.

I took a quick look....That if statement needs to take into account when the
condition
   channel->read_bytes_read == (int) buflen
is true and if so, also enter the error state. That's why you're seeing the
code get stuck in the loop.

Paul


On Mon, Oct 20, 2008 at 12:47 PM, E L <crc1021@gmail.com> wrote:

> There was change in libssh2_channel_read_ex, in the check of rc < 0
>        if (channel->read_block) {
>            /* in the second lap and onwards, do this */
>            rc = libssh2_packet_read(session);
>            channel->read_packet = session->packets.head;
>        }
>
>        /* We didn't read any data from the socket and
>         * no packets are waiting to be read */
>        if ((rc < 0) && (! channel->read_packet)) {
>                    if (rc != PACKET_EAGAIN) {
>                channel->read_state = libssh2_NB_state_idle;
>            }
>            /* no packets available */
>            return rc;
>        }
>
> This is causing problems for me, the code appears to spin in some busy
> wait loop.
>
> This issue is that rc == LIBSSH2_ERROR_EAGAIN and
> session->packets.head is not NULL, so the error checking code is not
> entered.  Reverting that line by removing the "&& (!
> channel->read_packet)", make the code work again.
>
> Code is from libssh2-0.19.0-20081020, compiled with mingw on win XP,
> and used in libcurl.
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> libssh2-devel mailing list
> libssh2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libssh2-devel
>

[Attachment #5 (text/html)]

<div dir="ltr">That patch that I added that changed the line you are referring to was \
done to fix an issue where small amounts of data weren&#39;t getting picked up on the \
channel_read when it only recieved 1~8 chars of data. Looks like I forgot a case \
dealing with the while loop on line 1533.<br> <br>I took a quick look....That if \
statement needs to take into account when the condition<br>&nbsp;&nbsp; \
channel-&gt;read_bytes_read == (int) buflen<br>is true and if so, also enter the \
error state. That&#39;s why you&#39;re seeing the code get stuck in the loop. <br> \
<br>Paul<br><br><br><div class="gmail_quote">On Mon, Oct 20, 2008 at 12:47 PM, E L \
<span dir="ltr">&lt;<a \
href="mailto:crc1021@gmail.com">crc1021@gmail.com</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, \
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> There was change in \
libssh2_channel_read_ex, in the check of rc &lt; 0<br>  &nbsp; &nbsp; &nbsp; &nbsp;if \
(channel-&gt;read_block) {<br>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* in the \
second lap and onwards, do this */<br>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rc = \
libssh2_packet_read(session);<br>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;channel-&gt;read_packet = session-&gt;packets.head;<br>  &nbsp; &nbsp; &nbsp; \
&nbsp;}<br> <br>
 &nbsp; &nbsp; &nbsp; &nbsp;/* We didn&#39;t read any data from the socket and<br>
 &nbsp; &nbsp; &nbsp; &nbsp; * no packets are waiting to be read */<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if ((rc &lt; 0) &amp;&amp; (! channel-&gt;read_packet)) \
{<br>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (rc != \
PACKET_EAGAIN) {<br>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;channel-&gt;read_state = libssh2_NB_state_idle;<br>  &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp;}<br>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* no packets \
available */<br>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return rc;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
This is causing problems for me, the code appears to spin in some busy<br>
wait loop.<br>
<br>
This issue is that rc == LIBSSH2_ERROR_EAGAIN and<br>
session-&gt;packets.head is not NULL, so the error checking code is not<br>
entered. &nbsp;Reverting that line by removing the &quot;&amp;&amp; (!<br>
channel-&gt;read_packet)&quot;, make the code work again.<br>
<br>
Code is from libssh2-0.19.0-20081020, compiled with mingw on win XP,<br>
and used in libcurl.<br>
<br>
-------------------------------------------------------------------------<br>
This SF.Net email is sponsored by the Moblin Your Move Developer&#39;s challenge<br>
Build the coolest Linux based applications with Moblin SDK &amp; win great prizes<br>
Grand prize is a trip for two to an Open Source event anywhere in the world<br>
<a href="http://moblin-contest.org/redirect.php?banner_id=100&amp;url=/" \
target="_blank">http://moblin-contest.org/redirect.php?banner_id=100&amp;url=/</a><br>
 _______________________________________________<br>
libssh2-devel mailing list<br>
<a href="mailto:libssh2-devel@lists.sourceforge.net">libssh2-devel@lists.sourceforge.net</a><br>
 <a href="https://lists.sourceforge.net/lists/listinfo/libssh2-devel" \
target="_blank">https://lists.sourceforge.net/lists/listinfo/libssh2-devel</a><br> \
</blockquote></div><br></div>



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
libssh2-devel mailing list
libssh2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic