Coder Social home page Coder Social logo

Comments (6)

nmathewson avatar nmathewson commented on September 27, 2024

Hm. It could be that there's another evhttp_request_free somewhere in here happening first. Can you use a debugger or valgrind or something to see where the first call to evhttp_request_free is happening?

from libevent.

pphaneuf avatar pphaneuf commented on September 27, 2024

A request still in progress when an evhttp_connection gets freed will get blown away:

https://github.com/libevent/libevent/blob/patches-2.0/http.c#L1142

Is that expected? I'd think that if you used evhttp_request_own, the user should be the one doing the evhttp_request_free?

from libevent.

pphaneuf avatar pphaneuf commented on September 27, 2024

Got started on a pull request to fix this (it fixes the case that the example program above triggers), but I think we should go over the calls to evhttp_request_free in http.c and review whether they should be conditional or not (which I could add to this pull request).

from libevent.

errzey avatar errzey commented on September 27, 2024

Just for my own information: we have made no claims that after evhttp_request_own() we do further processing on it, correct? in evhtp, the function evhtp_take_ownership() relinquishes all further processing from the library.

If this is the case, maybe a simple macro for internal use only:

#define evhttp_request_free_(req_)  do {           \
    if ((req_->flags & EVHTTP_USER_OWNED) == 0) {  \
         evhttp_request_free(req_);                \
    } } while(0)                                   \

from libevent.

pphaneuf avatar pphaneuf commented on September 27, 2024

My understanding is that this function only changes the memory ownership (in other words, processing continues, but now the user is responsible for freeing the request, as maybe they want to access the header/body after returning from the callback).

from libevent.

azat avatar azat commented on September 27, 2024

So I decided to use inline function instead of macros (since it is easy to debug), other then this it is the same as @ellzey suggested. Plus add a regression test for this.

from libevent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.