diff --git a/server/red_channel.c b/server/red_channel.c index ebb181c5..717da02c 100644 --- a/server/red_channel.c +++ b/server/red_channel.c @@ -185,10 +185,8 @@ static void red_peer_handle_outgoing(RedsStreamContext *peer, OutgoingHandler *h } } -static void red_channel_peer_on_error(void *opaque) +void red_channel_default_peer_on_error(RedChannel *channel) { - RedChannel *channel = (RedChannel *)opaque; - channel->disconnect(channel); } @@ -286,7 +284,7 @@ RedChannel *red_channel_create(int size, RedsStreamContext *peer, channel->incoming.alloc_msg_buf = (alloc_msg_recv_buf_proc)alloc_recv_buf; channel->incoming.release_msg_buf = (release_msg_recv_buf_proc)release_recv_buf; channel->incoming.handle_message = (handle_message_proc)handle_message; - channel->incoming.on_error = red_channel_peer_on_error; + channel->incoming.on_error = (on_incoming_error_proc)red_channel_default_peer_on_error; channel->outgoing.opaque = channel; channel->outgoing.pos = 0; @@ -296,7 +294,7 @@ RedChannel *red_channel_create(int size, RedsStreamContext *peer, channel->outgoing.get_msg_size = red_channel_peer_get_out_msg_size; channel->outgoing.prepare = red_channel_peer_prepare_out_msg; channel->outgoing.on_block = red_channel_peer_on_out_block; - channel->outgoing.on_error = red_channel_peer_on_error; + channel->outgoing.on_error = (on_outgoing_error_proc)red_channel_default_peer_on_error; channel->outgoing.on_msg_done = red_channel_peer_on_out_msg_done; channel->shut = 0; // came here from inputs, perhaps can be removed? XXX diff --git a/server/red_channel.h b/server/red_channel.h index 7c973fd4..5135970f 100644 --- a/server/red_channel.h +++ b/server/red_channel.h @@ -200,6 +200,8 @@ void red_channel_init_outgoing_messages_window(RedChannel *channel); int red_channel_handle_message(RedChannel *channel, uint32_t size, uint16_t type, void *message); +/* default error handler that disconnects channel */ +void red_channel_default_peer_on_error(RedChannel *channel); /* when preparing send_data: should call reset, then init and then add_buf per buffer that is being sent */