summaryrefslogtreecommitdiff
path: root/server/red-channel.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2016-02-09 14:35:01 +0100
committerFrediano Ziglio <fziglio@redhat.com>2016-02-09 14:01:08 +0000
commit9766619dfffaebc82728624e6d0a0c3083ee2906 (patch)
tree12221aa7406a429904b64877836b448950a7e53b /server/red-channel.c
parentb0b64bea5906134bd6f3b4ab1fd1e33677eec247 (diff)
red-channel: return number of created pipe items
This is useful in the following patches to count the number of replies to wait for. Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Diffstat (limited to 'server/red-channel.c')
-rw-r--r--server/red-channel.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/server/red-channel.c b/server/red-channel.c
index 4bc2faae..f3a1cea0 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -2245,15 +2245,17 @@ typedef int (*rcc_item_cond_t)(RedChannelClient *rcc, PipeItem *item);
* @creator: a callback to create pipe item (not null)
* @data: the data to pass to the creator
* @pipe_add: a callback to add non-null pipe items (not null)
+ *
+ * Returns: the number of added items
**/
-static void red_channel_pipes_create_batch(RedChannel *channel,
+static int red_channel_pipes_create_batch(RedChannel *channel,
new_pipe_item_t creator, void *data,
rcc_item_t pipe_add)
{
RingItem *link, *next;
RedChannelClient *rcc;
PipeItem *item;
- int num = 0;
+ int num = 0, n = 0;
spice_assert(creator != NULL);
spice_assert(pipe_add != NULL);
@@ -2263,16 +2265,21 @@ static void red_channel_pipes_create_batch(RedChannel *channel,
item = (*creator)(rcc, data, num++);
if (item) {
(*pipe_add)(rcc, item);
+ n++;
}
}
+
+ return n;
}
-void red_channel_pipes_new_add_push(RedChannel *channel,
- new_pipe_item_t creator, void *data)
+int red_channel_pipes_new_add_push(RedChannel *channel,
+ new_pipe_item_t creator, void *data)
{
- red_channel_pipes_create_batch(channel, creator, data,
- red_channel_client_pipe_add);
+ int n = red_channel_pipes_create_batch(channel, creator, data,
+ red_channel_client_pipe_add);
red_channel_push(channel);
+
+ return n;
}
void red_channel_pipes_new_add(RedChannel *channel, new_pipe_item_t creator, void *data)