libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] infinite loop even when connection is closed by clie


From: Christian Grothoff
Subject: Re: [libmicrohttpd] infinite loop even when connection is closed by client in the create_response_from_callback when max < buffer size
Date: Wed, 19 Jan 2011 15:26:10 +0100
User-agent: KMail/1.13.5 (Linux/2.6.32-trunk-vserver-amd64; KDE/4.4.5; x86_64; ; )

Hi!

First of all, which threading mode are you using? (external select, internal 
select, thread-per-connection?).  Also, are you using chunked encoding or not?

In any case, looking at the code (there are two places in connection.c where 
we call the content reader callback, both with the format "response->crc", the 
'max' argument should always be either block_size (unchunked) or block_size - 
12 (chunked encoding), unless you're at the end of the file (which for 
MHD_SIZE_UNKNOWN you'd never be).

So a value of 16372 is rather strange (359988 OTOH should be something you 
ought to have to deal with...).  Could you answer the above questions and 
maybe also supply a stack trace with the values of the "response" and 
"connection" structs on the stack upon the time of the call?

Finally, in terms of being called "forever", you may want to add a timeout to 
your connections (option to MHD_start_daemon).  

Happy hacking,

Christian

On Wednesday 19 January 2011 13:37:37 Leandro Santiago wrote:
> Hello to all. I'm streaming videos via http using libmicrohttpd.
> 
> To do it, I'm using the MHD_create_response_from_callback, using a callback
> with the interface:
> 
> static ssize_t video_generator(void* cls, uint64_t pos, char* buf, size_t
> max);
> 
> When I call MHD_create_function_from_callback, I'm passing the value 360000
> as the block_size and MHD_SIZE_UNKNOWN as size;
> 
> The problem is sometimes the max value isn't 360000, but a lower value
> (16372).
> 
> As I can't work with this low value, I ask, in the beginning of
> video_generator:
> 
> if (max < 360000) return 0;
> 
> The problem is thereafter this function (video_generator) is called
> everytime, indefinitely, passing max as 16372 and the "pos" value as 0.
> Even if I close the connection (closing the client, for example), the
> video_generator callback continues indefinitely, with the same values (max
> = 16372 and pos = 0). So I need to kill the process.
> 
> For example, the above behavior happens when I use any webbrowser as
> client, but doesn't happen when I use mplayer (which supports http
> protocol).
> 
> What this function does is: everytime it's called, it sends one frame to
> the client.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]