cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Problems using curl_easy_pause() in chunked connections

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sat, 6 Mar 2010 18:13:25 +0100 (CET)

On Thu, 25 Feb 2010, Jose Juan Fernandez wrote:

> 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?

It seems like a bug to me. Can you repeat this problem on demand? I would
really like to understand it better and have a test case added for exactly
this to make sure that A) we fix it the best and proper way and B) we make
sure that we don't break it again in the future!

The test cases in the 500 range are all pure libcurl tests and based on one of
the existing ones it should be fairly straight-forward on how to make one for
this case.

> 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?

I would prefer if the code would instead call the pausewrite() function to set
the state.temp* variables, to keep that logic in the same place. I figure the
pausewrite() would then need to have some check around 'len' to only malloc
and memcpy if non-zero. Or similar.

Don't you think that makes sense?

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-03-06