[Spice-devel] [PATCH 04/13] server: rename s/peer/stream
Alon Levy
alevy at redhat.com
Thu Feb 24 08:43:46 PST 2011
On Tue, Feb 22, 2011 at 05:08:58PM +0100, Marc-André Lureau wrote:
> This is stylish change again. We are talking about a RedStream object,
> so let's just name the variable "stream" everywhere, to avoid
> confusion with a non existent RedPeer object.
ACK reluctantely (since I'll have to update all my patches again.. oh well)
> ---
> server/inputs_channel.c | 10 ++--
> server/main_channel.c | 12 ++--
> server/red_channel.c | 48 +++++++-------
> server/red_channel.h | 6 +-
> server/red_dispatcher.c | 8 +-
> server/red_tunnel_worker.c | 12 ++--
> server/red_worker.c | 56 +++++++++---------
> server/reds.c | 146 ++++++++++++++++++++++----------------------
> server/reds.h | 2 +-
> server/smartcard.c | 4 +-
> server/snd_worker.c | 44 +++++++-------
> 11 files changed, 174 insertions(+), 174 deletions(-)
>
> diff --git a/server/inputs_channel.c b/server/inputs_channel.c
> index 0781e62..e2a6e2d 100644
> --- a/server/inputs_channel.c
> +++ b/server/inputs_channel.c
> @@ -494,21 +494,21 @@ static int inputs_channel_config_socket(RedChannel *channel)
> int flags;
> int delay_val = 1;
>
> - if (setsockopt(channel->peer->socket, IPPROTO_TCP, TCP_NODELAY,
> + if (setsockopt(channel->stream->socket, IPPROTO_TCP, TCP_NODELAY,
> &delay_val, sizeof(delay_val)) == -1) {
> red_printf("setsockopt failed, %s", strerror(errno));
> return FALSE;
> }
>
> - if ((flags = fcntl(channel->peer->socket, F_GETFL)) == -1 ||
> - fcntl(channel->peer->socket, F_SETFL, flags | O_ASYNC) == -1) {
> + if ((flags = fcntl(channel->stream->socket, F_GETFL)) == -1 ||
> + fcntl(channel->stream->socket, F_SETFL, flags | O_ASYNC) == -1) {
> red_printf("fcntl failed, %s", strerror(errno));
> return FALSE;
> }
> return TRUE;
> }
>
> -static void inputs_link(Channel *channel, RedsStream *peer, int migration,
> +static void inputs_link(Channel *channel, RedsStream *stream, int migration,
> int num_common_caps, uint32_t *common_caps, int num_caps,
> uint32_t *caps)
> {
> @@ -517,7 +517,7 @@ static void inputs_link(Channel *channel, RedsStream *peer, int migration,
> ASSERT(channel->data == NULL);
>
> g_inputs_channel = inputs_channel = (InputsChannel*)red_channel_create_parser(
> - sizeof(*inputs_channel), peer, core, migration, FALSE /* handle_acks */
> + sizeof(*inputs_channel), stream, core, migration, FALSE /* handle_acks */
> ,inputs_channel_config_socket
> ,spice_get_client_channel_parser(SPICE_CHANNEL_INPUTS, NULL)
> ,inputs_channel_handle_parsed
> diff --git a/server/main_channel.c b/server/main_channel.c
> index ec234dd..9dfc471 100644
> --- a/server/main_channel.c
> +++ b/server/main_channel.c
> @@ -776,7 +776,7 @@ static int main_channel_config_socket(RedChannel *channel)
> return TRUE;
> }
>
> -static void main_channel_link(Channel *channel, RedsStream *peer, int migration,
> +static void main_channel_link(Channel *channel, RedsStream *stream, int migration,
> int num_common_caps, uint32_t *common_caps, int num_caps,
> uint32_t *caps)
> {
> @@ -785,7 +785,7 @@ static void main_channel_link(Channel *channel, RedsStream *peer, int migration,
> ASSERT(channel->data == NULL);
>
> main_chan = (MainChannel*)red_channel_create_parser(
> - sizeof(*main_chan), peer, core, migration, FALSE /* handle_acks */
> + sizeof(*main_chan), stream, core, migration, FALSE /* handle_acks */
> ,main_channel_config_socket
> ,spice_get_client_channel_parser(SPICE_CHANNEL_MAIN, NULL)
> ,main_channel_handle_parsed
> @@ -803,22 +803,22 @@ int main_channel_getsockname(Channel *channel, struct sockaddr *sa, socklen_t *s
> {
> MainChannel *main_chan = channel->data;
>
> - return main_chan ? getsockname(main_chan->base.peer->socket, sa, salen) : -1;
> + return main_chan ? getsockname(main_chan->base.stream->socket, sa, salen) : -1;
> }
>
> int main_channel_getpeername(Channel *channel, struct sockaddr *sa, socklen_t *salen)
> {
> MainChannel *main_chan = channel->data;
>
> - return main_chan ? getpeername(main_chan->base.peer->socket, sa, salen) : -1;
> + return main_chan ? getpeername(main_chan->base.stream->socket, sa, salen) : -1;
> }
>
> void main_channel_close(Channel *channel)
> {
> MainChannel *main_chan = channel->data;
>
> - if (main_chan && main_chan->base.peer) {
> - close(main_chan->base.peer->socket);
> + if (main_chan && main_chan->base.stream) {
> + close(main_chan->base.stream->socket);
> }
> }
>
> diff --git a/server/red_channel.c b/server/red_channel.c
> index 36e9f68..f25a61f 100644
> --- a/server/red_channel.c
> +++ b/server/red_channel.c
> @@ -34,15 +34,15 @@ static void red_channel_pipe_clear(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(RedsStream *peer, uint8_t *buf, uint32_t size)
> +static int red_peer_receive(RedsStream *stream, uint8_t *buf, uint32_t size)
> {
> uint8_t *pos = buf;
> while (size) {
> int now;
> - if (peer->shutdown) {
> + if (stream->shutdown) {
> return -1;
> }
> - now = reds_stream_read(peer, pos, size);
> + now = reds_stream_read(stream, pos, size);
> if (now <= 0) {
> if (now == 0) {
> return -1;
> @@ -66,7 +66,7 @@ static int red_peer_receive(RedsStream *peer, uint8_t *buf, uint32_t size)
> return pos - buf;
> }
>
> -static void red_peer_handle_incoming(RedsStream *peer, IncomingHandler *handler)
> +static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handler)
> {
> int bytes_read;
> uint8_t *parsed;
> @@ -76,7 +76,7 @@ static void red_peer_handle_incoming(RedsStream *peer, IncomingHandler *handler)
> for (;;) {
> int ret_handle;
> if (handler->header_pos < sizeof(SpiceDataHeader)) {
> - bytes_read = red_peer_receive(peer,
> + bytes_read = red_peer_receive(stream,
> ((uint8_t *)&handler->header) + handler->header_pos,
> sizeof(SpiceDataHeader) - handler->header_pos);
> if (bytes_read == -1) {
> @@ -100,7 +100,7 @@ static void red_peer_handle_incoming(RedsStream *peer, IncomingHandler *handler)
> }
> }
>
> - bytes_read = red_peer_receive(peer,
> + bytes_read = red_peer_receive(stream,
> handler->msg + handler->msg_pos,
> handler->header.size - handler->msg_pos);
> if (bytes_read == -1) {
> @@ -144,7 +144,7 @@ static void red_peer_handle_incoming(RedsStream *peer, IncomingHandler *handler)
> }
> }
>
> -static void red_peer_handle_outgoing(RedsStream *peer, OutgoingHandler *handler)
> +static void red_peer_handle_outgoing(RedsStream *stream, OutgoingHandler *handler)
> {
> ssize_t n;
>
> @@ -158,7 +158,7 @@ static void red_peer_handle_outgoing(RedsStream *peer, OutgoingHandler *handler)
>
> for (;;) {
> handler->prepare(handler->opaque, handler->vec, &handler->vec_size, handler->pos);
> - n = reds_stream_writev(peer, handler->vec, handler->vec_size);
> + n = reds_stream_writev(stream, handler->vec, handler->vec_size);
> if (n == -1) {
> switch (errno) {
> case EAGAIN:
> @@ -227,7 +227,7 @@ static void red_channel_peer_on_out_block(void *opaque)
> {
> RedChannel *channel = (RedChannel *)opaque;
> channel->send_data.blocked = TRUE;
> - channel->core->watch_update_mask(channel->peer->watch,
> + channel->core->watch_update_mask(channel->stream->watch,
> SPICE_WATCH_EVENT_READ |
> SPICE_WATCH_EVENT_WRITE);
> }
> @@ -242,12 +242,12 @@ static void red_channel_peer_on_out_msg_done(void *opaque)
> }
> if (channel->send_data.blocked) {
> channel->send_data.blocked = FALSE;
> - channel->core->watch_update_mask(channel->peer->watch,
> + channel->core->watch_update_mask(channel->stream->watch,
> SPICE_WATCH_EVENT_READ);
> }
> }
>
> -RedChannel *red_channel_create(int size, RedsStream *peer,
> +RedChannel *red_channel_create(int size, RedsStream *stream,
> SpiceCoreInterface *core,
> int migrate, int handle_acks,
> channel_configure_socket_proc config_socket,
> @@ -270,7 +270,7 @@ RedChannel *red_channel_create(int size, RedsStream *peer,
> channel->send_item = send_item;
> channel->release_item = release_item;
>
> - channel->peer = peer;
> + channel->stream = stream;
> channel->core = core;
> channel->ack_data.messages_window = ~0; // blocks send message (maybe use send_data.blocked +
> // block flags)
> @@ -302,7 +302,7 @@ RedChannel *red_channel_create(int size, RedsStream *peer,
> goto error;
> }
>
> - channel->peer->watch = channel->core->watch_add(channel->peer->socket,
> + channel->stream->watch = channel->core->watch_add(channel->stream->socket,
> SPICE_WATCH_EVENT_READ,
> red_channel_event, channel);
>
> @@ -311,7 +311,7 @@ RedChannel *red_channel_create(int size, RedsStream *peer,
> error:
> spice_marshaller_destroy(channel->send_data.marshaller);
> free(channel);
> - reds_stream_free(peer);
> + reds_stream_free(stream);
>
> return NULL;
> }
> @@ -325,7 +325,7 @@ int do_nothing_handle_message(RedChannel *red_channel, SpiceDataHeader *header,
> return TRUE;
> }
>
> -RedChannel *red_channel_create_parser(int size, RedsStream *peer,
> +RedChannel *red_channel_create_parser(int size, RedsStream *stream,
> SpiceCoreInterface *core,
> int migrate, int handle_acks,
> channel_configure_socket_proc config_socket,
> @@ -338,7 +338,7 @@ RedChannel *red_channel_create_parser(int size, RedsStream *peer,
> channel_on_incoming_error_proc incoming_error,
> channel_on_outgoing_error_proc outgoing_error)
> {
> - RedChannel *channel = red_channel_create(size, peer,
> + RedChannel *channel = red_channel_create(size, stream,
> core, migrate, handle_acks, config_socket, do_nothing_disconnect, do_nothing_handle_message,
> alloc_recv_buf, release_recv_buf, send_item, release_item);
>
> @@ -360,7 +360,7 @@ void red_channel_destroy(RedChannel *channel)
> return;
> }
> red_channel_pipe_clear(channel);
> - reds_stream_free(channel->peer);
> + reds_stream_free(channel->stream);
> spice_marshaller_destroy(channel->send_data.marshaller);
> free(channel);
> }
> @@ -368,12 +368,12 @@ void red_channel_destroy(RedChannel *channel)
> void red_channel_shutdown(RedChannel *channel)
> {
> red_printf("");
> - if (channel->peer && !channel->peer->shutdown) {
> - channel->core->watch_update_mask(channel->peer->watch,
> + if (channel->stream && !channel->stream->shutdown) {
> + channel->core->watch_update_mask(channel->stream->watch,
> SPICE_WATCH_EVENT_READ);
> red_channel_pipe_clear(channel);
> - shutdown(channel->peer->socket, SHUT_RDWR);
> - channel->peer->shutdown = TRUE;
> + shutdown(channel->stream->socket, SHUT_RDWR);
> + channel->stream->shutdown = TRUE;
> }
> }
>
> @@ -411,7 +411,7 @@ static void red_channel_event(int fd, int event, void *data)
> RedChannel *channel = (RedChannel *)data;
>
> if (event & SPICE_WATCH_EVENT_READ) {
> - red_peer_handle_incoming(channel->peer, &channel->incoming);
> + red_peer_handle_incoming(channel->stream, &channel->incoming);
> }
> if (event & SPICE_WATCH_EVENT_WRITE) {
> red_channel_push(channel);
> @@ -444,7 +444,7 @@ void red_channel_init_send_data(RedChannel *channel, uint16_t msg_type, PipeItem
>
> static void red_channel_send(RedChannel *channel)
> {
> - red_peer_handle_outgoing(channel->peer, &channel->outgoing);
> + red_peer_handle_outgoing(channel->stream, &channel->outgoing);
> }
>
> void red_channel_begin_send_message(RedChannel *channel)
> @@ -548,7 +548,7 @@ static PipeItem *red_channel_pipe_get(RedChannel *channel)
>
> int red_channel_is_connected(RedChannel *channel)
> {
> - return !!channel->peer;
> + return !!channel->stream;
> }
>
> static void red_channel_pipe_clear(RedChannel *channel)
> diff --git a/server/red_channel.h b/server/red_channel.h
> index ae58522..fb5fb6e 100644
> --- a/server/red_channel.h
> +++ b/server/red_channel.h
> @@ -110,7 +110,7 @@ typedef void (*channel_on_incoming_error_proc)(RedChannel *channel);
> typedef void (*channel_on_outgoing_error_proc)(RedChannel *channel);
>
> struct RedChannel {
> - RedsStream *peer;
> + RedsStream *stream;
> SpiceCoreInterface *core;
> int migrate;
> int handle_acks;
> @@ -154,7 +154,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, RedsStream *peer,
> +RedChannel *red_channel_create(int size, RedsStream *stream,
> SpiceCoreInterface *core,
> int migrate, int handle_acks,
> channel_configure_socket_proc config_socket,
> @@ -167,7 +167,7 @@ RedChannel *red_channel_create(int size, RedsStream *peer,
>
> /* alternative constructor, meant for marshaller based (inputs,main) channels,
> * will become default eventually */
> -RedChannel *red_channel_create_parser(int size, RedsStream *peer,
> +RedChannel *red_channel_create_parser(int size, RedsStream *stream,
> 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 3816e14..75e0670 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, RedsStream *peer, int migration,
> +static void red_dispatcher_set_peer(Channel *channel, RedsStream *stream, 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, RedsStream *peer, int migr
> dispatcher = (RedDispatcher *)channel->data;
> RedWorkerMessage message = RED_WORKER_MESSAGE_DISPLAY_CONNECT;
> write_message(dispatcher->channel, &message);
> - send_data(dispatcher->channel, &peer, sizeof(RedsStream *));
> + send_data(dispatcher->channel, &stream, 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, RedsStream *peer,
> +static void red_dispatcher_set_cursor_peer(Channel *channel, RedsStream *stream,
> 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, RedsStream *peer,
> red_printf("");
> RedWorkerMessage message = RED_WORKER_MESSAGE_CURSOR_CONNECT;
> write_message(dispatcher->channel, &message);
> - send_data(dispatcher->channel, &peer, sizeof(RedsStream *));
> + send_data(dispatcher->channel, &stream, sizeof(RedsStream *));
> send_data(dispatcher->channel, &migration, sizeof(int));
> }
>
> diff --git a/server/red_tunnel_worker.c b/server/red_tunnel_worker.c
> index 267de4a..4793f62 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, RedsStream *peer, int migration,
> +static void handle_tunnel_channel_link(Channel *channel, RedsStream *stream, 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);
> @@ -3347,19 +3347,19 @@ static int tunnel_channel_config_socket(RedChannel *channel)
> int flags;
> int delay_val;
>
> - if ((flags = fcntl(channel->peer->socket, F_GETFL)) == -1) {
> + if ((flags = fcntl(channel->stream->socket, F_GETFL)) == -1) {
> red_printf("accept failed, %s", strerror(errno)); // can't we just use red_error?
> return FALSE;
> }
>
> - if (fcntl(channel->peer->socket, F_SETFL, flags | O_NONBLOCK) == -1) {
> + if (fcntl(channel->stream->socket, F_SETFL, flags | O_NONBLOCK) == -1) {
> red_printf("accept failed, %s", strerror(errno));
> return FALSE;
> }
>
> delay_val = 1;
>
> - if (setsockopt(channel->peer->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val,
> + if (setsockopt(channel->stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val,
> sizeof(delay_val)) == -1) {
> red_printf("setsockopt failed, %s", strerror(errno));
> }
> @@ -3420,7 +3420,7 @@ static void on_new_tunnel_channel(TunnelChannel *channel)
> }
> }
>
> -static void handle_tunnel_channel_link(Channel *channel, RedsStream *peer, int migration,
> +static void handle_tunnel_channel_link(Channel *channel, RedsStream *stream, int migration,
> int num_common_caps, uint32_t *common_caps, int num_caps,
> uint32_t *caps)
> {
> @@ -3431,7 +3431,7 @@ static void handle_tunnel_channel_link(Channel *channel, RedsStream *peer, int m
> }
>
> tunnel_channel =
> - (TunnelChannel *)red_channel_create(sizeof(*tunnel_channel), peer, worker->core_interface,
> + (TunnelChannel *)red_channel_create(sizeof(*tunnel_channel), stream, worker->core_interface,
> migration, TRUE,
> tunnel_channel_config_socket,
> tunnel_channel_disconnect,
> diff --git a/server/red_worker.c b/server/red_worker.c
> index 446fae4..0afff6f 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -356,7 +356,7 @@ struct RedChannel {
> uint32_t id;
> spice_parse_channel_func_t parser;
> struct RedWorker *worker;
> - RedsStream *peer;
> + RedsStream *stream;
> int migrate;
>
> Ring pipe;
> @@ -7338,8 +7338,8 @@ static void red_send_data(RedChannel *channel, void *item)
> }
> vec_size = spice_marshaller_fill_iovec(channel->send_data.marshaller,
> vec, MAX_SEND_VEC, channel->send_data.pos);
> - ASSERT(channel->peer);
> - n = reds_stream_writev(channel->peer, vec, vec_size);
> + ASSERT(channel->stream);
> + n = reds_stream_writev(channel->stream, vec, vec_size);
> if (n == -1) {
> switch (errno) {
> case EAGAIN:
> @@ -8518,15 +8518,15 @@ void red_show_tree(RedWorker *worker)
>
> static inline int channel_is_connected(RedChannel *channel)
> {
> - return !!channel->peer;
> + return !!channel->stream;
> }
>
> static void red_disconnect_channel(RedChannel *channel)
> {
> channel_release_res(channel);
> red_pipe_clear(channel);
> - reds_stream_free(channel->peer);
> - channel->peer = NULL;
> + reds_stream_free(channel->stream);
> + channel->stream = NULL;
> channel->send_data.blocked = FALSE;
> channel->send_data.size = channel->send_data.pos = 0;
> spice_marshaller_reset(channel->send_data.marshaller);
> @@ -8537,7 +8537,7 @@ static void red_disconnect_display(RedChannel *channel)
> {
> DisplayChannel *display_channel;
>
> - if (!channel || !channel->peer) {
> + if (!channel || !channel->stream) {
> return;
> }
>
> @@ -8869,7 +8869,7 @@ static int display_channel_wait_for_init(DisplayChannel *display_channel)
> uint64_t end_time = red_now() + DISPLAY_CLIENT_TIMEOUT;
> for (;;) {
> red_receive((RedChannel *)display_channel);
> - if (!display_channel->base.peer) {
> + if (!display_channel->base.stream) {
> break;
> }
> if (display_channel->pixmap_cache && display_channel->glz_dict) {
> @@ -9251,8 +9251,8 @@ static void red_receive(RedChannel *channel)
> ssize_t n;
> n = channel->recive_data.end - channel->recive_data.now;
> ASSERT(n);
> - ASSERT(channel->peer);
> - n = reds_stream_read(channel->peer, channel->recive_data.now, n);
> + ASSERT(channel->stream);
> + n = reds_stream_read(channel->stream, channel->recive_data.now, n);
> if (n <= 0) {
> if (n == 0) {
> channel->disconnect(channel);
> @@ -9319,7 +9319,7 @@ static void red_receive(RedChannel *channel)
> }
>
> static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_id,
> - RedsStream *peer, int migrate,
> + RedsStream *stream, int migrate,
> event_listener_action_proc handler,
> disconnect_channel_proc disconnect,
> hold_item_proc hold_item,
> @@ -9331,18 +9331,18 @@ static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_i
> int flags;
> int delay_val;
>
> - if ((flags = fcntl(peer->socket, F_GETFL)) == -1) {
> + if ((flags = fcntl(stream->socket, F_GETFL)) == -1) {
> red_printf("accept failed, %s", strerror(errno));
> goto error1;
> }
>
> - if (fcntl(peer->socket, F_SETFL, flags | O_NONBLOCK) == -1) {
> + if (fcntl(stream->socket, F_SETFL, flags | O_NONBLOCK) == -1) {
> red_printf("accept failed, %s", strerror(errno));
> goto error1;
> }
>
> delay_val = IS_LOW_BANDWIDTH() ? 0 : 1;
> - if (setsockopt(peer->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val, sizeof(delay_val)) == -1) {
> + if (setsockopt(stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val, sizeof(delay_val)) == -1) {
> red_printf("setsockopt failed, %s", strerror(errno));
> }
>
> @@ -9356,7 +9356,7 @@ static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_i
> channel->hold_item = hold_item;
> channel->release_item = release_item;
> channel->handle_message = handle_message;
> - channel->peer = peer;
> + channel->stream = stream;
> channel->worker = worker;
> channel->messages_window = ~0; // blocks send message (maybe use send_data.blocked +
> // block flags)
> @@ -9371,7 +9371,7 @@ static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_i
>
> event.events = EPOLLIN | EPOLLOUT | EPOLLET;
> event.data.ptr = channel;
> - if (epoll_ctl(worker->epoll, EPOLL_CTL_ADD, peer->socket, &event) == -1) {
> + if (epoll_ctl(worker->epoll, EPOLL_CTL_ADD, stream->socket, &event) == -1) {
> red_printf("epoll_ctl failed, %s", strerror(errno));
> goto error2;
> }
> @@ -9383,7 +9383,7 @@ static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_i
> error2:
> free(channel);
> error1:
> - reds_stream_free(peer);
> + reds_stream_free(stream);
>
> return NULL;
> }
> @@ -9445,7 +9445,7 @@ static void display_channel_release_item(RedChannel *channel, void *item)
> }
> }
>
> -static void handle_new_display_channel(RedWorker *worker, RedsStream *peer, int migrate)
> +static void handle_new_display_channel(RedWorker *worker, RedsStream *stream, int migrate)
> {
> DisplayChannel *display_channel;
> size_t stream_buf_size;
> @@ -9453,7 +9453,7 @@ static void handle_new_display_channel(RedWorker *worker, RedsStream *peer, int
> red_disconnect_display((RedChannel *)worker->display_channel);
>
> if (!(display_channel = (DisplayChannel *)__new_channel(worker, sizeof(*display_channel),
> - SPICE_CHANNEL_DISPLAY, peer,
> + SPICE_CHANNEL_DISPLAY, stream,
> migrate, handle_channel_events,
> red_disconnect_display,
> display_channel_hold_item,
> @@ -9525,7 +9525,7 @@ static void handle_new_display_channel(RedWorker *worker, RedsStream *peer, int
>
> static void red_disconnect_cursor(RedChannel *channel)
> {
> - if (!channel || !channel->peer) {
> + if (!channel || !channel->stream) {
> return;
> }
>
> @@ -9568,14 +9568,14 @@ static void cursor_channel_release_item(RedChannel *channel, void *item)
> red_release_cursor(channel->worker, item);
> }
>
> -static void red_connect_cursor(RedWorker *worker, RedsStream *peer, int migrate)
> +static void red_connect_cursor(RedWorker *worker, RedsStream *stream, int migrate)
> {
> CursorChannel *channel;
>
> red_disconnect_cursor((RedChannel *)worker->cursor_channel);
>
> if (!(channel = (CursorChannel *)__new_channel(worker, sizeof(*channel),
> - SPICE_CHANNEL_CURSOR, peer, migrate,
> + SPICE_CHANNEL_CURSOR, stream, migrate,
> handle_channel_events,
> red_disconnect_cursor,
> cursor_channel_hold_item,
> @@ -10004,13 +10004,13 @@ static void handle_dev_input(EventListener *listener, uint32_t events)
> handle_dev_destroy_primary_surface(worker);
> break;
> case RED_WORKER_MESSAGE_DISPLAY_CONNECT: {
> - RedsStream *peer;
> + RedsStream *stream;
> int migrate;
> red_printf("connect");
>
> - receive_data(worker->channel, &peer, sizeof(RedsStream *));
> + receive_data(worker->channel, &stream, sizeof(RedsStream *));
> receive_data(worker->channel, &migrate, sizeof(int));
> - handle_new_display_channel(worker, peer, migrate);
> + handle_new_display_channel(worker, stream, migrate);
> break;
> }
> case RED_WORKER_MESSAGE_DISPLAY_DISCONNECT:
> @@ -10052,13 +10052,13 @@ static void handle_dev_input(EventListener *listener, uint32_t events)
> red_migrate_display(worker);
> break;
> case RED_WORKER_MESSAGE_CURSOR_CONNECT: {
> - RedsStream *peer;
> + RedsStream *stream;
> int migrate;
>
> red_printf("cursor connect");
> - receive_data(worker->channel, &peer, sizeof(RedsStream *));
> + receive_data(worker->channel, &stream, sizeof(RedsStream *));
> receive_data(worker->channel, &migrate, sizeof(int));
> - red_connect_cursor(worker, peer, migrate);
> + red_connect_cursor(worker, stream, migrate);
> break;
> }
> case RED_WORKER_MESSAGE_CURSOR_DISCONNECT:
> diff --git a/server/reds.c b/server/reds.c
> index a2bc3b4..45e4964 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -224,7 +224,7 @@ typedef struct RedsState {
> static RedsState *reds = NULL;
>
> typedef struct AsyncRead {
> - RedsStream *peer;
> + RedsStream *stream;
> void *opaque;
> uint8_t *now;
> uint8_t *end;
> @@ -233,7 +233,7 @@ typedef struct AsyncRead {
> } AsyncRead;
>
> typedef struct RedLinkInfo {
> - RedsStream *peer;
> + RedsStream *stream;
> AsyncRead asyc_read;
> SpiceLinkHeader link_header;
> SpiceLinkMess *link_mess;
> @@ -297,11 +297,11 @@ static ChannelSecurityOptions *find_channel_security(int id)
> return now;
> }
>
> -static void reds_channel_event(RedsStream *peer, int event)
> +static void spice_channel_event(SpiceChannelEventInfo *info, int event)
> {
> if (core->base.minor_version < 3 || core->channel_event == NULL)
> return;
> - core->channel_event(event, &peer->info);
> + core->channel_event(event, info);
> }
>
> static ssize_t stream_write_cb(RedsStream *s, const void *buf, size_t size)
> @@ -379,8 +379,8 @@ static void reds_stream_remove_watch(RedsStream* s)
>
> static void reds_link_free(RedLinkInfo *link)
> {
> - reds_stream_free(link->peer);
> - link->peer = NULL;
> + reds_stream_free(link->stream);
> + link->stream = NULL;
>
> free(link->link_mess);
> link->link_mess = NULL;
> @@ -1404,12 +1404,12 @@ static int reds_send_link_ack(RedLinkInfo *link)
> BIO_get_mem_ptr(bio, &bmBuf);
> memcpy(ack.pub_key, bmBuf->data, sizeof(ack.pub_key));
>
> - ret = sync_write(link->peer, &header, sizeof(header)) && sync_write(link->peer, &ack,
> + ret = sync_write(link->stream, &header, sizeof(header)) && sync_write(link->stream, &ack,
> sizeof(ack));
> if (channel) {
> - ret = ret && sync_write(link->peer, channel->common_caps,
> + ret = ret && sync_write(link->stream, channel->common_caps,
> channel->num_common_caps * sizeof(uint32_t)) &&
> - sync_write(link->peer, channel->caps, channel->num_caps * sizeof(uint32_t));
> + sync_write(link->stream, channel->caps, channel->num_caps * sizeof(uint32_t));
> }
> BIO_free(bio);
> return ret;
> @@ -1426,7 +1426,7 @@ static int reds_send_link_error(RedLinkInfo *link, uint32_t error)
> header.minor_version = SPICE_VERSION_MINOR;
> memset(&reply, 0, sizeof(reply));
> reply.error = error;
> - return sync_write(link->peer, &header, sizeof(header)) && sync_write(link->peer, &reply,
> + return sync_write(link->stream, &header, sizeof(header)) && sync_write(link->stream, &reply,
> sizeof(reply));
> }
>
> @@ -1435,27 +1435,27 @@ static void reds_show_new_channel(RedLinkInfo *link, int connection_id)
> red_printf("channel %d:%d, connected successfully, over %s link",
> link->link_mess->channel_type,
> link->link_mess->channel_id,
> - link->peer->ssl == NULL ? "Non Secure" : "Secure");
> + link->stream->ssl == NULL ? "Non Secure" : "Secure");
> /* add info + send event */
> - if (link->peer->ssl) {
> - link->peer->info.flags |= SPICE_CHANNEL_EVENT_FLAG_TLS;
> + if (link->stream->ssl) {
> + link->stream->info.flags |= SPICE_CHANNEL_EVENT_FLAG_TLS;
> }
> - link->peer->info.connection_id = connection_id;
> - link->peer->info.type = link->link_mess->channel_type;
> - link->peer->info.id = link->link_mess->channel_id;
> - reds_channel_event(link->peer, SPICE_CHANNEL_EVENT_INITIALIZED);
> + 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;
> + spice_channel_event(&link->stream->info, SPICE_CHANNEL_EVENT_INITIALIZED);
> }
>
> static void reds_send_link_result(RedLinkInfo *link, uint32_t error)
> {
> - sync_write(link->peer, &error, sizeof(error));
> + sync_write(link->stream, &error, sizeof(error));
> }
>
> // TODO: now that main is a separate channel this should
> // actually be joined with reds_handle_other_links, ebcome reds_handle_link
> static void reds_handle_main_link(RedLinkInfo *link)
> {
> - RedsStream *peer;
> + RedsStream *stream;
> SpiceLinkMess *link_mess;
> uint32_t *caps;
> uint32_t connection_id;
> @@ -1487,14 +1487,14 @@ static void reds_handle_main_link(RedLinkInfo *link)
> reds->mig_wait_disconnect = FALSE;
>
> reds_show_new_channel(link, connection_id);
> - peer = link->peer;
> - reds_stream_remove_watch(peer);
> - link->peer = NULL;
> + stream = link->stream;
> + reds_stream_remove_watch(stream);
> + link->stream = NULL;
> link->link_mess = NULL;
> reds_link_free(link);
> caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset);
> reds->main_channel = main_channel_init();
> - reds->main_channel->link(reds->main_channel, peer, reds->mig_target, link_mess->num_common_caps,
> + reds->main_channel->link(reds->main_channel, stream, reds->mig_target, link_mess->num_common_caps,
> link_mess->num_common_caps ? caps : NULL, link_mess->num_channel_caps,
> link_mess->num_channel_caps ? caps + link_mess->num_common_caps : NULL);
> free(link_mess);
> @@ -1558,7 +1558,7 @@ static void openssl_init(RedLinkInfo *link)
> static void reds_handle_other_links(RedLinkInfo *link)
> {
> Channel *channel;
> - RedsStream *peer;
> + RedsStream *stream;
> SpiceLinkMess *link_mess;
> uint32_t *caps;
>
> @@ -1579,18 +1579,18 @@ static void reds_handle_other_links(RedLinkInfo *link)
>
> reds_send_link_result(link, SPICE_LINK_ERR_OK);
> reds_show_new_channel(link, reds->link_id);
> - if (link_mess->channel_type == SPICE_CHANNEL_INPUTS && !link->peer->ssl) {
> + if (link_mess->channel_type == SPICE_CHANNEL_INPUTS && !link->stream->ssl) {
> char *mess = "keyboard channel is insecure";
> const int mess_len = strlen(mess);
> main_channel_push_notify(reds->main_channel, (uint8_t*)mess, mess_len);
> }
> - peer = link->peer;
> - reds_stream_remove_watch(peer);
> - link->peer = NULL;
> + stream = link->stream;
> + reds_stream_remove_watch(stream);
> + link->stream = NULL;
> link->link_mess = NULL;
> reds_link_free(link);
> caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset);
> - channel->link(channel, peer, reds->mig_target, link_mess->num_common_caps,
> + channel->link(channel, stream, reds->mig_target, link_mess->num_common_caps,
> link_mess->num_common_caps ? caps : NULL, link_mess->num_channel_caps,
> link_mess->num_channel_caps ? caps + link_mess->num_common_caps : NULL);
> free(link_mess);
> @@ -1635,11 +1635,11 @@ static void reds_handle_ticket(void *opaque)
>
> static inline void async_read_clear_handlers(AsyncRead *obj)
> {
> - if (!obj->peer->watch) {
> + if (!obj->stream->watch) {
> return;
> }
> - core->watch_remove(obj->peer->watch);
> - obj->peer->watch = NULL;
> + core->watch_remove(obj->stream->watch);
> + obj->stream->watch = NULL;
> }
>
> static void async_read_handler(int fd, int event, void *data)
> @@ -1650,13 +1650,13 @@ static void async_read_handler(int fd, int event, void *data)
> int n = obj->end - obj->now;
>
> ASSERT(n > 0);
> - n = reds_stream_read(obj->peer, obj->now, n);
> + n = reds_stream_read(obj->stream, obj->now, n);
> if (n <= 0) {
> if (n < 0) {
> switch (errno) {
> case EAGAIN:
> - if (!obj->peer->watch) {
> - obj->peer->watch = core->watch_add(obj->peer->socket,
> + if (!obj->stream->watch) {
> + obj->stream->watch = core->watch_add(obj->stream->socket,
> SPICE_WATCH_EVENT_READ,
> async_read_handler, obj);
> }
> @@ -1688,8 +1688,8 @@ static int reds_security_check(RedLinkInfo *link)
> {
> ChannelSecurityOptions *security_option = find_channel_security(link->link_mess->channel_type);
> uint32_t security = security_option ? security_option->options : default_channel_security;
> - return (link->peer->ssl && (security & SPICE_CHANNEL_SECURITY_SSL)) ||
> - (!link->peer->ssl && (security & SPICE_CHANNEL_SECURITY_NONE));
> + return (link->stream->ssl && (security & SPICE_CHANNEL_SECURITY_SSL)) ||
> + (!link->stream->ssl && (security & SPICE_CHANNEL_SECURITY_NONE));
> }
>
> static void reds_handle_read_link_done(void *opaque)
> @@ -1708,7 +1708,7 @@ static void reds_handle_read_link_done(void *opaque)
> }
>
> if (!reds_security_check(link)) {
> - if (link->peer->ssl) {
> + if (link->stream->ssl) {
> red_printf("spice channels %d should not be encrypted", link_mess->channel_type);
> reds_send_link_error(link, SPICE_LINK_ERR_NEED_UNSECURED);
> } else {
> @@ -1787,7 +1787,7 @@ static void reds_handle_new_link(RedLinkInfo *link)
> {
> AsyncRead *obj = &link->asyc_read;
> obj->opaque = link;
> - obj->peer = link->peer;
> + obj->stream = link->stream;
> obj->now = (uint8_t *)&link->link_header;
> obj->end = (uint8_t *)((SpiceLinkHeader *)&link->link_header + 1);
> obj->done = reds_handle_read_header_done;
> @@ -1800,29 +1800,29 @@ static void reds_handle_ssl_accept(int fd, int event, void *data)
> RedLinkInfo *link = (RedLinkInfo *)data;
> int return_code;
>
> - if ((return_code = SSL_accept(link->peer->ssl)) != 1) {
> - int ssl_error = SSL_get_error(link->peer->ssl, return_code);
> + if ((return_code = SSL_accept(link->stream->ssl)) != 1) {
> + int ssl_error = SSL_get_error(link->stream->ssl, return_code);
> if (ssl_error != SSL_ERROR_WANT_READ && ssl_error != SSL_ERROR_WANT_WRITE) {
> red_printf("SSL_accept failed, error=%d", ssl_error);
> reds_link_free(link);
> } else {
> if (ssl_error == SSL_ERROR_WANT_READ) {
> - core->watch_update_mask(link->peer->watch, SPICE_WATCH_EVENT_READ);
> + core->watch_update_mask(link->stream->watch, SPICE_WATCH_EVENT_READ);
> } else {
> - core->watch_update_mask(link->peer->watch, SPICE_WATCH_EVENT_WRITE);
> + core->watch_update_mask(link->stream->watch, SPICE_WATCH_EVENT_WRITE);
> }
> }
> return;
> }
> - core->watch_remove(link->peer->watch);
> - link->peer->watch = NULL;
> + core->watch_remove(link->stream->watch);
> + link->stream->watch = NULL;
> reds_handle_new_link(link);
> }
>
> static RedLinkInfo *__reds_accept_connection(int listen_socket)
> {
> RedLinkInfo *link;
> - RedsStream *peer;
> + RedsStream *stream;
> int delay_val = 1;
> int flags;
> int socket;
> @@ -1847,16 +1847,16 @@ static RedLinkInfo *__reds_accept_connection(int listen_socket)
> }
>
> link = spice_new0(RedLinkInfo, 1);
> - peer = spice_new0(RedsStream, 1);
> - link->peer = peer;
> - peer->socket = socket;
> + stream = spice_new0(RedsStream, 1);
> + link->stream = stream;
>
> + stream->socket = socket;
> /* gather info + send event */
> - peer->info.llen = sizeof(peer->info.laddr);
> - peer->info.plen = sizeof(peer->info.paddr);
> - getsockname(peer->socket, (struct sockaddr*)(&peer->info.laddr), &peer->info.llen);
> - getpeername(peer->socket, (struct sockaddr*)(&peer->info.paddr), &peer->info.plen);
> - reds_channel_event(peer, SPICE_CHANNEL_EVENT_CONNECTED);
> + stream->info.llen = sizeof(stream->info.laddr);
> + stream->info.plen = sizeof(stream->info.paddr);
> + getsockname(stream->socket, (struct sockaddr*)(&stream->info.laddr), &stream->info.llen);
> + getpeername(stream->socket, (struct sockaddr*)(&stream->info.paddr), &stream->info.plen);
> + spice_channel_event(&stream->info, SPICE_CHANNEL_EVENT_CONNECTED);
>
> openssl_init(link);
>
> @@ -1871,15 +1871,15 @@ error:
> static RedLinkInfo *reds_accept_connection(int listen_socket)
> {
> RedLinkInfo *link;
> - RedsStream *peer;
> + RedsStream *stream;
>
> if (!(link = __reds_accept_connection(listen_socket))) {
> return NULL;
> }
> - peer = link->peer;
> - peer->read = stream_read_cb;
> - peer->write = stream_write_cb;
> - peer->writev = stream_writev_cb;
> + stream = link->stream;
> + stream->read = stream_read_cb;
> + stream->write = stream_write_cb;
> + stream->writev = stream_writev_cb;
>
> return link;
> }
> @@ -1897,47 +1897,47 @@ static void reds_accept_ssl_connection(int fd, int event, void *data)
> }
>
> // Handle SSL handshaking
> - if (!(sbio = BIO_new_socket(link->peer->socket, BIO_NOCLOSE))) {
> + if (!(sbio = BIO_new_socket(link->stream->socket, BIO_NOCLOSE))) {
> red_printf("could not allocate ssl bio socket");
> goto error;
> }
>
> - link->peer->ssl = SSL_new(reds->ctx);
> - if (!link->peer->ssl) {
> + link->stream->ssl = SSL_new(reds->ctx);
> + if (!link->stream->ssl) {
> red_printf("could not allocate ssl context");
> BIO_free(sbio);
> goto error;
> }
>
> - SSL_set_bio(link->peer->ssl, sbio, sbio);
> + SSL_set_bio(link->stream->ssl, sbio, sbio);
>
> - link->peer->write = stream_ssl_write_cb;
> - link->peer->read = stream_ssl_read_cb;
> - link->peer->writev = stream_ssl_writev_cb;
> + link->stream->write = stream_ssl_write_cb;
> + link->stream->read = stream_ssl_read_cb;
> + link->stream->writev = stream_ssl_writev_cb;
>
> - return_code = SSL_accept(link->peer->ssl);
> + return_code = SSL_accept(link->stream->ssl);
> if (return_code == 1) {
> reds_handle_new_link(link);
> return;
> }
>
> - ssl_error = SSL_get_error(link->peer->ssl, return_code);
> + ssl_error = SSL_get_error(link->stream->ssl, return_code);
> if (return_code == -1 && (ssl_error == SSL_ERROR_WANT_READ ||
> ssl_error == SSL_ERROR_WANT_WRITE)) {
> int eventmask = ssl_error == SSL_ERROR_WANT_READ ?
> SPICE_WATCH_EVENT_READ : SPICE_WATCH_EVENT_WRITE;
> - link->peer->watch = core->watch_add(link->peer->socket, eventmask,
> + link->stream->watch = core->watch_add(link->stream->socket, eventmask,
> reds_handle_ssl_accept, link);
> return;
> }
>
> ERR_print_errors_fp(stderr);
> red_printf("SSL_accept failed, error=%d", ssl_error);
> - SSL_free(link->peer->ssl);
> + SSL_free(link->stream->ssl);
>
> error:
> - close(link->peer->socket);
> - free(link->peer);
> + close(link->stream->socket);
> + free(link->stream);
> BN_free(link->tiTicketing.bn);
> free(link);
> }
> @@ -3167,7 +3167,7 @@ void reds_stream_free(RedsStream *s)
> if (!s)
> return;
>
> - reds_channel_event(s, SPICE_CHANNEL_EVENT_DISCONNECTED);
> + spice_channel_event(&s->info, SPICE_CHANNEL_EVENT_DISCONNECTED);
>
> if (s->ssl)
> SSL_free(s->ssl);
> diff --git a/server/reds.h b/server/reds.h
> index 34e4082..3c810e0 100644
> --- a/server/reds.h
> +++ b/server/reds.h
> @@ -55,7 +55,7 @@ typedef struct Channel {
> uint32_t *common_caps;
> int num_caps;
> uint32_t *caps;
> - void (*link)(struct Channel *, RedsStream *peer, int migration, int num_common_caps,
> + void (*link)(struct Channel *, RedsStream *stream, 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 a7d26b6..1ae9645 100644
> --- a/server/smartcard.c
> +++ b/server/smartcard.c
> @@ -485,7 +485,7 @@ static int smartcard_channel_handle_message(RedChannel *channel, SpiceDataHeader
> return TRUE;
> }
>
> -static void smartcard_link(Channel *channel, RedsStream *peer,
> +static void smartcard_link(Channel *channel, RedsStream *stream,
> int migration, int num_common_caps,
> uint32_t *common_caps, int num_caps,
> uint32_t *caps)
> @@ -495,7 +495,7 @@ static void smartcard_link(Channel *channel, RedsStream *peer,
> }
> g_smartcard_channel =
> (SmartCardChannel *)red_channel_create(sizeof(*g_smartcard_channel),
> - peer, core,
> + stream, core,
> migration, FALSE /* handle_acks */,
> smartcard_channel_config_socket,
> smartcard_channel_disconnect,
> diff --git a/server/snd_worker.c b/server/snd_worker.c
> index 2382a29..e412f55 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 {
> - RedsStream *peer;
> + RedsStream *stream;
> SndWorker *worker;
> spice_parse_channel_func_t parser;
>
> @@ -186,9 +186,9 @@ static void snd_disconnect_channel(SndChannel *channel)
> channel->cleanup(channel);
> worker = channel->worker;
> worker->connection = NULL;
> - core->watch_remove(channel->peer->watch);
> - channel->peer->watch = NULL;
> - reds_stream_free(channel->peer);
> + core->watch_remove(channel->stream->watch);
> + channel->stream->watch = NULL;
> + reds_stream_free(channel->stream);
> spice_marshaller_destroy(channel->send_data.marshaller);
> free(channel);
> }
> @@ -236,19 +236,19 @@ static int snd_send_data(SndChannel *channel)
>
> if (channel->blocked) {
> channel->blocked = FALSE;
> - core->watch_update_mask(channel->peer->watch, SPICE_WATCH_EVENT_READ);
> + core->watch_update_mask(channel->stream->watch, SPICE_WATCH_EVENT_READ);
> }
> break;
> }
>
> vec_size = spice_marshaller_fill_iovec(channel->send_data.marshaller,
> vec, MAX_SEND_VEC, channel->send_data.pos);
> - n = reds_stream_writev(channel->peer, vec, vec_size);
> + n = reds_stream_writev(channel->stream, vec, vec_size);
> if (n == -1) {
> switch (errno) {
> case EAGAIN:
> channel->blocked = TRUE;
> - core->watch_update_mask(channel->peer->watch, SPICE_WATCH_EVENT_READ |
> + core->watch_update_mask(channel->stream->watch, SPICE_WATCH_EVENT_READ |
> SPICE_WATCH_EVENT_WRITE);
> return FALSE;
> case EINTR:
> @@ -390,7 +390,7 @@ static void snd_receive(void* data)
> ssize_t n;
> n = channel->recive_data.end - channel->recive_data.now;
> ASSERT(n);
> - n = reds_stream_read(channel->peer, channel->recive_data.now, n);
> + n = reds_stream_read(channel->stream, channel->recive_data.now, n);
> if (n <= 0) {
> if (n == 0) {
> snd_disconnect_channel(channel);
> @@ -736,7 +736,7 @@ static void snd_record_send(void* data)
> }
>
> static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_id,
> - RedsStream *peer,
> + RedsStream *stream,
> int migrate, send_messages_proc send_messages,
> handle_message_proc handle_message,
> on_message_done_proc on_message_done,
> @@ -748,28 +748,28 @@ static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_i
> int priority;
> int tos;
>
> - if ((flags = fcntl(peer->socket, F_GETFL)) == -1) {
> + if ((flags = fcntl(stream->socket, F_GETFL)) == -1) {
> red_printf("accept failed, %s", strerror(errno));
> goto error1;
> }
>
> priority = 6;
> - if (setsockopt(peer->socket, SOL_SOCKET, SO_PRIORITY, (void*)&priority,
> + if (setsockopt(stream->socket, SOL_SOCKET, SO_PRIORITY, (void*)&priority,
> sizeof(priority)) == -1) {
> red_printf("setsockopt failed, %s", strerror(errno));
> }
>
> tos = IPTOS_LOWDELAY;
> - if (setsockopt(peer->socket, IPPROTO_IP, IP_TOS, (void*)&tos, sizeof(tos)) == -1) {
> + if (setsockopt(stream->socket, IPPROTO_IP, IP_TOS, (void*)&tos, sizeof(tos)) == -1) {
> red_printf("setsockopt failed, %s", strerror(errno));
> }
>
> delay_val = IS_LOW_BANDWIDTH() ? 0 : 1;
> - if (setsockopt(peer->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val, sizeof(delay_val)) == -1) {
> + if (setsockopt(stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val, sizeof(delay_val)) == -1) {
> red_printf("setsockopt failed, %s", strerror(errno));
> }
>
> - if (fcntl(peer->socket, F_SETFL, flags | O_NONBLOCK) == -1) {
> + if (fcntl(stream->socket, F_SETFL, flags | O_NONBLOCK) == -1) {
> red_printf("accept failed, %s", strerror(errno));
> goto error1;
> }
> @@ -777,16 +777,16 @@ static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_i
> ASSERT(size >= sizeof(*channel));
> channel = spice_malloc0(size);
> channel->parser = spice_get_client_channel_parser(channel_id, NULL);
> - channel->peer = peer;
> + channel->stream = stream;
> channel->worker = worker;
> channel->recive_data.message = (SpiceDataHeader *)channel->recive_data.buf;
> channel->recive_data.now = channel->recive_data.buf;
> channel->recive_data.end = channel->recive_data.buf + sizeof(channel->recive_data.buf);
> channel->send_data.marshaller = spice_marshaller_new();
>
> - peer->watch = core->watch_add(peer->socket, SPICE_WATCH_EVENT_READ,
> + stream->watch = core->watch_add(stream->socket, SPICE_WATCH_EVENT_READ,
> snd_event, channel);
> - if (peer->watch == NULL) {
> + if (stream->watch == NULL) {
> red_printf("watch_add failed, %s", strerror(errno));
> goto error2;
> }
> @@ -802,7 +802,7 @@ error2:
> free(channel);
>
> error1:
> - reds_stream_free(peer);
> + reds_stream_free(stream);
> return NULL;
> }
>
> @@ -933,7 +933,7 @@ static void snd_playback_cleanup(SndChannel *channel)
> celt051_mode_destroy(playback_channel->celt_mode);
> }
>
> -static void snd_set_playback_peer(Channel *channel, RedsStream *peer, int migration,
> +static void snd_set_playback_peer(Channel *channel, RedsStream *stream, int migration,
> int num_common_caps, uint32_t *common_caps, int num_caps,
> uint32_t *caps)
> {
> @@ -961,7 +961,7 @@ static void snd_set_playback_peer(Channel *channel, RedsStream *peer, int migrat
> if (!(playback_channel = (PlaybackChannel *)__new_channel(worker,
> sizeof(*playback_channel),
> SPICE_CHANNEL_PLAYBACK,
> - peer,
> + stream,
> migration,
> snd_playback_send,
> snd_playback_handle_message,
> @@ -1099,7 +1099,7 @@ static void snd_record_cleanup(SndChannel *channel)
> celt051_mode_destroy(record_channel->celt_mode);
> }
>
> -static void snd_set_record_peer(Channel *channel, RedsStream *peer, int migration,
> +static void snd_set_record_peer(Channel *channel, RedsStream *stream, int migration,
> int num_common_caps, uint32_t *common_caps, int num_caps,
> uint32_t *caps)
> {
> @@ -1127,7 +1127,7 @@ static void snd_set_record_peer(Channel *channel, RedsStream *peer, int migratio
> if (!(record_channel = (RecordChannel *)__new_channel(worker,
> sizeof(*record_channel),
> SPICE_CHANNEL_RECORD,
> - peer,
> + stream,
> migration,
> snd_record_send,
> snd_record_handle_message,
> --
> 1.7.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list