From d47912241f4bc263cf3c19c07ed3907681826277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Sun, 27 Feb 2011 09:38:04 +0100 Subject: [PATCH] server: s/RedsStreamContext/RedsStream https://bugs.freedesktop.org/show_bug.cgi?id=34795 --- server/inputs_channel.c | 2 +- server/main_channel.c | 2 +- server/red_channel.c | 10 +++++----- server/red_channel.h | 6 +++--- server/red_dispatcher.c | 8 ++++---- server/red_tunnel_worker.c | 4 ++-- server/red_worker.c | 16 ++++++++-------- server/reds.c | 28 ++++++++++++++-------------- server/reds.h | 8 ++++---- server/smartcard.c | 2 +- server/snd_worker.c | 8 ++++---- 11 files changed, 47 insertions(+), 47 deletions(-) diff --git a/server/inputs_channel.c b/server/inputs_channel.c index c930d4d..ebf915c 100644 --- a/server/inputs_channel.c +++ b/server/inputs_channel.c @@ -512,7 +512,7 @@ static void inputs_channel_hold_pipe_item(PipeItem *item) { } -static void inputs_link(Channel *channel, RedsStreamContext *peer, int migration, +static void inputs_link(Channel *channel, RedsStream *peer, int migration, int num_common_caps, uint32_t *common_caps, int num_caps, uint32_t *caps) { diff --git a/server/main_channel.c b/server/main_channel.c index 67ac72f..f43f89a 100644 --- a/server/main_channel.c +++ b/server/main_channel.c @@ -780,7 +780,7 @@ static void main_channel_hold_pipe_item(PipeItem *item) { } -static void main_channel_link(Channel *channel, RedsStreamContext *peer, int migration, +static void main_channel_link(Channel *channel, RedsStream *peer, int migration, int num_common_caps, uint32_t *common_caps, int num_caps, uint32_t *caps) { diff --git a/server/red_channel.c b/server/red_channel.c index 6008876..788960f 100644 --- a/server/red_channel.c +++ b/server/red_channel.c @@ -33,7 +33,7 @@ static PipeItem *red_channel_pipe_get(RedChannel *channel); static void red_channel_event(int fd, int event, void *data); /* return the number of bytes read. -1 in case of error */ -static int red_peer_receive(RedsStreamContext *peer, uint8_t *buf, uint32_t size) +static int red_peer_receive(RedsStream *peer, uint8_t *buf, uint32_t size) { uint8_t *pos = buf; while (size) { @@ -68,7 +68,7 @@ static int red_peer_receive(RedsStreamContext *peer, uint8_t *buf, uint32_t size // does many calls to red_peer_receive and through it cb_read, and thus avoids pointer // arithmetic for the case where a single cb_read could return multiple messages. But // this is suboptimal potentially. Profile and consider fixing. -static void red_peer_handle_incoming(RedsStreamContext *peer, IncomingHandler *handler) +static void red_peer_handle_incoming(RedsStream *peer, IncomingHandler *handler) { int bytes_read; uint8_t *parsed; @@ -152,7 +152,7 @@ void red_channel_receive(RedChannel *channel) red_peer_handle_incoming(channel->peer, &channel->incoming); } -static void red_peer_handle_outgoing(RedsStreamContext *peer, OutgoingHandler *handler) +static void red_peer_handle_outgoing(RedsStream *peer, OutgoingHandler *handler) { int n; if (handler->size == 0) { @@ -252,7 +252,7 @@ static void red_channel_peer_on_out_msg_done(void *opaque) } } -RedChannel *red_channel_create(int size, RedsStreamContext *peer, +RedChannel *red_channel_create(int size, RedsStream *peer, SpiceCoreInterface *core, int migrate, int handle_acks, channel_configure_socket_proc config_socket, @@ -334,7 +334,7 @@ int do_nothing_handle_message(RedChannel *red_channel, SpiceDataHeader *header, return TRUE; } -RedChannel *red_channel_create_parser(int size, RedsStreamContext *peer, +RedChannel *red_channel_create_parser(int size, RedsStream *peer, SpiceCoreInterface *core, int migrate, int handle_acks, channel_configure_socket_proc config_socket, diff --git a/server/red_channel.h b/server/red_channel.h index 2ee6566..fd9ce37 100644 --- a/server/red_channel.h +++ b/server/red_channel.h @@ -114,7 +114,7 @@ typedef void (*channel_on_incoming_error_proc)(RedChannel *channel); typedef void (*channel_on_outgoing_error_proc)(RedChannel *channel); struct RedChannel { - RedsStreamContext *peer; + RedsStream *peer; SpiceCoreInterface *core; int migrate; int handle_acks; @@ -160,7 +160,7 @@ struct RedChannel { /* if one of the callbacks should cause disconnect, use red_channel_shutdown and don't explicitly destroy the channel */ -RedChannel *red_channel_create(int size, RedsStreamContext *peer, +RedChannel *red_channel_create(int size, RedsStream *peer, SpiceCoreInterface *core, int migrate, int handle_acks, channel_configure_socket_proc config_socket, @@ -174,7 +174,7 @@ RedChannel *red_channel_create(int size, RedsStreamContext *peer, /* alternative constructor, meant for marshaller based (inputs,main) channels, * will become default eventually */ -RedChannel *red_channel_create_parser(int size, RedsStreamContext *peer, +RedChannel *red_channel_create_parser(int size, RedsStream *peer, SpiceCoreInterface *core, int migrate, int handle_acks, channel_configure_socket_proc config_socket, diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c index 2a3c297..3816e14 100644 --- a/server/red_dispatcher.c +++ b/server/red_dispatcher.c @@ -71,7 +71,7 @@ extern spice_wan_compression_t zlib_glz_state; static RedDispatcher *dispatchers = NULL; -static void red_dispatcher_set_peer(Channel *channel, RedsStreamContext *peer, int migration, +static void red_dispatcher_set_peer(Channel *channel, RedsStream *peer, int migration, int num_common_caps, uint32_t *common_caps, int num_caps, uint32_t *caps) { @@ -81,7 +81,7 @@ static void red_dispatcher_set_peer(Channel *channel, RedsStreamContext *peer, i dispatcher = (RedDispatcher *)channel->data; RedWorkerMessage message = RED_WORKER_MESSAGE_DISPLAY_CONNECT; write_message(dispatcher->channel, &message); - send_data(dispatcher->channel, &peer, sizeof(RedsStreamContext *)); + send_data(dispatcher->channel, &peer, sizeof(RedsStream *)); send_data(dispatcher->channel, &migration, sizeof(int)); } @@ -101,7 +101,7 @@ static void red_dispatcher_migrate(Channel *channel) write_message(dispatcher->channel, &message); } -static void red_dispatcher_set_cursor_peer(Channel *channel, RedsStreamContext *peer, +static void red_dispatcher_set_cursor_peer(Channel *channel, RedsStream *peer, int migration, int num_common_caps, uint32_t *common_caps, int num_caps, uint32_t *caps) @@ -110,7 +110,7 @@ static void red_dispatcher_set_cursor_peer(Channel *channel, RedsStreamContext * red_printf(""); RedWorkerMessage message = RED_WORKER_MESSAGE_CURSOR_CONNECT; write_message(dispatcher->channel, &message); - send_data(dispatcher->channel, &peer, sizeof(RedsStreamContext *)); + send_data(dispatcher->channel, &peer, sizeof(RedsStream *)); send_data(dispatcher->channel, &migration, sizeof(int)); } diff --git a/server/red_tunnel_worker.c b/server/red_tunnel_worker.c index f60894b..6ea58f0 100644 --- a/server/red_tunnel_worker.c +++ b/server/red_tunnel_worker.c @@ -598,7 +598,7 @@ static void arm_timer(SlirpUsrNetworkInterface *usr_interface, UserTimer *timer, /* reds interface */ -static void handle_tunnel_channel_link(Channel *channel, RedsStreamContext *peer, int migration, +static void handle_tunnel_channel_link(Channel *channel, RedsStream *peer, int migration, int num_common_caps, uint32_t *common_caps, int num_caps, uint32_t *caps); static void handle_tunnel_channel_shutdown(struct Channel *channel); @@ -3424,7 +3424,7 @@ static void tunnel_channel_hold_pipe_item(PipeItem *item) { } -static void handle_tunnel_channel_link(Channel *channel, RedsStreamContext *peer, int migration, +static void handle_tunnel_channel_link(Channel *channel, RedsStream *peer, int migration, int num_common_caps, uint32_t *common_caps, int num_caps, uint32_t *caps) { diff --git a/server/red_worker.c b/server/red_worker.c index d75856e..96d5c94 100644 --- a/server/red_worker.c +++ b/server/red_worker.c @@ -355,7 +355,7 @@ typedef int (*channel_handle_parsed_proc)(RedChannel *channel, uint32_t size, ui struct RedChannel { spice_parse_channel_func_t parser; - RedsStreamContext *peer; + RedsStream *peer; int migrate; Ring pipe; @@ -9352,7 +9352,7 @@ static void free_common_channel_from_listener(EventListener *ctx) } static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_id, - RedsStreamContext *peer, int migrate, + RedsStream *peer, int migrate, event_listener_action_proc handler, channel_disconnect_proc disconnect, channel_hold_pipe_item_proc hold_item, @@ -9485,7 +9485,7 @@ static void display_channel_release_item(RedChannel *channel, PipeItem *item, in } } -static void handle_new_display_channel(RedWorker *worker, RedsStreamContext *peer, int migrate) +static void handle_new_display_channel(RedWorker *worker, RedsStream *peer, int migrate) { DisplayChannel *display_channel; size_t stream_buf_size; @@ -9612,7 +9612,7 @@ static void cursor_channel_release_item(RedChannel *channel, PipeItem *item, int red_release_cursor(common->worker, SPICE_CONTAINEROF(item, CursorItem, pipe_data)); } -static void red_connect_cursor(RedWorker *worker, RedsStreamContext *peer, int migrate) +static void red_connect_cursor(RedWorker *worker, RedsStream *peer, int migrate) { CursorChannel *channel; @@ -10053,11 +10053,11 @@ static void handle_dev_input(EventListener *listener, uint32_t events) handle_dev_destroy_primary_surface(worker); break; case RED_WORKER_MESSAGE_DISPLAY_CONNECT: { - RedsStreamContext *peer; + RedsStream *peer; int migrate; red_printf("connect"); - receive_data(worker->channel, &peer, sizeof(RedsStreamContext *)); + receive_data(worker->channel, &peer, sizeof(RedsStream *)); receive_data(worker->channel, &migrate, sizeof(int)); handle_new_display_channel(worker, peer, migrate); break; @@ -10101,11 +10101,11 @@ static void handle_dev_input(EventListener *listener, uint32_t events) red_migrate_display(worker); break; case RED_WORKER_MESSAGE_CURSOR_CONNECT: { - RedsStreamContext *peer; + RedsStream *peer; int migrate; red_printf("cursor connect"); - receive_data(worker->channel, &peer, sizeof(RedsStreamContext *)); + receive_data(worker->channel, &peer, sizeof(RedsStream *)); receive_data(worker->channel, &migrate, sizeof(int)); red_connect_cursor(worker, peer, migrate); break; diff --git a/server/reds.c b/server/reds.c index 573a838..2edf3e8 100644 --- a/server/reds.c +++ b/server/reds.c @@ -224,7 +224,7 @@ typedef struct RedsState { static RedsState *reds = NULL; typedef struct AsyncRead { - RedsStreamContext *peer; + RedsStream *peer; void *opaque; uint8_t *now; uint8_t *end; @@ -233,7 +233,7 @@ typedef struct AsyncRead { } AsyncRead; typedef struct RedLinkInfo { - RedsStreamContext *peer; + RedsStream *peer; AsyncRead asyc_read; SpiceLinkHeader link_header; SpiceLinkMess *link_mess; @@ -297,7 +297,7 @@ static ChannelSecurityOptions *find_channel_security(int id) return now; } -static void reds_channel_event(RedsStreamContext *peer, int event) +static void reds_channel_event(RedsStream *peer, int event) { if (core->base.minor_version < 3 || core->channel_event == NULL) return; @@ -326,7 +326,7 @@ static int reds_read(void *ctx, void *buf, size_t size) return (return_code); } -static int reds_free(RedsStreamContext *peer) +static int reds_free(RedsStream *peer) { reds_channel_event(peer, SPICE_CHANNEL_EVENT_DISCONNECTED); close(peer->socket); @@ -392,7 +392,7 @@ static int reds_ssl_writev(void *ctx, const struct iovec *vector, int count) return return_code; } -static int reds_ssl_free(RedsStreamContext *peer) +static int reds_ssl_free(RedsStream *peer) { reds_channel_event(peer, SPICE_CHANNEL_EVENT_DISCONNECTED); SSL_free(peer->ssl); @@ -418,7 +418,7 @@ static void __reds_release_link(RedLinkInfo *link) static inline void reds_release_link(RedLinkInfo *link) { - RedsStreamContext *peer = link->peer; + RedsStream *peer = link->peer; __reds_release_link(link); peer->cb_free(peer); } @@ -1370,7 +1370,7 @@ void reds_on_main_receive_migrate_data(MainMigrateData *data, uint8_t *end) while (write_to_vdi_port() || read_from_vdi_port()); } -static int sync_write(RedsStreamContext *peer, void *in_buf, size_t n) +static int sync_write(RedsStream *peer, void *in_buf, size_t n) { uint8_t *buf = (uint8_t *)in_buf; while (n) { @@ -1482,7 +1482,7 @@ static void reds_send_link_result(RedLinkInfo *link, uint32_t error) // actually be joined with reds_handle_other_links, ebcome reds_handle_link static void reds_handle_main_link(RedLinkInfo *link) { - RedsStreamContext *peer; + RedsStream *peer; SpiceLinkMess *link_mess; uint32_t *caps; uint32_t connection_id; @@ -1583,7 +1583,7 @@ static void openssl_init(RedLinkInfo *link) static void reds_handle_other_links(RedLinkInfo *link) { Channel *channel; - RedsStreamContext *peer; + RedsStream *peer; SpiceLinkMess *link_mess; uint32_t *caps; @@ -1844,7 +1844,7 @@ static void reds_handle_ssl_accept(int fd, int event, void *data) static RedLinkInfo *__reds_accept_connection(int listen_socket) { RedLinkInfo *link; - RedsStreamContext *peer; + RedsStream *peer; int delay_val = 1; int flags; int socket; @@ -1869,7 +1869,7 @@ static RedLinkInfo *__reds_accept_connection(int listen_socket) } link = spice_new0(RedLinkInfo, 1); - peer = spice_new0(RedsStreamContext, 1); + peer = spice_new0(RedsStream, 1); link->peer = peer; peer->socket = socket; @@ -1893,7 +1893,7 @@ error: static RedLinkInfo *reds_accept_connection(int listen_socket) { RedLinkInfo *link; - RedsStreamContext *peer; + RedsStream *peer; if (!(link = __reds_accept_connection(listen_socket))) { return NULL; @@ -1903,7 +1903,7 @@ static RedLinkInfo *reds_accept_connection(int listen_socket) peer->cb_read = (int (*)(void *, void *, int))reds_read; peer->cb_write = (int (*)(void *, void *, int))reds_write; peer->cb_writev = (int (*)(void *, const struct iovec *vector, int count))writev; - peer->cb_free = (int (*)(RedsStreamContext *))reds_free; + peer->cb_free = (int (*)(RedsStream *))reds_free; return link; } @@ -1939,7 +1939,7 @@ static void reds_accept_ssl_connection(int fd, int event, void *data) link->peer->cb_write = (int (*)(void *, void *, int))reds_ssl_write; link->peer->cb_read = (int (*)(void *, void *, int))reds_ssl_read; link->peer->cb_writev = reds_ssl_writev; - link->peer->cb_free = (int (*)(RedsStreamContext *))reds_ssl_free; + link->peer->cb_free = (int (*)(RedsStream *))reds_ssl_free; return_code = SSL_accept(link->peer->ssl); if (return_code == 1) { diff --git a/server/reds.h b/server/reds.h index 547c33c..b974eda 100644 --- a/server/reds.h +++ b/server/reds.h @@ -28,7 +28,7 @@ #define __visible__ __attribute__ ((visibility ("default"))) -typedef struct RedsStreamContext { +typedef struct RedsStream { void *ctx; int socket; @@ -45,8 +45,8 @@ typedef struct RedsStreamContext { int (*cb_read)(void *, void *, int); int (*cb_writev)(void *, const struct iovec *vector, int count); - int (*cb_free)(struct RedsStreamContext *); -} RedsStreamContext; + int (*cb_free)(struct RedsStream *); +} RedsStream; typedef struct Channel { struct Channel *next; @@ -56,7 +56,7 @@ typedef struct Channel { uint32_t *common_caps; int num_caps; uint32_t *caps; - void (*link)(struct Channel *, RedsStreamContext *peer, int migration, int num_common_caps, + void (*link)(struct Channel *, RedsStream *peer, int migration, int num_common_caps, uint32_t *common_caps, int num_caps, uint32_t *caps); void (*shutdown)(struct Channel *); void (*migrate)(struct Channel *); diff --git a/server/smartcard.c b/server/smartcard.c index a93e59d..23b3779 100644 --- a/server/smartcard.c +++ b/server/smartcard.c @@ -469,7 +469,7 @@ static void smartcard_channel_hold_pipe_item(PipeItem *item) { } -static void smartcard_link(Channel *channel, RedsStreamContext *peer, +static void smartcard_link(Channel *channel, RedsStream *peer, int migration, int num_common_caps, uint32_t *common_caps, int num_caps, uint32_t *caps) diff --git a/server/snd_worker.c b/server/snd_worker.c index 6c0f9d6..2cd4d92 100644 --- a/server/snd_worker.c +++ b/server/snd_worker.c @@ -73,7 +73,7 @@ typedef void (*cleanup_channel_proc)(SndChannel *channel); typedef struct SndWorker SndWorker; struct SndChannel { - RedsStreamContext *peer; + RedsStream *peer; SndWorker *worker; spice_parse_channel_func_t parser; @@ -734,7 +734,7 @@ static void snd_record_send(void* data) } static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_id, - RedsStreamContext *peer, + RedsStream *peer, int migrate, send_messages_proc send_messages, handle_message_proc handle_message, on_message_done_proc on_message_done, @@ -931,7 +931,7 @@ static void snd_playback_cleanup(SndChannel *channel) celt051_mode_destroy(playback_channel->celt_mode); } -static void snd_set_playback_peer(Channel *channel, RedsStreamContext *peer, int migration, +static void snd_set_playback_peer(Channel *channel, RedsStream *peer, int migration, int num_common_caps, uint32_t *common_caps, int num_caps, uint32_t *caps) { @@ -1097,7 +1097,7 @@ static void snd_record_cleanup(SndChannel *channel) celt051_mode_destroy(record_channel->celt_mode); } -static void snd_set_record_peer(Channel *channel, RedsStreamContext *peer, int migration, +static void snd_set_record_peer(Channel *channel, RedsStream *peer, int migration, int num_common_caps, uint32_t *common_caps, int num_caps, uint32_t *caps) { -- 1.7.4