1. 通过evhttp_connection_base_new设置了bufferevent的readcd:evhttp_read_cb, writecb:evhttp_write_cb。 2. 调用bufferevent_setfd bufferevent_setfd代码如下: intbufferevent_setfd(structbufferevent *bev, evutil_socket_t fd) { union bufferevent_ctrl_data d;intres = -1; d.fd=fd; BEV_LOCK(bev);if(...
1. 通过evhttp_connection_base_new设置了bufferevent的readcd:evhttp_read_cb, writecb:evhttp_write_cb。 2. 调用bufferevent_setfd bufferevent_setfd代码如下: intbufferevent_setfd(structbufferevent *bev, evutil_socket_t fd) { union bufferevent_ctrl_data d;intres = -1; d.fd=fd; BEV_LOCK(bev);if(...
1. I added BEV_OPT_THREADSAFE in evhttp_connection_base_new(evcon->bufev = bufferevent_socket_new(NULL, -1, BEV_OPT_THREADSAFE); +callbacks). This means switching callbacks, etc., are threadsafe now. 2. I refcount bufev while the thread is writing. In particular,evhttp_send_reply does ...
voidSubscriber::start(){#ifndefWIN32bufferevent_enable(req->evcon->bufev, EV_READ);#endifevhttp_connection_set_closecb(req->evcon, on_sub_disconnect,this);evhttp_add_header(req->output_headers,"Connection","keep-alive");evhttp_add_header(req->output_headers,"Content-Type","text/html;charse...
setsockopt(fd, SOL_SOCKET, TCP_NODELAY, (void *)&on, sizeof(on))); struct bufferevent *bev = bufferevent_socket_new(base, fd, BEV_OPT_CLOSE_ON_FREE | BEV_OPT_DEFER_CALLBACKS); struct evhttp_connection *evcon = evhttp_connection_base_bufferevent_new(base, NULL, bev, "foobar.com", ...
I am using libevent 2.1.8 for an HTTP client and found that some times requests go missing. The callback passed to evhttp_make_request will just never get called. I tracked it down to bufferevent_writecb getting called with event WRITE_E...
fd = http_connect("127.0.0.1", port);/* Stupid thing to send a request */bev = bufferevent_new(fd, http_readcb, http_writecb, http_errorcb,NULL); bufferevent_base_set(base, bev); http_request ="GET /test HTTP/1.1\r\n""Host: somehost\r\n""Connection: close\r\n""\r\n"; ...