In sample http-server.c in libevent-2.1.5-beta,I add some code to enable the iocp background,then the problem arise.The source code was below.
Problem:
it only accept the conncet,but the user callbake(dump_request_cb,send_document_cb) isn't be invoked
I think:
It is because the bev_a->ok not set to 1
Speculations:
What i try:
I modify the code in the case BEV_CTRL_SET_FD in method be_async_ctrl as below:
case BEV_CTRL_SET_FD: {
struct event_iocp_port *iocp;
if (data->fd == evbuffer_overlapped_get_fd_(bev->input))
return 0;
if (!(iocp = event_base_get_iocp_(bev->ev_base)))
return -1;
if (event_iocp_port_associate_(iocp, data->fd, 1) < 0)
{
int err = GetLastError();
/* We may have alrady associated this fd with a port.
* Let's hope it's this port, and that the error code
* for doing this neer changes. */
if (err != ERROR_INVALID_PARAMETER)
return -1;
}
evbuffer_overlapped_set_fd_(bev->input, data->fd);
evbuffer_overlapped_set_fd_(bev->output, data->fd);
struct bufferevent_async *bev_async = upcast(bev);
bev_async->ok = 1;
return 0;
}
Result: it works,the user callback can be invoke