static void simple_tcp_io_cb(liIOStream *stream, liIOStreamEvent event) { simple_tcp_connection *data = stream->data; LI_FORCE_ASSERT(NULL != data); LI_FORCE_ASSERT(NULL == data->con || data == data->con->con_sock.data); LI_FORCE_ASSERT(NULL == data->sock_stream || stream == data->sock_stream); li_connection_simple_tcp(&data->con, stream, &data->simple_tcp_context, event); if (NULL != data->con && data->con->out_has_all_data && (NULL == stream->stream_out.out || 0 == stream->stream_out.out->length)) { li_stream_simple_socket_flush(stream); li_connection_request_done(data->con); } switch (event) { case LI_IOSTREAM_DESTROY: LI_FORCE_ASSERT(NULL == data->con); LI_FORCE_ASSERT(NULL == data->sock_stream); stream->data = NULL; g_slice_free(simple_tcp_connection, data); break; default: break; } }
static void tcp_io_cb(liIOStream *stream, liIOStreamEvent event) { mod_connection_ctx *conctx = stream->data; LI_FORCE_ASSERT(NULL == conctx->sock_stream || conctx->sock_stream == stream); if (LI_IOSTREAM_DESTROY == event) { li_stream_simple_socket_close(stream, TRUE); /* kill it, ssl sent an close alert message */ } li_connection_simple_tcp(&conctx->con, stream, &conctx->simple_socket_data, event); if (NULL != conctx->con && conctx->con->out_has_all_data && (NULL == stream->stream_out.out || 0 == stream->stream_out.out->length) && li_streams_empty(conctx->con->con_sock.raw_out, NULL)) { li_stream_simple_socket_flush(stream); li_connection_request_done(conctx->con); } switch (event) { case LI_IOSTREAM_DESTROY: LI_FORCE_ASSERT(NULL == conctx->sock_stream); LI_FORCE_ASSERT(NULL == conctx->tls_filter); LI_FORCE_ASSERT(NULL == conctx->con); stream->data = NULL; g_slice_free(mod_connection_ctx, conctx); return; default: break; } }