Hi,
I am using libmicrohttpd in my application and am seeing an unexpected
sequence of function calls and am wondering if this is expected or
whether there is something that I've set up incorrectly.
When initiating the daemon, I am setting callbacks for both
MHD_OPTION_URI_LOG_CALLBACK and MHD_OPTION_NOTIFY_COMPLETED. Then upon
answering the request I am doing a MHD_create_response_from_callback.
What I'm observing is that the MHD_OPTION_NOTIFY_COMPLETED function is
called before the ContentReaderFreeCallback function from the response
callback. My expectation was that the callback "cleanup" would have
been called before the "notify completed".
The following code snippets may better explain the question. I am
seeing that the 'mhd_deinit' function is being called before the
'file_free' function.
----snip-----
mhd_ops[0].option = MHD_OPTION_URI_LOG_CALLBACK;
mhd_ops[0].value = (intptr_t)mhd_init;
mhd_ops[0].ptr_value = NULL;
mhd_ops[1].option = MHD_OPTION_NOTIFY_COMPLETED;
mhd_ops[1].value = (intptr_t)mhd_deinit;
mhd_ops[1].ptr_value = NULL;
mhd_ops[2].option = MHD_OPTION_END;
mhd_ops[2].value = 0;
mhd_ops[2].ptr_value = NULL;
daemon = MHD_start_daemon (MHD_USE_AUTO |
MHD_USE_INTERNAL_POLLING_THREAD,
PORT, NULL, NULL,
&answer_to_connection, NULL
, MHD_OPTION_ARRAY, mhd_ops
, MHD_OPTION_END);
----snip-----
response = MHD_create_response_from_callback (
webua->sz, 32 * 1024, &file_reader, webua, &file_free);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
Thanks.
MrDave