cURL / Mailing Lists / curl-library / Single Mail

curl-library

Problems using curl_easy_pause() in chunked connections

From: Jose Juan Fernandez <JoseJuan.Fernandez_at_pure.com>
Date: Thu, 25 Feb 2010 11:54:26 -0000

Hi, I have been using libcurl for a while without any major issues (thanks for the great job!!). However, I recently found a case where it would cancel connections just after calling curl_easy_pause(). I tracked this down to the following line inside Curl_client_write() (sendf.c:379): if(type != data->state.tempwritetype) /* major internal confusion */ return CURLE_RECV_ERROR; This checks whether the current contents of the temporary buffer are the same type of data as the chunk we have just received (the "temporary buffer" contains the data received in a paused connection waiting to be given to the user). curl_easy_pause() doesn't need to store any data in the temporary buffer, so it neither sets that "current data type" variable. Usually this doesn't cause any problems because Curl_client_write() won't get called in a paused connection. But in chunked transfers, this may happen, and in that situation Curl_client_write() finds that the variables related to the temporary buffer are uninitialized and chooses to close the connection. Is this a bug in the library, or I am just doing something wrong? I tried to automatically setup all data->state.tempwrite* vars when Curl_client_write() finds data->state.tempwritetype==0. This seems to work ok, and to me it looks sensible: if we receive some data with the connection paused, but the buffer is still empty and uninitialized, we can just initialize it. Please take a look at the attached patch. Do you think this makes sense? Should I submit it for inclusion in some future release? In that case, what would be the proper way of submitting it? Thanks a lot, Jose - PURE is part of the Imagination Technologies Group. This message is subject to Imagination Technologies' e-mail terms: http://www.imgtec.com/e-mail.htm Imagination Technologies Ltd is a limited company registered in England No: 1306335 Registered Office: Imagination House, Home Park Estate, Kings Langley, Hertfordshire, WD4 8LZ. Email to and from the company may be monitored for compliance and other administrative purposes. -

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

Received on 2010-02-25