-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
The documentation for evhttp_request_set_error_cb()
says:
On error, both the error callback and the regular callback will be called, error callback is called before the regular callback.
It is unclear what is meant by the "regular callback". I had assumed this meant the request complete callback. However, it's not possible for any request callback to be called after the error callback. The error callback is invoked in evhttp_connection_fail_()
and the request is freed in that function. So it is not possible to call the complete callback or any other request callback after the error callback is called.
The documentation for evhttp_request_set_on_complete_cb()
does not make it clear that the complete callback may never get called. This is problematic if the complete callback is being used to deallocate resources.
Further complicating the resource allocation issue, if the user cancels the request with evhttp_cancel_request()
then neither callback is called. A much cleaner solution is to add a request free callback which is always called in evhttp_request_free()
if set by the user.