[Spice-devel] [spice-server v2 12/14] rcc: Remove red-channel-client-private.h

Christophe Fergeau cfergeau at redhat.com
Tue Feb 14 14:17:37 UTC 2017


Nothing outside of RedChannelClient needs access to data contained in
RedChannelClientPrivate, so we can move all the type definitions to the
.c file to make it fully opaque rather than relying on a private header.

Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
---
 server/Makefile.am                  |   1 -
 server/red-channel-client-private.h | 130 ------------------------------------
 server/red-channel-client.c         | 107 ++++++++++++++++++++++++++++-
 3 files changed, 106 insertions(+), 132 deletions(-)
 delete mode 100644 server/red-channel-client-private.h

diff --git a/server/Makefile.am b/server/Makefile.am
index 6db4e7b..a043660 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -101,7 +101,6 @@ libserver_la_SOURCES =				\
 	red-channel.h				\
 	red-channel-client.c			\
 	red-channel-client.h			\
-	red-channel-client-private.h		\
 	red-client.c				\
 	red-client.h				\
 	red-common.h				\
diff --git a/server/red-channel-client-private.h b/server/red-channel-client-private.h
deleted file mode 100644
index 5c1308b..0000000
--- a/server/red-channel-client-private.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
-    Copyright (C) 2009-2015 Red Hat, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _H_RED_CHANNEL_CLIENT_PRIVATE
-#define _H_RED_CHANNEL_CLIENT_PRIVATE
-
-#include "red-channel.h"
-#include "red-channel-client.h"
-
-typedef struct SpiceDataHeaderOpaque SpiceDataHeaderOpaque;
-
-typedef uint16_t (*get_msg_type_proc)(SpiceDataHeaderOpaque *header);
-typedef uint32_t (*get_msg_size_proc)(SpiceDataHeaderOpaque *header);
-typedef void (*set_msg_type_proc)(SpiceDataHeaderOpaque *header, uint16_t type);
-typedef void (*set_msg_size_proc)(SpiceDataHeaderOpaque *header, uint32_t size);
-typedef void (*set_msg_serial_proc)(SpiceDataHeaderOpaque *header, uint64_t serial);
-typedef void (*set_msg_sub_list_proc)(SpiceDataHeaderOpaque *header, uint32_t sub_list);
-
-struct SpiceDataHeaderOpaque {
-    uint8_t *data;
-    uint16_t header_size;
-
-    set_msg_type_proc set_msg_type;
-    set_msg_size_proc set_msg_size;
-    set_msg_serial_proc set_msg_serial;
-    set_msg_sub_list_proc set_msg_sub_list;
-
-    get_msg_type_proc get_msg_type;
-    get_msg_size_proc get_msg_size;
-};
-
-typedef struct RedChannelClientLatencyMonitor {
-    int state;
-    uint64_t last_pong_time;
-    SpiceTimer *timer;
-    uint32_t id;
-    int tcp_nodelay;
-    int warmup_was_sent;
-
-    int64_t roundtrip;
-} RedChannelClientLatencyMonitor;
-
-typedef struct RedChannelClientConnectivityMonitor {
-    int state;
-    uint32_t out_bytes;
-    uint32_t in_bytes;
-    uint32_t timeout;
-    SpiceTimer *timer;
-} RedChannelClientConnectivityMonitor;
-
-typedef struct OutgoingHandler {
-    struct iovec vec_buf[IOV_MAX];
-    int vec_size;
-    struct iovec *vec;
-    int pos;
-    int size;
-} OutgoingHandler;
-
-typedef struct IncomingHandler {
-    uint8_t header_buf[MAX_HEADER_SIZE];
-    SpiceDataHeaderOpaque header;
-    uint32_t header_pos;
-    uint8_t *msg; // data of the msg following the header. allocated by alloc_msg_buf.
-    uint32_t msg_pos;
-} IncomingHandler;
-
-struct RedChannelClientPrivate
-{
-    RedChannel *channel;
-    RedClient  *client;
-    RedsStream *stream;
-    gboolean monitor_latency;
-
-    struct {
-        uint32_t generation;
-        uint32_t client_generation;
-        uint32_t messages_window;
-        uint32_t client_window;
-    } ack_data;
-
-    struct {
-        /* this can be either main.marshaller or urgent.marshaller */
-        SpiceMarshaller *marshaller;
-        SpiceDataHeaderOpaque header;
-        uint32_t size;
-        int blocked;
-        uint64_t last_sent_serial;
-
-        struct {
-            SpiceMarshaller *marshaller;
-            uint8_t *header_data;
-        } main;
-
-        struct {
-            SpiceMarshaller *marshaller;
-        } urgent;
-    } send_data;
-
-    int during_send;
-    GQueue pipe;
-
-    RedChannelCapabilities remote_caps;
-    int is_mini_header;
-    gboolean destroying;
-
-    int wait_migrate_data;
-    int wait_migrate_flush_mark;
-
-    RedChannelClientLatencyMonitor latency_monitor;
-    RedChannelClientConnectivityMonitor connectivity_monitor;
-
-    IncomingHandler incoming;
-    OutgoingHandler outgoing;
-};
-
-#endif /* _H_RED_CHANNEL_CLIENT_PRIVATE */
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index d33e756..a22df6b 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -34,10 +34,115 @@
 #include <common/generated_server_marshallers.h>
 
 #include "red-channel-client.h"
