|
|
@ -172,19 +172,30 @@ static void streambuf_listener_newconn(struct obj *p, socket_t *newsock, char *a |
|
|
i.timer = streambuf_stream_timer; |
|
|
i.timer = streambuf_stream_timer; |
|
|
i.obj = &s->obj; |
|
|
i.obj = &s->obj; |
|
|
|
|
|
|
|
|
if (poller_add_item(listener->poller, &i)) |
|
|
|
|
|
goto fail; |
|
|
|
|
|
|
|
|
|
|
|
if (cb->newconn_func) |
|
|
if (cb->newconn_func) |
|
|
cb->newconn_func(s); |
|
|
cb->newconn_func(s); |
|
|
|
|
|
|
|
|
|
|
|
obj_hold(s); |
|
|
|
|
|
|
|
|
mutex_lock(&listener->lock); |
|
|
mutex_lock(&listener->lock); |
|
|
g_hash_table_insert(listener->streams, s, s); // hand over ref |
|
|
g_hash_table_insert(listener->streams, s, s); // hand over ref |
|
|
mutex_unlock(&listener->lock); |
|
|
mutex_unlock(&listener->lock); |
|
|
|
|
|
|
|
|
|
|
|
if (poller_add_item(listener->poller, &i)) |
|
|
|
|
|
goto fail; |
|
|
|
|
|
|
|
|
|
|
|
obj_put(s); |
|
|
|
|
|
|
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
fail: |
|
|
fail: |
|
|
|
|
|
mutex_lock(&listener->lock); |
|
|
|
|
|
int ret = g_hash_table_remove(listener->streams, s); |
|
|
|
|
|
mutex_unlock(&listener->lock); |
|
|
|
|
|
|
|
|
|
|
|
if (ret) |
|
|
|
|
|
obj_put(s); |
|
|
|
|
|
|
|
|
obj_put(s); |
|
|
obj_put(s); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|