Skip to content

Conversation

jcoffland
Copy link
Contributor

This adds a callback from evhttp_request_free() that guarantees resources associated with an evhttp_request can be deallocated. I found this necessary because the on complete and on error callbacks are not always called which can lead to memory leaks. This callback makes the resource deallocation explicit.

@coveralls
Copy link

coveralls commented Jan 31, 2018

Coverage Status

Coverage decreased (-0.008%) to 80.539% when pulling 63a6193 on CauldronDevelopmentLLC:evhttp_request_on_free_cb into f24b28e on libevent:master.

Copy link
Member

@azat azat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus this change will need a unit test.

Also would you mind to change the documentation to address issues that you found in #589?

@jcoffland jcoffland force-pushed the evhttp_request_on_free_cb branch from e9f13c6 to 63a6193 Compare February 4, 2018 19:50
@NathanFrench NathanFrench added the subsystem:http HTTP Related issue label May 2, 2018
@imay
Copy link

imay commented Jun 15, 2018

This patch is what I want

@jcoffland
Copy link
Contributor Author

@azat

Plus this change will need a unit test.

I'm confused as to how to create a unit test in this code base.

Also would you mind to change the documentation to address issues that you found in #589?

Not sure what you mean here.

@azat
Copy link
Member

azat commented Dec 2, 2018

I'm confused as to how to create a unit test in this code base.

regress_http.c

Not sure what you mean here.

I meant that we need to document order/cases in which callbacks will be called, so that it will be possible to figure this out without looking into sources, and since you adding yet another callback (and I assume that already look into all available callbacks in http and your knowledge was fresh, egh was cause it passed almost year since this pull request had been submitted) I would love to see separate patch that documents this.

/*
* Free callback - called just before the request is freed.
*/
void (*on_free_cb)(struct evhttp_request *, void *);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an ABI break. The soname needs to be bumped.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually using evhttp_request directly is not recommended, but yes it is.

And there is a comment in this file:

Data structures for http.  Using these structures may hurt forward
compatibility with later versions of Libevent: be careful!

But nobody reads headers

@azat
Copy link
Member

azat commented Oct 27, 2024

@pprindeville I'm really sorry for abandoning this, sadly, but I haven't have enough time for libevent for a long time already.
Please resubmit it if you are still interested (but don't forget the unit test), I'm OK with changes.

@azat azat closed this Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

6 participants