[Spice-devel] [PATCH spice-server 14/14] char_device: move SpiceCharDeviceState from the header

Yonit Halperin yhalperi at redhat.com
Wed Jun 27 08:16:52 PDT 2012


In addition, I also removed the no longer used wakeup callback
---
 server/char_device.c |   21 +++++++++++++++++++++
 server/char_device.h |   26 --------------------------
 server/reds.c        |    8 ++++----
 3 files changed, 25 insertions(+), 30 deletions(-)

diff --git a/server/char_device.c b/server/char_device.c
index 13a3a58..a0a0208 100644
--- a/server/char_device.c
+++ b/server/char_device.c
@@ -43,6 +43,27 @@ struct SpiceCharDeviceClientState {
     uint32_t max_send_queue_size;
 };
 
+struct SpiceCharDeviceState {
+    int running;
+    uint32_t refs;
+
+    Ring write_queue;
+    Ring write_bufs_pool;
+    SpiceCharDeviceWriteBuffer *cur_write_buf;
+    uint8_t *cur_write_buf_pos;
+    SpiceTimer *write_to_dev_timer;
+    uint64_t num_self_tokens;
+
+    Ring clients; /* list of SpiceCharDeviceClientState */
+    uint32_t num_clients;
+
+    uint64_t client_tokens_interval; /* frequency of returning tokens to the client */
+    SpiceCharDeviceInstance *sin;
+
+    SpiceCharDeviceCallbacks cbs;
+    void *opaque;
+};
+
 /* Holding references for avoiding access violation if the char device was
  * destroyed during a callback */
 static void spice_char_device_state_ref(SpiceCharDeviceState *char_dev);
diff --git a/server/char_device.h b/server/char_device.h
index d355a2f..7046cd4 100644
--- a/server/char_device.h
+++ b/server/char_device.h
@@ -108,32 +108,6 @@ typedef struct SpiceCharDeviceCallbacks {
 
 typedef struct SpiceCharDeviceState SpiceCharDeviceState;
 
-struct SpiceCharDeviceState {
-    int running;
-    uint32_t refs;
-
-    Ring write_queue;
-    Ring write_bufs_pool;
-    SpiceCharDeviceWriteBuffer *cur_write_buf;
-    uint8_t *cur_write_buf_pos;
-    SpiceTimer *write_to_dev_timer;
-    uint64_t num_self_tokens;
-
-    Ring clients;
-    uint32_t num_clients;
-
-    uint64_t client_tokens_interval; /* frequency of returning tokens to the client */
-    SpiceCharDeviceInstance *sin;
-
-    SpiceCharDeviceCallbacks cbs;
-    void *opaque;
-    /* tmp till all spice char devices will employ the new SpiceCharDeviceState
-     * implementation. Then, SpiceCharDeviceState will be moved to char_device.c and
-     * this callback will be removed */
-    void (*wakeup)(SpiceCharDeviceInstance *sin);
-};
-
-
 SpiceCharDeviceState *spice_char_device_state_create(SpiceCharDeviceInstance *sin,
                                                      uint32_t client_tokens_interval,
                                                      uint32_t self_tokens,
diff --git a/server/reds.c b/server/reds.c
index f0f4040..256e7a6 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3157,11 +3157,11 @@ static SpiceCharDeviceState *attach_to_red_agent(SpiceCharDeviceInstance *sin)
 
 SPICE_GNUC_VISIBLE void spice_server_char_device_wakeup(SpiceCharDeviceInstance* sin)
 {
-    if (sin->st->wakeup) {
-        sin->st->wakeup(sin);
-    } else {
-        spice_char_device_wakeup(sin->st);
+    if (!sin->st) {
+        spice_error("no SpiceCharDeviceState attached to instance %p", sin);
+        return;
     }
+    spice_char_device_wakeup(sin->st);
 }
 
 #define SUBTYPE_VDAGENT "vdagent"
-- 
1.7.7.6



More information about the Spice-devel mailing list