[gnet-devel] gnet_conn_set_main_context() issue ... a bug ??



Hi,

I'm using 2.0.8 gnet_conn_set_main_context() to put GConn in
an independents GMainLoop.   Basically my code looks like below:

while(1) {
    conn = gnet_conn_new(...)
    ctx = g_main_context_new()
    loop = g_main_loop_new(ctx, FALSE)

    gnet_conn_set_main_context(conn, ctx)
    gnet_conn_set_watch_error
    gnet_conn_timeout
    gnet_conn_connect
    g_main_loop_run()

    // if something wrong ... do cleanup and try reconnect
    g_main_loop_unref(loop)
    g_main_context_unref(ctx)
    g_main_context_unref(ctx) ///// MUST unref twice !!!
    gnet_conn_delete(conn)
    g_usleep(1000)
}


Please notice that I need to call g_main_context_unref(ctx) twice
or after couple loop ... I will got:

GLib-ERROR **: Cannot create pipe main loop wake-up: Too many open files

I traced the gnet-2.0.8 source code and found
gnet_conn_set_main_context() will increase GMainContext's reference count
but gnet_conn_delete() or gnet_conn_unref() did not unref it ...

I will consider this as gnet_conn_unref()'s bug ... anyone can confirm this ?
thanks.

I can provide a patch if someone can tell me how to contribute.

Regrads,
KC


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]