-
Notifications
You must be signed in to change notification settings - Fork 161
coredump problem of short connection accept. #15
Comments
/sig bug |
Sweet! I just got done pushing a bunch of stuff tonight, I will check this awesomeness out tomorrow. Thank you very much! |
Damn, I applaud your attention to detail. Working on it now. |
Just to be clear, |
What version are you using? Testing with the current pre-release, I cannot reproduce (using examples/test_basic.c):
If possible, do you have a backtrace? Edit: I couldn't reproduce with the following versions:
|
@NathanFrench thank you for your kindly reply. i have got code from [git clone ellzey/libevhtp] and i have checked the example test_basic.c, and it's no coredump problem. and would you explain that how to judge all data has successfully been written?
|
add more info:
the reason is that conn is already freed in the evhtp_connection_writecb func. |
in this web site, evhtp_connection_writecb is called when have data for writing.
and in the example test_basic.c, evhtp_connection_writecb is called after _evhtp_connection_readcb is completed. so coredump is not happened. would you explain more clear the time of calling evhtp_connection_writecb? |
Can you try the following:
Also, have you tried on current releases? |
@NathanFrench
|
and i have tried the current release, if not add |
and i think that |
you should set BEV_OPT_DEFER_CALLBACKS becouse you are using bufferevent_openssl_socket_new for https. |
This bug has been fixed for ages and has been backpatched in Libevent 2.0. But this is correct in another manner: you don't want events firing off while in mid-translation. |
may be it fixed, but i have the same problem with ssl (https) client, based on bufferevent (not evhtp_connection_new). i use libevent-2.1.7-rc. |
Sweet. May I close this ticket? |
@NathanFrench please close this issue. Thank you very much. |
1. coredump problem of short connection:
use libevhtp as http server, if request from client is a short connection(include "Connection":"close" header), i got a
coredump
at callhtparser_get_error()
in the_evhtp_connection_readcb()
func.2. reason of the coredump:
for the default callback registration in the
_evhtp_connection_accept()
func, when receive a short connection request, the action flow of server is:_evhtp_connection_readcb()
func and get the request data.htparser_run()
to verify and parse the request data. in thehtparser_run()
, after completed parse msg, it will callback the func(for example,the func name is:handle_cmd
) that registered byevhtp_set_cb()
.handle_cmd
func, after process the request body, in common we will write the response data(for example, callevhtp_send_reply()
func) in the end._evhtp_connection_writecb
that registered in the_evhtp_connection_accept()
will be triggered by the write action._evhtp_connection_writecb
func, if the request is a short connection, it will callevhtp_connection_free()
to free the connection.htparser_run
func, the connection variable in the_evhtp_connection_readcb
func is become invalid. so callhtparser_get_error
func get a coredump.3. code modify:
i have merged above changes in my project, it works correct now.
above modification is suitable or not, can you give some suggestions. Thanks in advance.
The text was updated successfully, but these errors were encountered: