[Spice-commits] 3 commits - server/main_channel.h server/red_worker.c server/reds-private.h server/reds.c server/snd_worker.c

Christophe Fergau teuf at kemper.freedesktop.org
Tue Oct 8 10:08:47 PDT 2013


 server/main_channel.h |    4 -
 server/red_worker.c   |    8 +--
 server/reds-private.h |    6 +-
 server/reds.c         |  118 +++++++++++++++++++++++++-------------------------
 server/snd_worker.c   |   40 ++++++++--------
 5 files changed, 88 insertions(+), 88 deletions(-)

New commits:
commit edfb16a55d22440fd0dcadf1f41d897a153fc617
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Wed Oct 2 18:44:20 2013 +0200

    reds: Fix 'asyc' typo

diff --git a/server/reds.c b/server/reds.c
index 5af0ba4..bcbb130 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -141,7 +141,7 @@ typedef struct AsyncRead {
 
 typedef struct RedLinkInfo {
     RedsStream *stream;
-    AsyncRead asyc_read;
+    AsyncRead async_read;
     SpiceLinkHeader link_header;
     SpiceLinkMess *link_mess;
     int mess_pos;
@@ -2118,12 +2118,12 @@ static void async_read_handler(int fd, int event, void *data)
 
 static void reds_get_spice_ticket(RedLinkInfo *link)
 {
-    AsyncRead *obj = &link->asyc_read;
+    AsyncRead *obj = &link->async_read;
 
     obj->now = (uint8_t *)&link->tiTicketing.encrypted_ticket.encrypted_data;
     obj->end = obj->now + link->tiTicketing.rsa_size;
     obj->done = reds_handle_ticket;
-    async_read_handler(0, 0, &link->asyc_read);
+    async_read_handler(0, 0, &link->async_read);
 }
 
 #if HAVE_SASL
@@ -2209,7 +2209,7 @@ static void reds_handle_auth_sasl_step(void *opaque)
     RedLinkInfo *link = (RedLinkInfo *)opaque;
     RedsSASL *sasl = &link->stream->sasl;
     uint32_t datalen = sasl->len;
-    AsyncRead *obj = &link->asyc_read;
+    AsyncRead *obj = &link->async_read;
 
     /* NB, distinction of NULL vs "" is *critical* in SASL */
     if (datalen) {
@@ -2257,7 +2257,7 @@ static void reds_handle_auth_sasl_step(void *opaque)
         obj->now = (uint8_t *)&sasl->len;
         obj->end = obj->now + sizeof(uint32_t);
         obj->done = reds_handle_auth_sasl_steplen;
-        async_read_handler(0, 0, &link->asyc_read);
+        async_read_handler(0, 0, &link->async_read);
     } else {
         int ssf;
 
@@ -2293,7 +2293,7 @@ authabort:
 static void reds_handle_auth_sasl_steplen(void *opaque)
 {
     RedLinkInfo *link = (RedLinkInfo *)opaque;
-    AsyncRead *obj = &link->asyc_read;
+    AsyncRead *obj = &link->async_read;
     RedsSASL *sasl = &link->stream->sasl;
 
     spice_info("Got steplen %d", sasl->len);
@@ -2310,7 +2310,7 @@ static void reds_handle_auth_sasl_steplen(void *opaque)
         obj->now = (uint8_t *)sasl->data;
         obj->end = obj->now + sasl->len;
         obj->done = reds_handle_auth_sasl_step;
-        async_read_handler(0, 0, &link->asyc_read);
+        async_read_handler(0, 0, &link->async_read);
     }
 }
 
@@ -2333,7 +2333,7 @@ static void reds_handle_auth_sasl_steplen(void *opaque)
 static void reds_handle_auth_sasl_start(void *opaque)
 {
     RedLinkInfo *link = (RedLinkInfo *)opaque;
-    AsyncRead *obj = &link->asyc_read;
+    AsyncRead *obj = &link->async_read;
     const char *serverout;
     unsigned int serveroutlen;
     int err;
@@ -2388,7 +2388,7 @@ static void reds_handle_auth_sasl_start(void *opaque)
         obj->now = (uint8_t *)&sasl->len;
         obj->end = obj->now + sizeof(uint32_t);
         obj->done = reds_handle_auth_sasl_steplen;
-        async_read_handler(0, 0, &link->asyc_read);
+        async_read_handler(0, 0, &link->async_read);
     } else {
         int ssf;
 
@@ -2424,7 +2424,7 @@ authabort:
 static void reds_handle_auth_startlen(void *opaque)
 {
     RedLinkInfo *link = (RedLinkInfo *)opaque;
-    AsyncRead *obj = &link->asyc_read;
+    AsyncRead *obj = &link->async_read;
     RedsSASL *sasl = &link->stream->sasl;
 
     spice_info("Got client start len %d", sasl->len);
@@ -2444,13 +2444,13 @@ static void reds_handle_auth_startlen(void *opaque)
     obj->now = (uint8_t *)sasl->data;
     obj->end = obj->now + sasl->len;
     obj->done = reds_handle_auth_sasl_start;
-    async_read_handler(0, 0, &link->asyc_read);
+    async_read_handler(0, 0, &link->async_read);
 }
 
 static void reds_handle_auth_mechname(void *opaque)
 {
     RedLinkInfo *link = (RedLinkInfo *)opaque;
-    AsyncRead *obj = &link->asyc_read;
+    AsyncRead *obj = &link->async_read;
     RedsSASL *sasl = &link->stream->sasl;
 
     sasl->mechname[sasl->len] = '\0';
@@ -2488,7 +2488,7 @@ static void reds_handle_auth_mechname(void *opaque)
     obj->now = (uint8_t *)&sasl->len;
     obj->end = obj->now + sizeof(uint32_t);
     obj->done = reds_handle_auth_startlen;
-    async_read_handler(0, 0, &link->asyc_read);
+    async_read_handler(0, 0, &link->async_read);
 
     return;
 }
@@ -2496,7 +2496,7 @@ static void reds_handle_auth_mechname(void *opaque)
 static void reds_handle_auth_mechlen(void *opaque)
 {
     RedLinkInfo *link = (RedLinkInfo *)opaque;
-    AsyncRead *obj = &link->asyc_read;
+    AsyncRead *obj = &link->async_read;
     RedsSASL *sasl = &link->stream->sasl;
 
     if (sasl->len < 1 || sasl->len > 100) {
@@ -2511,7 +2511,7 @@ static void reds_handle_auth_mechlen(void *opaque)
     obj->now = (uint8_t *)sasl->mechname;
     obj->end = obj->now + sasl->len;
     obj->done = reds_handle_auth_mechname;
-    async_read_handler(0, 0, &link->asyc_read);
+    async_read_handler(0, 0, &link->async_read);
 }
 
 static void reds_start_auth_sasl(RedLinkInfo *link)
@@ -2521,7 +2521,7 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
     int err;
     char *localAddr, *remoteAddr;
     int mechlistlen;
-    AsyncRead *obj = &link->asyc_read;
+    AsyncRead *obj = &link->async_read;
     RedsSASL *sasl = &link->stream->sasl;
 
     /* Get local & remote client addresses in form  IPADDR;PORT */
@@ -2624,7 +2624,7 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
     obj->now = (uint8_t *)&sasl->len;
     obj->end = obj->now + sizeof(uint32_t);
     obj->done = reds_handle_auth_mechlen;
-    async_read_handler(0, 0, &link->asyc_read);
+    async_read_handler(0, 0, &link->async_read);
 
     return;
 
@@ -2674,7 +2674,7 @@ static void reds_handle_read_link_done(void *opaque)
 {
     RedLinkInfo *link = (RedLinkInfo *)opaque;
     SpiceLinkMess *link_mess = link->link_mess;
-    AsyncRead *obj = &link->asyc_read;
+    AsyncRead *obj = &link->async_read;
     uint32_t num_caps = link_mess->num_common_caps + link_mess->num_channel_caps;
     uint32_t *caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset);
     int auth_selection;
@@ -2719,7 +2719,7 @@ static void reds_handle_read_link_done(void *opaque)
         obj->now = (uint8_t *)&link->auth_mechanism;
         obj->end = obj->now + sizeof(SpiceLinkAuthMechanism);
         obj->done = reds_handle_auth_mechanism;
-        async_read_handler(0, 0, &link->asyc_read);
+        async_read_handler(0, 0, &link->async_read);
     }
 }
 
@@ -2741,7 +2741,7 @@ static void reds_handle_read_header_done(void *opaque)
 {
     RedLinkInfo *link = (RedLinkInfo *)opaque;
     SpiceLinkHeader *header = &link->link_header;
-    AsyncRead *obj = &link->asyc_read;
+    AsyncRead *obj = &link->async_read;
 
     if (header->magic != SPICE_MAGIC) {
         reds_send_link_error(link, SPICE_LINK_ERR_INVALID_MAGIC);
@@ -2773,19 +2773,19 @@ static void reds_handle_read_header_done(void *opaque)
     obj->now = (uint8_t *)link->link_mess;
     obj->end = obj->now + header->size;
     obj->done = reds_handle_read_link_done;
-    async_read_handler(0, 0, &link->asyc_read);
+    async_read_handler(0, 0, &link->async_read);
 }
 
 static void reds_handle_new_link(RedLinkInfo *link)
 {
-    AsyncRead *obj = &link->asyc_read;
+    AsyncRead *obj = &link->async_read;
     obj->opaque = link;
     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;
     obj->error = reds_handle_link_error;
-    async_read_handler(0, 0, &link->asyc_read);
+    async_read_handler(0, 0, &link->async_read);
 }
 
 static void reds_handle_ssl_accept(int fd, int event, void *data)
commit df96538e1fc3518174333e29e7041877fc9d0ecc
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Wed Oct 2 18:42:49 2013 +0200

    Fix 'recive' typo throughout the code base
    
    'receive' was mispelt 'recive' in multiple places.

diff --git a/server/red_worker.c b/server/red_worker.c
index 451c8ab..afbdd91 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -383,7 +383,7 @@ typedef struct LocalCursor {
 } LocalCursor;
 
 #define MAX_PIPE_SIZE 50
-#define CHANNEL_RECIVE_BUF_SIZE 1024
+#define CHANNEL_RECEIVE_BUF_SIZE 1024
 
 #define WIDE_CLIENT_ACK_WINDOW 40
 #define NARROW_CLIENT_ACK_WINDOW 20
@@ -654,7 +654,7 @@ typedef struct GlzSharedDictionary {
 typedef struct CommonChannel {
     RedChannel base; // Must be the first thing
     struct RedWorker *worker;
-    uint8_t recv_buf[CHANNEL_RECIVE_BUF_SIZE];
+    uint8_t recv_buf[CHANNEL_RECEIVE_BUF_SIZE];
     uint32_t id_alloc; // bitfield. TODO - use this instead of shift scheme.
     int during_target_migrate; /* TRUE when the client that is associated with the channel
                                   is during migration. Turned off when the vm is started.
@@ -1591,8 +1591,8 @@ static uint8_t *common_alloc_recv_buf(RedChannelClient *rcc, uint16_t type, uint
         return spice_malloc(size);
     }
 
-    if (size > CHANNEL_RECIVE_BUF_SIZE) {
-        spice_critical("unexpected message size %u (max is %d)", size, CHANNEL_RECIVE_BUF_SIZE);
+    if (size > CHANNEL_RECEIVE_BUF_SIZE) {
+        spice_critical("unexpected message size %u (max is %d)", size, CHANNEL_RECEIVE_BUF_SIZE);
         return NULL;
     }
     return common->recv_buf;
diff --git a/server/reds-private.h b/server/reds-private.h
index 9358d27..ee09e7c 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -57,9 +57,9 @@ typedef struct VDIPortState {
     /* read from agent */
     Ring read_bufs;
     uint32_t read_state;
-    uint32_t message_recive_len;
-    uint8_t *recive_pos;
-    uint32_t recive_len;
+    uint32_t message_receive_len;
+    uint8_t *receive_pos;
+    uint32_t receive_len;
     VDIReadBuf *current_read_buf;
     AgentMsgFilter read_filter;
 
diff --git a/server/reds.c b/server/reds.c
index 1456b75..5af0ba4 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -476,9 +476,9 @@ static void reds_reset_vdp(void)
     SpiceCharDeviceInterface *sif;
 
     state->read_state = VDI_PORT_READ_STATE_READ_HEADER;
-    state->recive_pos = (uint8_t *)&state->vdi_chunk_header;
-    state->recive_len = sizeof(state->vdi_chunk_header);
-    state->message_recive_len = 0;
+    state->receive_pos = (uint8_t *)&state->vdi_chunk_header;
+    state->receive_len = sizeof(state->vdi_chunk_header);
+    state->message_receive_len = 0;
     if (state->current_read_buf) {
         vdi_port_read_buf_unref(state->current_read_buf);
         state->current_read_buf = NULL;
@@ -786,43 +786,43 @@ static SpiceCharDeviceMsgToClient *vdi_port_read_one_msg_from_device(SpiceCharDe
     while (vdagent) {
         switch (state->read_state) {
         case VDI_PORT_READ_STATE_READ_HEADER:
-            n = sif->read(vdagent, state->recive_pos, state->recive_len);
+            n = sif->read(vdagent, state->receive_pos, state->receive_len);
             if (!n) {
                 return NULL;
             }
-            if ((state->recive_len -= n)) {
-                state->recive_pos += n;
+            if ((state->receive_len -= n)) {
+                state->receive_pos += n;
                 return NULL;
             }
-            state->message_recive_len = state->vdi_chunk_header.size;
+            state->message_receive_len = state->vdi_chunk_header.size;
             state->read_state = VDI_PORT_READ_STATE_GET_BUFF;
         case VDI_PORT_READ_STATE_GET_BUFF: {
             if (!(state->current_read_buf = vdi_port_read_buf_get())) {
                 return NULL;
             }
-            state->recive_pos = state->current_read_buf->data;
-            state->recive_len = MIN(state->message_recive_len,
+            state->receive_pos = state->current_read_buf->data;
+            state->receive_len = MIN(state->message_receive_len,
                                     sizeof(state->current_read_buf->data));
-            state->current_read_buf->len = state->recive_len;
-            state->message_recive_len -= state->recive_len;
+            state->current_read_buf->len = state->receive_len;
+            state->message_receive_len -= state->receive_len;
             state->read_state = VDI_PORT_READ_STATE_READ_DATA;
         }
         case VDI_PORT_READ_STATE_READ_DATA:
-            n = sif->read(vdagent, state->recive_pos, state->recive_len);
+            n = sif->read(vdagent, state->receive_pos, state->receive_len);
             if (!n) {
                 return NULL;
             }
-            if ((state->recive_len -= n)) {
-                state->recive_pos += n;
+            if ((state->receive_len -= n)) {
+                state->receive_pos += n;
                 break;
             }
             dispatch_buf = state->current_read_buf;
             state->current_read_buf = NULL;
-            state->recive_pos = NULL;
-            if (state->message_recive_len == 0) {
+            state->receive_pos = NULL;
+            if (state->message_receive_len == 0) {
                 state->read_state = VDI_PORT_READ_STATE_READ_HEADER;
-                state->recive_pos = (uint8_t *)&state->vdi_chunk_header;
-                state->recive_len = sizeof(state->vdi_chunk_header);
+                state->receive_pos = (uint8_t *)&state->vdi_chunk_header;
+                state->receive_len = sizeof(state->vdi_chunk_header);
             } else {
                 state->read_state = VDI_PORT_READ_STATE_GET_BUFF;
             }
@@ -1184,8 +1184,8 @@ void reds_on_main_channel_migrate(MainChannelClient *mcc)
         return;
     }
     spice_assert(agent_state->current_read_buf->data &&
-                 agent_state->recive_pos > agent_state->current_read_buf->data);
-    read_data_len = agent_state->recive_pos - agent_state->current_read_buf->data;
+                 agent_state->receive_pos > agent_state->current_read_buf->data);
+    read_data_len = agent_state->receive_pos - agent_state->current_read_buf->data;
 
     if (agent_state->read_filter.msg_data_to_read ||
         read_data_len > sizeof(VDAgentMessage)) { /* msg header has been read */
@@ -1205,11 +1205,11 @@ void reds_on_main_channel_migrate(MainChannelClient *mcc)
             vdi_port_read_buf_unref(read_buf);
         }
 
-        spice_assert(agent_state->recive_len);
-        agent_state->message_recive_len += agent_state->recive_len;
+        spice_assert(agent_state->receive_len);
+        agent_state->message_receive_len += agent_state->receive_len;
         agent_state->read_state = VDI_PORT_READ_STATE_GET_BUFF;
         agent_state->current_read_buf = NULL;
-        agent_state->recive_pos = NULL;
+        agent_state->receive_pos = NULL;
     }
 }
 
@@ -1248,7 +1248,7 @@ void reds_marshall_migrate_data(SpiceMarshaller *m)
 
     /* agent to client partial msg */
     if (agent_state->read_state == VDI_PORT_READ_STATE_READ_HEADER) {
-        mig_data.agent2client.chunk_header_size = agent_state->recive_pos -
+        mig_data.agent2client.chunk_header_size = agent_state->receive_pos -
             (uint8_t *)&agent_state->vdi_chunk_header;
 
         mig_data.agent2client.msg_header_done = FALSE;
@@ -1256,12 +1256,12 @@ void reds_marshall_migrate_data(SpiceMarshaller *m)
         spice_assert(!agent_state->read_filter.msg_data_to_read);
     } else {
         mig_data.agent2client.chunk_header_size = sizeof(VDIChunkHeader);
-        mig_data.agent2client.chunk_header.size = agent_state->message_recive_len;
+        mig_data.agent2client.chunk_header.size = agent_state->message_receive_len;
         if (agent_state->read_state == VDI_PORT_READ_STATE_READ_DATA) {
             /* in the middle of reading the message header (see reds_on_main_channel_migrate) */
             mig_data.agent2client.msg_header_done = FALSE;
             mig_data.agent2client.msg_header_partial_len =
-                agent_state->recive_pos - agent_state->current_read_buf->data;
+                agent_state->receive_pos - agent_state->current_read_buf->data;
             spice_assert(mig_data.agent2client.msg_header_partial_len < sizeof(VDAgentMessage));
             spice_assert(!agent_state->read_filter.msg_data_to_read);
         } else {
@@ -1306,11 +1306,11 @@ static int reds_agent_state_restore(SpiceMigrateDataMain *mig_data)
     chunk_header_remaining = sizeof(VDIChunkHeader) - mig_data->agent2client.chunk_header_size;
     if (chunk_header_remaining) {
         agent_state->read_state = VDI_PORT_READ_STATE_READ_HEADER;
-        agent_state->recive_pos = (uint8_t *)&agent_state->vdi_chunk_header +
+        agent_state->receive_pos = (uint8_t *)&agent_state->vdi_chunk_header +
             mig_data->agent2client.chunk_header_size;
-        agent_state->recive_len = chunk_header_remaining;
+        agent_state->receive_len = chunk_header_remaining;
     } else {
-        agent_state->message_recive_len = agent_state->vdi_chunk_header.size;
+        agent_state->message_receive_len = agent_state->vdi_chunk_header.size;
     }
 
     if (!mig_data->agent2client.msg_header_done) {
@@ -1327,21 +1327,21 @@ static int reds_agent_state_restore(SpiceMigrateDataMain *mig_data)
             memcpy(agent_state->current_read_buf->data,
                    partial_msg_header,
                    mig_data->agent2client.msg_header_partial_len);
-            agent_state->recive_pos = agent_state->current_read_buf->data +
+            agent_state->receive_pos = agent_state->current_read_buf->data +
                                       mig_data->agent2client.msg_header_partial_len;
             cur_buf_size = sizeof(agent_state->current_read_buf->data) -
                            mig_data->agent2client.msg_header_partial_len;
-            agent_state->recive_len = MIN(agent_state->message_recive_len, cur_buf_size);
-            agent_state->current_read_buf->len = agent_state->recive_len +
+            agent_state->receive_len = MIN(agent_state->message_receive_len, cur_buf_size);
+            agent_state->current_read_buf->len = agent_state->receive_len +
                                                  mig_data->agent2client.msg_header_partial_len;
-            agent_state->message_recive_len -= agent_state->recive_len;
+            agent_state->message_receive_len -= agent_state->receive_len;
         } else {
             spice_assert(mig_data->agent2client.msg_header_partial_len == 0);
         }
     } else {
             agent_state->read_state = VDI_PORT_READ_STATE_GET_BUFF;
             agent_state->current_read_buf = NULL;
-            agent_state->recive_pos = NULL;
+            agent_state->receive_pos = NULL;
             agent_state->read_filter.msg_data_to_read = mig_data->agent2client.msg_remaining;
             agent_state->read_filter.result = mig_data->agent2client.msg_filter_result;
     }
@@ -3889,8 +3889,8 @@ static void init_vd_agent_resources(void)
                           agent_file_xfer, TRUE);
 
     state->read_state = VDI_PORT_READ_STATE_READ_HEADER;
-    state->recive_pos = (uint8_t *)&state->vdi_chunk_header;
-    state->recive_len = sizeof(state->vdi_chunk_header);
+    state->receive_pos = (uint8_t *)&state->vdi_chunk_header;
+    state->receive_len = sizeof(state->vdi_chunk_header);
 
     for (i = 0; i < REDS_VDI_PORT_NUM_RECEIVE_BUFFS; i++) {
         VDIReadBuf *buf = spice_new0(VDIReadBuf, 1);
diff --git a/server/snd_worker.c b/server/snd_worker.c
index 19171e3..5346d96 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -42,7 +42,7 @@
 #define IOV_MAX 1024
 #endif
 
-#define SND_RECIVE_BUF_SIZE (16 * 1024 * 2)
+#define SND_RECEIVE_BUF_SIZE (16 * 1024 * 2)
 
 #define FRAME_SIZE 256
 #define PLAYBACK_BUF_SIZE (FRAME_SIZE * 4)
@@ -50,7 +50,7 @@
 #define CELT_BIT_RATE (64 * 1024)
 #define CELT_COMPRESSED_FRAME_BYTES (FRAME_SIZE * CELT_BIT_RATE / SPICE_INTERFACE_PLAYBACK_FREQ / 8)
 
-#define RECORD_SAMPLES_SIZE (SND_RECIVE_BUF_SIZE >> 2)
+#define RECORD_SAMPLES_SIZE (SND_RECEIVE_BUF_SIZE >> 2)
 
 enum PlaybackeCommand {
     SND_PLAYBACK_MIGRATE,
@@ -112,11 +112,11 @@ struct SndChannel {
     } send_data;
 
     struct {
-        uint8_t buf[SND_RECIVE_BUF_SIZE];
+        uint8_t buf[SND_RECEIVE_BUF_SIZE];
         uint8_t *message_start;
         uint8_t *now;
         uint8_t *end;
-    } recive_data;
+    } receive_data;
 
     snd_channel_send_messages_proc send_messages;
     snd_channel_handle_message_proc handle_message;
@@ -420,9 +420,9 @@ static void snd_receive(void* data)
 
     for (;;) {
         ssize_t n;
-        n = channel->recive_data.end - channel->recive_data.now;
+        n = channel->receive_data.end - channel->receive_data.now;
         spice_assert(n);
-        n = reds_stream_read(channel->stream, channel->recive_data.now, n);
+        n = reds_stream_read(channel->stream, channel->receive_data.now, n);
         if (n <= 0) {
             if (n == 0) {
                 snd_disconnect_channel(channel);
@@ -443,16 +443,16 @@ static void snd_receive(void* data)
                 return;
             }
         } else {
-            channel->recive_data.now += n;
+            channel->receive_data.now += n;
             for (;;) {
-                uint8_t *msg_start = channel->recive_data.message_start;
+                uint8_t *msg_start = channel->receive_data.message_start;
                 uint8_t *data = msg_start + header->header_size;
                 size_t parsed_size;
                 uint8_t *parsed;
                 message_destructor_t parsed_free;
 
                 header->data = msg_start;
-                n = channel->recive_data.now - msg_start;
+                n = channel->receive_data.now - msg_start;
 
                 if (n < header->header_size ||
                     n < header->header_size + header->get_msg_size(header)) {
@@ -473,16 +473,16 @@ static void snd_receive(void* data)
                     return;
                 }
                 parsed_free(parsed);
-                channel->recive_data.message_start = msg_start + header->header_size +
+                channel->receive_data.message_start = msg_start + header->header_size +
                                                      header->get_msg_size(header);
             }
-            if (channel->recive_data.now == channel->recive_data.message_start) {
-                channel->recive_data.now = channel->recive_data.buf;
-                channel->recive_data.message_start = channel->recive_data.buf;
-            } else if (channel->recive_data.now == channel->recive_data.end) {
-                memcpy(channel->recive_data.buf, channel->recive_data.message_start, n);
-                channel->recive_data.now = channel->recive_data.buf + n;
-                channel->recive_data.message_start = channel->recive_data.buf;
+            if (channel->receive_data.now == channel->receive_data.message_start) {
+                channel->receive_data.now = channel->receive_data.buf;
+                channel->receive_data.message_start = channel->receive_data.buf;
+            } else if (channel->receive_data.now == channel->receive_data.end) {
+                memcpy(channel->receive_data.buf, channel->receive_data.message_start, n);
+                channel->receive_data.now = channel->receive_data.buf + n;
+                channel->receive_data.message_start = channel->receive_data.buf;
             }
         }
     }
@@ -938,9 +938,9 @@ static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_i
     channel->parser = spice_get_client_channel_parser(channel_id, NULL);
     channel->stream = stream;
     channel->worker = worker;
-    channel->recive_data.message_start = 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->receive_data.message_start = channel->receive_data.buf;
+    channel->receive_data.now = channel->receive_data.buf;
+    channel->receive_data.end = channel->receive_data.buf + sizeof(channel->receive_data.buf);
     channel->send_data.marshaller = spice_marshaller_new();
 
     stream->watch = core->watch_add(stream->socket, SPICE_WATCH_EVENT_READ,
commit 394fd0e6b76a8b4b0662d4445b4f961fa5798e74
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Wed Oct 2 18:42:24 2013 +0200

    Namespace RECEIVE_BUF_SIZE

diff --git a/server/main_channel.h b/server/main_channel.h
index 29eb8d4..c8e9ade 100644
--- a/server/main_channel.h
+++ b/server/main_channel.h
@@ -30,12 +30,12 @@
 #define REDS_NUM_INTERNAL_AGENT_MESSAGES 1
 
 // approximate max receive message size for main channel
-#define RECEIVE_BUF_SIZE \
+#define MAIN_CHANNEL_RECEIVE_BUF_SIZE \
     (4096 + (REDS_AGENT_WINDOW_SIZE + REDS_NUM_INTERNAL_AGENT_MESSAGES) * SPICE_AGENT_MAX_DATA_SIZE)
 
 typedef struct MainChannel {
     RedChannel base;
-    uint8_t recv_buf[RECEIVE_BUF_SIZE];
+    uint8_t recv_buf[MAIN_CHANNEL_RECEIVE_BUF_SIZE];
     RedsMigSpice mig_target; // TODO: add refs and release (afrer all clients completed migration in one way or the other?)
     int num_clients_mig_wait;
 } MainChannel;
diff --git a/server/red_worker.c b/server/red_worker.c
index 8763c8e..451c8ab 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -383,7 +383,7 @@ typedef struct LocalCursor {
 } LocalCursor;
 
 #define MAX_PIPE_SIZE 50
-#define RECIVE_BUF_SIZE 1024
+#define CHANNEL_RECIVE_BUF_SIZE 1024
 
 #define WIDE_CLIENT_ACK_WINDOW 40
 #define NARROW_CLIENT_ACK_WINDOW 20
@@ -654,7 +654,7 @@ typedef struct GlzSharedDictionary {
 typedef struct CommonChannel {
     RedChannel base; // Must be the first thing
     struct RedWorker *worker;
-    uint8_t recv_buf[RECIVE_BUF_SIZE];
+    uint8_t recv_buf[CHANNEL_RECIVE_BUF_SIZE];
     uint32_t id_alloc; // bitfield. TODO - use this instead of shift scheme.
     int during_target_migrate; /* TRUE when the client that is associated with the channel
                                   is during migration. Turned off when the vm is started.
@@ -1591,8 +1591,8 @@ static uint8_t *common_alloc_recv_buf(RedChannelClient *rcc, uint16_t type, uint
         return spice_malloc(size);
     }
 
-    if (size > RECIVE_BUF_SIZE) {
-        spice_critical("unexpected message size %u (max is %d)", size, RECIVE_BUF_SIZE);
+    if (size > CHANNEL_RECIVE_BUF_SIZE) {
+        spice_critical("unexpected message size %u (max is %d)", size, CHANNEL_RECIVE_BUF_SIZE);
         return NULL;
     }
     return common->recv_buf;
diff --git a/server/snd_worker.c b/server/snd_worker.c
index ebddfcd..19171e3 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -42,7 +42,7 @@
 #define IOV_MAX 1024
 #endif
 
-#define RECIVE_BUF_SIZE (16 * 1024 * 2)
+#define SND_RECIVE_BUF_SIZE (16 * 1024 * 2)
 
 #define FRAME_SIZE 256
 #define PLAYBACK_BUF_SIZE (FRAME_SIZE * 4)
@@ -50,7 +50,7 @@
 #define CELT_BIT_RATE (64 * 1024)
 #define CELT_COMPRESSED_FRAME_BYTES (FRAME_SIZE * CELT_BIT_RATE / SPICE_INTERFACE_PLAYBACK_FREQ / 8)
 
-#define RECORD_SAMPLES_SIZE (RECIVE_BUF_SIZE >> 2)
+#define RECORD_SAMPLES_SIZE (SND_RECIVE_BUF_SIZE >> 2)
 
 enum PlaybackeCommand {
     SND_PLAYBACK_MIGRATE,
@@ -112,7 +112,7 @@ struct SndChannel {
     } send_data;
 
     struct {
-        uint8_t buf[RECIVE_BUF_SIZE];
+        uint8_t buf[SND_RECIVE_BUF_SIZE];
         uint8_t *message_start;
         uint8_t *now;
         uint8_t *end;


More information about the Spice-commits mailing list