cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: HP-UX Bug Fix

From: Rick Jones <rick_jones2_at_hp.com>
Date: Thu, 13 Mar 2003 17:02:10 -0800

"Combes, Chris M." wrote:
>
> Hi Daniel,
>
> A co-worker is requesting a modification to libcurl
> as described below.
>
> Can you let me know if this change is incorporated
> or not?
>
> Thanks,
> Chris
>
> Version: 7.10.3
> Changed file: lib/sendf.c
> Reason: A full buffer (server not reading fast enough) will
> cause a write failure on HP-UX as send() returns -1 with errno ==
> EAGAIN

I would have thought that if non-blocking was being used, that a
function that would be trying to write data to a socket would only be
called if something like select or poll stated that the socket was
writeable, in which case I would expect at least one byte to be written.

However, looking at the code swrite is part of Curl_write, and there are
at least some places where Curl_write will be called in a loop until all
is written, but there appears to be no intervening select/poll call.
For example, Curl_sendf:

  do {
    /* Write the buffer to the socket */
    res = Curl_write(conn, sockfd, sptr, write_len, &bytes_written);

    if(CURLE_OK != res)
      break;

    if(data->set.verbose)
      Curl_debug(data, CURLINFO_DATA_OUT, sptr, bytes_written);

    if(bytes_written != write_len) {
      /* if not all was written at once, we must advance the pointer,
decrease
         the size left and try again! */
      write_len -= bytes_written;
      sptr += bytes_written;
    }
    else
      break;

  } while(1);

If the socket buffer is full, this would simply sit and spin for however
long it took to get the socket buffer empty. Doubleplusungood. (Unless
I'm missing something about the conditions in which Curl_sendf is
called?)

rick jones

-- 
Wisdom Teeth are impacted, people are affected by the effects of events.
these opinions are mine, all mine; HP might not want them anyway... :)
feel free to post, OR email to raj in cup.hp.com  but NOT BOTH...
-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
Received on 2003-03-14