-#include "red-channel-client-private.h"
 #include "red-client.h"
 #include "glib-compat.h"
 
+typedef struct SpiceDataHeaderOpaque SpiceDataHeaderOpaque;
+
+typedef uint16_t (*get_msg_type_proc)(SpiceDataHeaderOpaque *header);
+typedef uint32_t (*get_msg_size_proc)(SpiceDataHeaderOpaque *header);
+typedef void (*set_msg_type_proc)(SpiceDataHeaderOpaque *header, uint16_t type);
+typedef void (*set_msg_size_proc)(SpiceDataHeaderOpaque *header, uint32_t size);
+typedef void (*set_msg_serial_proc)(SpiceDataHeaderOpaque *header, uint64_t serial);
+typedef void (*set_msg_sub_list_proc)(SpiceDataHeaderOpaque *header, uint32_t sub_list);
+
+struct SpiceDataHeaderOpaque {
+    uint8_t *data;
+    uint16_t header_size;
+
+    set_msg_type_proc set_msg_type;
+    set_msg_size_proc set_msg_size;
+    set_msg_serial_proc set_msg_serial;
+    set_msg_sub_list_proc set_msg_sub_list;
+
+    get_msg_type_proc get_msg_type;
+    get_msg_size_proc get_msg_size;
+};
+
+typedef struct RedChannelClientLatencyMonitor {
+    int state;
+    uint64_t last_pong_time;
+    SpiceTimer *timer;
+    uint32_t id;
+    int tcp_nodelay;
+    int warmup_was_sent;
+
+    int64_t roundtrip;
+} RedChannelClientLatencyMonitor;
+
+typedef struct RedChannelClientConnectivityMonitor {
+    int state;
+    uint32_t out_bytes;
+    uint32_t in_bytes;
+    uint32_t timeout;
+    SpiceTimer *timer;
+} RedChannelClientConnectivityMonitor;
+
+typedef struct OutgoingHandler {
+    struct iovec vec_buf[IOV_MAX];
+    int vec_size;
+    struct iovec *vec;
+    int pos;
+    int size;
+} OutgoingHandler;
+
+typedef struct IncomingHandler {
+    uint8_t header_buf[MAX_HEADER_SIZE];
+    SpiceDataHeaderOpaque header;
+    uint32_t header_pos;
+    uint8_t *msg; // data of the msg following the header. allocated by alloc_msg_buf.
+    uint32_t msg_pos;
+} IncomingHandler;
+
+struct RedChannelClientPrivate
+{
+    RedChannel *channel;
+    RedClient  *client;
+    RedsStream *stream;
+    gboolean monitor_latency;
+
+    struct {
+        uint32_t generation;
+        uint32_t client_generation;
+        uint32_t messages_window;
+        uint32_t client_window;
+    } ack_data;
+
+    struct {
+        /* this can be either main.marshaller or urgent.marshaller */
+        SpiceMarshaller *marshaller;
+        SpiceDataHeaderOpaque header;
+        uint32_t size;
+        int blocked;
+        uint64_t last_sent_serial;
+
+        struct {
+            SpiceMarshaller *marshaller;
+            uint8_t *header_data;
+        } main;
+
+        struct {
+            SpiceMarshaller *marshaller;
+        } urgent;
+    } send_data;
+
+    int during_send;
+    GQueue pipe;
+
+    RedChannelCapabilities remote_caps;
+    int is_mini_header;
+    gboolean destroying;
+
+    int wait_migrate_data;
+    int wait_migrate_flush_mark;
+
+    RedChannelClientLatencyMonitor latency_monitor;
+    RedChannelClientConnectivityMonitor connectivity_monitor;
+
+    IncomingHandler incoming;
+    OutgoingHandler outgoing;
+};
+
 static const SpiceDataHeaderOpaque full_header_wrapper;
 static const SpiceDataHeaderOpaque mini_header_wrapper;
 static void red_channel_client_clear_sent_item(RedChannelClient *rcc);
-- 
2.9.3



More information about the Spice-devel mailing list