libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] MHD_RESPMEM_PERSISTENT


From: Christian Grothoff
Subject: Re: [libmicrohttpd] MHD_RESPMEM_PERSISTENT
Date: Tue, 24 Jan 2017 17:29:07 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0

Miguel,

I can only assume that your assertion that you are not modifying the
buffer after creating the response object is not correct.

My 2 cents

Christian

On 01/24/2017 05:22 PM, Miguel Sancho wrote:
> Hi Silvio, thanks for answering,
> 
>> Could you show what error and how the buffer was assigned?
> 
> The error is that the downloaded binary file from the MHD server with the
> MHD_RESPMEM_PERSISTENT option is corrupt:
> 
>    - Same size as the original
>    - The initial bytes are ok
>    - but from a certain point file contents are set to '0'. The
>    free(buffer) seems to impact the content downloaded in the http response, I
>    do not how because free() is after the MHD_destroy_response()
>    - Buffer is correctly downloaded when using the MHD_RESPMEM_MUST_COPY
>    option but I wanted to minimize the memory impacts
> 
> The buffer is allocated by the MHD server with malloc, simplifying:
>              unsigned char* buffer = (unsigned char*)malloc(dataSize);
>              memcpy(buffer, data, dataSize);
> 
> Another thing I observe is that if* I remove the free(buffer)*, the file is
> correctly downloaded. However this solution is not valid because in this
> case I have a memory leak:
> *            response = MHD_create_response_from_*
> 
> 
> 
> *buffer(
> size,(void*)buffer,MHD_RESPMEM_PERSISTENT);            ret =
> MHD_queue_response (connection, 200, response);
> MHD_destroy_response (response);            //free(buffer);   // Memory
> Leak!*
> 
> Thanks
> 
> Miguel
> 

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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