Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong usage of struct evhttp_request in trace log #13

Closed
zieckey opened this issue Mar 18, 2017 · 1 comment
Closed

Wrong usage of struct evhttp_request in trace log #13

zieckey opened this issue Mar 18, 2017 · 1 comment

Comments

@zieckey
Copy link
Collaborator

zieckey commented Mar 18, 2017

We cannot use struct evhttp_request* req any more after we called evhttp_send_reply.

struct Response {
    Response(struct evhttp_request* r, const std::string& m)
        : req(r), buffer(nullptr) {
        if (m.size() > 0) {
            buffer = evbuffer_new();
            evbuffer_add(buffer, m.c_str(), m.size());
        }
    }

    ~Response() {
        if (buffer) {
            evbuffer_free(buffer);
            buffer = nullptr;
        }

        // At this time, req is freed by evhttp framework probably.
        // So don't use req any more.
        // LOG_TRACE << "free request " << req->uri;
    }

    struct evhttp_request*  req;
    struct evbuffer* buffer;
};
@zieckey
Copy link
Collaborator Author

zieckey commented Mar 18, 2017

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant