cURL / Mailing Lists / curl-library / Single Mail

curl-library

No callbacks during POST

From: Raf Nulens <raf.nulens_at_androme.com>
Date: Wed, 4 Jul 2007 11:13:33 +0200

Hi all,

using libcurl version 7.16.0 (win32) we are experiencing following problem:
when uploading binary data using POST the upload stops after having sent a
few bytes (without having received a read- or socket-callback). So we
repeaditly have to call curl_multi_socket_all to send the next part of the
buffer.

The following curl options are set:

curl_multi_setopt ( multiHandle, CURLMOPT_SOCKETFUNCTION,
internal::curl_socket_callback );
curl_multi_setopt (multiHandle, CURLMOPT_SOCKETDATA, this );
curl_multi_setopt (multiHandle, CURLMOPT_TIMERFUNCTION,
internal::curl_multi_timer_callback );
curl_multi_setopt (multiHandle, CURLMOPT_TIMERDATA, this );

curl_easy_setopt ( easyHandle, CURLOPT_PRIVATE, (void *)pUpload );
curl_easy_setopt ( easyHandle, CURLOPT_URL, remotePathName.c_str () );
curl_easy_setopt ( easyHandle, CURLOPT_POST, 1 );
curl_easy_setopt ( easyHandle, CURLOPT_READDATA, pFile );
curl_easy_setopt ( easyHandle, CURLOPT_POSTFIELDSIZE, fileSize );
curl_easy_setopt ( easyHandle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST );
curl_easy_setopt ( easyHandle, CURLOPT_USERPWD, login.c_str () );
curl_easy_setopt ( easyHandle, CURLOPT_CAPATH, certificateDirectory );

pCURLList = curl_slist_append ( pCURLList, "Content-Type: image/png" );
curl_easy_setopt ( easyHandle, CURLOPT_HTTPHEADER, pCURLList );

curl_easy_setopt ( easyHandle, CURLOPT_READFUNCTION,
internal::curl_read_callback );
curl_easy_setopt ( easyHandle, CURLOPT_READDATA, this );

curl_multi_add_handle ( multiHandle, easyHandle );

We have investigated this problem and it seems there is something wrong in
transfer.c function CURLcode Curl_readwrite(struct connectdata *conn, bool
*done) on line 1358 -> bool writedone=TRUE; It seems that writedone is
initialized on true, and the only value writedone gets assigned is true...
So the while loop (line 1369 to 1513 -> while(!writedone); ) can only be
executed once.

Purpose of the while loop is to keep sending data until the buffer is empty
or an EWOULDBLOCK is returned from the socket. In our case in the first
(and only) iteration there is some data sent from the buffer to the socket,
but not enough to get an EWOULDBLOCK back.

Initializing bool writedone to FALSE fixes the problem: the while loop is
iterated until the buffer is empty (or we receive an ewouldblock).

Now the question is: does this fix have any side effects for other requests?

Kind regards,

Raf Nulens
Received on 2007-07-04