diff options
author | Yonit Halperin <yhalperi@redhat.com> | 2013-05-07 12:26:10 -0400 |
---|---|---|
committer | Yonit Halperin <yhalperi@redhat.com> | 2013-05-08 11:26:57 -0400 |
commit | 5fb3d2557ee37be4ce4f6eb041148d3eb922978a (patch) | |
tree | c88834d643266b97452ac3d4550a4f4feb133658 | |
parent | 20cc9567643dcd33166359fa2226ae15030939b3 (diff) |
reds: move handle_channel_event logic from main_dispatcher to reds
main_dispactcher role is to pass events to the main thread.
The logic that handles the event better not be inside main_dispatcher.
-rw-r--r-- | server/main_dispatcher.c | 5 | ||||
-rw-r--r-- | server/reds.c | 19 | ||||
-rw-r--r-- | server/reds.h | 4 |
3 files changed, 19 insertions, 9 deletions
diff --git a/server/main_dispatcher.c b/server/main_dispatcher.c index 84024024..92b0791c 100644 --- a/server/main_dispatcher.c +++ b/server/main_dispatcher.c @@ -64,10 +64,7 @@ static void main_dispatcher_self_handle_channel_event( int event, SpiceChannelEventInfo *info) { - main_dispatcher.core->channel_event(event, info); - if (event == SPICE_CHANNEL_EVENT_DISCONNECTED) { - free(info); - } + reds_handle_channel_event(event, info); } static void main_dispatcher_handle_channel_event(void *opaque, diff --git a/server/reds.c b/server/reds.c index b8db905e..a378f80c 100644 --- a/server/reds.c +++ b/server/reds.c @@ -189,11 +189,20 @@ static ChannelSecurityOptions *find_channel_security(int id) return now; } -static void reds_stream_channel_event(RedsStream *s, int event) +static void reds_stream_push_channel_event(RedsStream *s, int event) +{ + main_dispatcher_channel_event(event, s->info); +} + +void reds_handle_channel_event(int event, SpiceChannelEventInfo *info) { if (core->base.minor_version < 3 || core->channel_event == NULL) return; - main_dispatcher_channel_event(event, s->info); + + core->channel_event(event, info); + if (event == SPICE_CHANNEL_EVENT_DISCONNECTED) { + free(info); + } } static ssize_t stream_write_cb(RedsStream *s, const void *buf, size_t size) @@ -1524,7 +1533,7 @@ static void reds_info_new_channel(RedLinkInfo *link, int connection_id) link->stream->info->connection_id = connection_id; link->stream->info->type = link->link_mess->channel_type; link->stream->info->id = link->link_mess->channel_id; - reds_stream_channel_event(link->stream, SPICE_CHANNEL_EVENT_INITIALIZED); + reds_stream_push_channel_event(link->stream, SPICE_CHANNEL_EVENT_INITIALIZED); } static void reds_send_link_result(RedLinkInfo *link, uint32_t error) @@ -2845,7 +2854,7 @@ static RedLinkInfo *reds_init_client_connection(int socket) getpeername(stream->socket, (struct sockaddr*)(&stream->info->paddr_ext), &stream->info->plen_ext); - reds_stream_channel_event(stream, SPICE_CHANNEL_EVENT_CONNECTED); + reds_stream_push_channel_event(stream, SPICE_CHANNEL_EVENT_CONNECTED); openssl_init(link); @@ -4573,7 +4582,7 @@ void reds_stream_free(RedsStream *s) return; } - reds_stream_channel_event(s, SPICE_CHANNEL_EVENT_DISCONNECTED); + reds_stream_push_channel_event(s, SPICE_CHANNEL_EVENT_DISCONNECTED); #if HAVE_SASL if (s->sasl.conn) { diff --git a/server/reds.h b/server/reds.h index 59f13cec..c5c557d7 100644 --- a/server/reds.h +++ b/server/reds.h @@ -111,11 +111,15 @@ typedef struct RedsMigSpice { int sport; } RedsMigSpice; +/* any thread */ ssize_t reds_stream_read(RedsStream *s, void *buf, size_t nbyte); ssize_t reds_stream_write(RedsStream *s, const void *buf, size_t nbyte); ssize_t reds_stream_writev(RedsStream *s, const struct iovec *iov, int iovcnt); void reds_stream_free(RedsStream *s); +/* main thread only */ +void reds_handle_channel_event(int event, SpiceChannelEventInfo *info); + void reds_disable_mm_timer(void); void reds_enable_mm_timer(void); void reds_update_mm_timer(uint32_t mm_time); |