[PATCH 1/9] daemonClientStream: Use unsigned int to store stream @serial

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The stream serial number is the serial number of the RPC call
that initiated a data transfer. And as such can never be
negative. Moreover, when looking up internal state for a stream,
the serial numbers are compared. But hey, the serial number in
message header is unsigned too!

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 daemon/stream.c               | 22 +++++++++++-----------
 src/rpc/virnetserverprogram.c | 12 ++++++------
 src/rpc/virnetserverprogram.h |  4 ++--
 3 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/daemon/stream.c b/daemon/stream.c
index dfe0bf9..ce1e054 100644
--- a/daemon/stream.c
+++ b/daemon/stream.c
@@ -42,7 +42,7 @@ struct daemonClientStream {
 
     virStreamPtr st;
     int procedure;
-    int serial;
+    unsigned int serial;
 
     unsigned int recvEOF : 1;
     unsigned int closed : 1;
@@ -92,11 +92,11 @@ daemonStreamUpdateEvents(daemonClientStream *stream)
  * fast stream, but slow client
  */
 static void
-daemonStreamMessageFinished(virNetMessagePtr msg ATTRIBUTE_UNUSED,
+daemonStreamMessageFinished(virNetMessagePtr msg,
                             void *opaque)
 {
     daemonClientStream *stream = opaque;
-    VIR_DEBUG("stream=%p proc=%d serial=%d",
+    VIR_DEBUG("stream=%p proc=%d serial=%u",
               stream, msg->header.proc, msg->header.serial);
 
     stream->tx = 1;
@@ -293,7 +293,7 @@ daemonStreamFilter(virNetServerClientPtr client ATTRIBUTE_UNUSED,
         msg->header.serial != stream->serial)
         goto cleanup;
 
-    VIR_DEBUG("Incoming client=%p, rx=%p, serial=%d, proc=%d, status=%d",
+    VIR_DEBUG("Incoming client=%p, rx=%p, serial=%u, proc=%d, status=%d",
               client, stream->rx, msg->header.proc,
               msg->header.serial, msg->header.status);
 
@@ -324,7 +324,7 @@ daemonCreateClientStream(virNetServerClientPtr client,
     daemonClientStream *stream;
     daemonClientPrivatePtr priv = virNetServerClientGetPrivateData(client);
 
-    VIR_DEBUG("client=%p, proc=%d, serial=%d, st=%p",
+    VIR_DEBUG("client=%p, proc=%d, serial=%u, st=%p",
               client, header->proc, header->serial, st);
 
     if (VIR_ALLOC(stream) < 0)
@@ -360,7 +360,7 @@ int daemonFreeClientStream(virNetServerClientPtr client,
     if (stream->refs)
         return 0;
 
-    VIR_DEBUG("client=%p, proc=%d, serial=%d",
+    VIR_DEBUG("client=%p, proc=%d, serial=%u",
               client, stream->procedure, stream->serial);
 
     virObjectUnref(stream->prog);
@@ -398,7 +398,7 @@ int daemonAddClientStream(virNetServerClientPtr client,
                           daemonClientStream *stream,
                           bool transmit)
 {
-    VIR_DEBUG("client=%p, proc=%d, serial=%d, st=%p, transmit=%d",
+    VIR_DEBUG("client=%p, proc=%d, serial=%u, st=%p, transmit=%d",
               client, stream->procedure, stream->serial, stream->st, transmit);
     daemonClientPrivatePtr priv = virNetServerClientGetPrivateData(client);
 
@@ -448,7 +448,7 @@ int
 daemonRemoveClientStream(virNetServerClientPtr client,
                          daemonClientStream *stream)
 {
-    VIR_DEBUG("client=%p, proc=%d, serial=%d, st=%p",
+    VIR_DEBUG("client=%p, proc=%d, serial=%u, st=%p",
               client, stream->procedure, stream->serial, stream->st);
     daemonClientPrivatePtr priv = virNetServerClientGetPrivateData(client);
     daemonClientStream *curr = priv->streams;
@@ -515,7 +515,7 @@ daemonStreamHandleWriteData(virNetServerClientPtr client,
 {
     int ret;
 
-    VIR_DEBUG("client=%p, stream=%p, proc=%d, serial=%d, len=%zu, offset=%zu",
+    VIR_DEBUG("client=%p, stream=%p, proc=%d, serial=%u, len=%zu, offset=%zu",
               client, stream, msg->header.proc, msg->header.serial,
               msg->bufferLength, msg->bufferOffset);
 
@@ -565,7 +565,7 @@ daemonStreamHandleFinish(virNetServerClientPtr client,
 {
     int ret;
 
-    VIR_DEBUG("client=%p, stream=%p, proc=%d, serial=%d",
+    VIR_DEBUG("client=%p, stream=%p, proc=%d, serial=%u",
               client, stream, msg->header.proc, msg->header.serial);
 
     stream->closed = 1;
@@ -602,7 +602,7 @@ daemonStreamHandleAbort(virNetServerClientPtr client,
                         daemonClientStream *stream,
                         virNetMessagePtr msg)
 {
-    VIR_DEBUG("client=%p, stream=%p, proc=%d, serial=%d",
+    VIR_DEBUG("client=%p, stream=%p, proc=%d, serial=%u",
               client, stream, msg->header.proc, msg->header.serial);
     virNetMessageError rerr;
 
diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c
index a4d9295..311e344 100644
--- a/src/rpc/virnetserverprogram.c
+++ b/src/rpc/virnetserverprogram.c
@@ -147,9 +147,9 @@ virNetServerProgramSendError(unsigned program,
                              virNetMessageErrorPtr rerr,
                              int procedure,
                              int type,
-                             int serial)
+                             unsigned int serial)
 {
-    VIR_DEBUG("prog=%d ver=%d proc=%d type=%d serial=%d msg=%p rerr=%p",
+    VIR_DEBUG("prog=%d ver=%d proc=%d type=%d serial=%u msg=%p rerr=%p",
               program, version, procedure, type, serial, msg, rerr);
 
     virNetMessageSaveError(rerr);
@@ -217,7 +217,7 @@ int virNetServerProgramSendStreamError(virNetServerProgramPtr prog,
                                        virNetMessagePtr msg,
                                        virNetMessageErrorPtr rerr,
                                        int procedure,
-                                       int serial)
+                                       unsigned int serial)
 {
     return virNetServerProgramSendError(prog->program,
                                         prog->version,
@@ -282,7 +282,7 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog,
 
     memset(&rerr, 0, sizeof(rerr));
 
-    VIR_DEBUG("prog=%d ver=%d type=%d status=%d serial=%d proc=%d",
+    VIR_DEBUG("prog=%d ver=%d type=%d status=%d serial=%u proc=%d",
               msg->header.prog, msg->header.vers, msg->header.type,
               msg->header.status, msg->header.serial, msg->header.proc);
 
@@ -312,7 +312,7 @@ int virNetServerProgramDispatch(virNetServerProgramPtr prog,
          * stream packets after we closed down a stream. Just drop & ignore
          * these.
          */
-        VIR_INFO("Ignoring unexpected stream data serial=%d proc=%d status=%d",
+        VIR_INFO("Ignoring unexpected stream data serial=%u proc=%d status=%d",
                  msg->header.serial, msg->header.proc, msg->header.status);
         /* Send a dummy reply to free up 'msg' & unblock client rx */
         virNetMessageClear(msg);
@@ -510,7 +510,7 @@ int virNetServerProgramSendStreamData(virNetServerProgramPtr prog,
                                       virNetServerClientPtr client,
                                       virNetMessagePtr msg,
                                       int procedure,
-                                      int serial,
+                                      unsigned int serial,
                                       const char *data,
                                       size_t len)
 {
diff --git a/src/rpc/virnetserverprogram.h b/src/rpc/virnetserverprogram.h
index 0ccc372..531fca0 100644
--- a/src/rpc/virnetserverprogram.h
+++ b/src/rpc/virnetserverprogram.h
@@ -90,7 +90,7 @@ int virNetServerProgramSendStreamError(virNetServerProgramPtr prog,
                                        virNetMessagePtr msg,
                                        virNetMessageErrorPtr rerr,
                                        int procedure,
-                                       int serial);
+                                       unsigned int serial);
 
 int virNetServerProgramUnknownError(virNetServerClientPtr client,
                                     virNetMessagePtr msg,
@@ -100,7 +100,7 @@ int virNetServerProgramSendStreamData(virNetServerProgramPtr prog,
                                       virNetServerClientPtr client,
                                       virNetMessagePtr msg,
                                       int procedure,
-                                      int serial,
+                                      unsigned int serial,
                                       const char *data,
                                       size_t len);
 
-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]