[Top][All Lists]

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

[libmicrohttpd] may libmicrohttpd change the connection pointer

From: Martin Velek
Subject: [libmicrohttpd] may libmicrohttpd change the connection pointer
Date: Thu, 30 Jan 2014 13:15:18 +0100


do not you know, can I rely on "constant" struct MHD_Connection
*connection pointer passed to (*MHD_AccessHandlerCallback)? The
constant is meant as not varying during a single connection. It is
quite difficult to explain for me so let me outline the example :)

The problem:
I need to access URI parameters in the response callback.

The solution:
The function (*MHD_AccessHandlerCallback) creates a response from
callback by passing (*MHD_ContentReaderCallback) to the function
MHD_create_response_from_callback. The pointer to struct
MHD_Connection * is stored in the crc_cls (extra argument to crc).

In the (*MHD_ContentReaderCallback) callback, the void *cls is casted
to struct MHD_Connection * and call MHD_get_connection_values to get

The problem appears when the libmicrohttpd somehow reallocates the
connection pointer internally during the next call of
(*MHD_AccessHandlerCallback) or (*MHD_ContentReaderCallback). I
remind, I think only one connection => *con_cls != NULL previusly set
to something different from NULL.

The story above can be also summarized to this question:
How can I access the connection information from the response callback?


reply via email to

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