summaryrefslogtreecommitdiffstats
path: root/server/red_channel.h
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2011-08-03 16:04:20 +0300
committerAlon Levy <alevy@redhat.com>2011-08-23 18:23:48 +0300
commit1db936e64cfe955a757d9d77302f104f68a58bfd (patch)
tree8c8ae75a9c9116b37398ef97f625c1f180b15d2a /server/red_channel.h
parent812d01c06090f14ccb65e9a3b81df311c51e4b26 (diff)
downloadspice-1db936e64cfe955a757d9d77302f104f68a58bfd.tar.gz
spice-1db936e64cfe955a757d9d77302f104f68a58bfd.tar.xz
spice-1db936e64cfe955a757d9d77302f104f68a58bfd.zip
server/red_channel.c inroducing client_cbs
client_cbs are supposed to be called from client context (reds). This patch will be used in future patches for relacing reds::Channel with RedChannel in order to eliminate redundancy.
Diffstat (limited to 'server/red_channel.h')
-rw-r--r--server/red_channel.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/server/red_channel.h b/server/red_channel.h
index 996623bb..cb33fcb1 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -23,6 +23,7 @@
#define _H_RED_CHANNEL
#include "red_common.h"
+#include <pthread.h>
#include "reds.h"
#include "spice.h"
#include "ring.h"
@@ -138,6 +139,15 @@ typedef uint64_t (*channel_handle_migrate_data_proc)(RedChannelClient *base,
typedef uint64_t (*channel_handle_migrate_data_get_serial_proc)(RedChannelClient *base,
uint32_t size, void *message);
+
+typedef void (*channel_client_connect_proc)(RedChannel *channel, RedClient *client, RedsStream *stream,
+ int migration, int num_common_caps, uint32_t *common_caps,
+ int num_caps, uint32_t *caps);
+typedef void (*channel_client_disconnect_proc)(RedChannelClient *base);
+typedef void (*channel_client_migrate_proc)(RedChannelClient *base);
+
+// TODO: add ASSERTS for thread_id in client and channel calls
+//
/*
* callbacks that are triggered from channel client stream events.
* They are called from the thread that listen to the stream events.
@@ -155,6 +165,17 @@ typedef struct {
channel_handle_migrate_data_get_serial_proc handle_migrate_data_get_serial;
} ChannelCbs;
+
+/*
+ * callbacks that are triggered from client events.
+ * They should be called from the thread that handles the RedClient
+ */
+typedef struct {
+ channel_client_connect_proc connect;
+ channel_client_disconnect_proc disconnect;
+ channel_client_migrate_proc migrate;
+} ClientCbs;
+
struct RedChannelClient {
RingItem channel_link;
RingItem client_link;
@@ -197,6 +218,7 @@ struct RedChannel {
IncomingHandlerInterface incoming_cb;
ChannelCbs channel_cbs;
+ ClientCbs client_cbs;
/* Stuff below added for Main and Inputs channels switch to RedChannel
* (might be removed later) */
@@ -204,6 +226,8 @@ struct RedChannel {
channel_on_outgoing_error_proc on_outgoing_error;
int shut; /* signal channel is to be closed */
+ // TODO: when different channel_clients are in different threads from Channel -> need to protect!
+ pthread_t thread_id;
#ifdef RED_STATISTICS
uint64_t *out_bytes_counter;
#endif
@@ -228,6 +252,8 @@ RedChannel *red_channel_create_parser(int size,
channel_on_outgoing_error_proc outgoing_error,
ChannelCbs *channel_cbs);
+void red_channel_register_client_cbs(RedChannel *channel, ClientCbs *client_cbs);
+
RedChannelClient *red_channel_client_create(int size, RedChannel *channel, RedClient *client,
RedsStream *stream);
@@ -379,6 +405,8 @@ struct RedClient {
int channels_num;
int disconnecting;
MainChannelClient *mcc;
+
+ pthread_t thread_id;
};
RedClient *red_client_new();