#292 write callback not called at first when use IOCP

For_2.0
open
nobody
5
2012-11-05
2012-11-05
No

2.0.20 stable
Steps:
1.Create a event_base with IOCP:
evthread_use_windows_threads();
event_config_set_flag(ev_config, EVENT_BASE_FLAG_STARTUP_IOCP);
2.then call evconnlistener_new_bind(), the listener callback looks like this:
{
struct bufferevent *bev = bufferevent_socket_new(base, fd, BEV_OPT_CLOSE_ON_FREE);
bufferevent_setcb(bev, conn_readcb, conn_writecb, conn_eventcb, NULL);
bufferevent_enable(bev, EV_WRITE | EV_READ);
}
3. Connect from a client, nothing will happen, but if you create event_base without IOCP flag, conn_writecb will be called immediatly.

I know the callback mechanism when with IOCP or without IOCP are different, but this hidden difference is an unhappy experience especially when you want to use IOCP to replace select for code that works well. After all, when connection established, a connection should be ready for write.

Discussion

  • Nick Mathewson

    Nick Mathewson - 2012-11-05

    I agree that the two implementations should give the same behavior in this case.

    Have you had time to look at the code at all to see what's causing this problem? Is it just a missing call to invoke the write callback, or is there something more going on?

     
  • Xiao QingXing

    Xiao QingXing - 2012-11-06

    I think it's just missing the call. But when to call it is really a problem, because event_base_start_iocp is called when event_base created, it doesn't return until some writting happend.

    The attached is simply changed from hello-world.c in sample, you can see it.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks