[Spice-devel] [vdagent-linux 4/3] Report an error when file transfers are disabled

Christophe Fergeau cfergeau at redhat.com
Tue Apr 8 07:15:49 PDT 2014


This commit sends back a VD_AGENT_FILE_XFER_STATUS_ERROR to clients which
try to transfer files when the agent disabled file transfers (for example
because there is no valid destination directory for the transferred files).
---
 src/vdagent-file-xfers.c | 8 ++++++++
 src/vdagent-file-xfers.h | 2 ++
 src/vdagent.c            | 9 +++++++++
 3 files changed, 19 insertions(+)

diff --git a/src/vdagent-file-xfers.c b/src/vdagent-file-xfers.c
index 379cda0..344859d 100644
--- a/src/vdagent-file-xfers.c
+++ b/src/vdagent-file-xfers.c
@@ -315,3 +315,11 @@ void vdagent_file_xfers_data(struct vdagent_file_xfers *xfers,
         g_hash_table_remove(xfers->xfers, GUINT_TO_POINTER(msg->id));
     }
 }
+
+void vdagent_file_xfers_error(struct udscs_connection *vdagentd, uint32_t msg_id)
+{
+    g_return_if_fail(vdagentd != NULL);
+
+    udscs_write(vdagentd, VDAGENTD_FILE_XFER_STATUS,
+                msg_id, VD_AGENT_FILE_XFER_STATUS_ERROR, NULL, 0);
+}
diff --git a/src/vdagent-file-xfers.h b/src/vdagent-file-xfers.h
index 20783eb..fe5da81 100644
--- a/src/vdagent-file-xfers.h
+++ b/src/vdagent-file-xfers.h
@@ -37,5 +37,7 @@ void vdagent_file_xfers_status(struct vdagent_file_xfers *xfers,
     VDAgentFileXferStatusMessage *msg);
 void vdagent_file_xfers_data(struct vdagent_file_xfers *xfers,
     VDAgentFileXferDataMessage *msg);
+void vdagent_file_xfers_error(struct udscs_connection *vdagentd,
+    uint32_t msg_id);
 
 #endif
diff --git a/src/vdagent.c b/src/vdagent.c
index 50498ef..251b1d4 100644
--- a/src/vdagent.c
+++ b/src/vdagent.c
@@ -92,6 +92,9 @@ void daemon_read_complete(struct udscs_connection **connp,
         if (vdagent_file_xfers != NULL) {
             vdagent_file_xfers_start(vdagent_file_xfers,
                                      (VDAgentFileXferStartMessage *)data);
+        } else {
+            vdagent_file_xfers_error(*connp,
+                                     ((VDAgentFileXferStartMessage *)data)->id);
         }
         free(data);
         break;
@@ -99,6 +102,9 @@ void daemon_read_complete(struct udscs_connection **connp,
         if (vdagent_file_xfers != NULL) {
             vdagent_file_xfers_status(vdagent_file_xfers,
                                       (VDAgentFileXferStatusMessage *)data);
+        } else {
+            vdagent_file_xfers_error(*connp,
+                                     ((VDAgentFileXferStatusMessage *)data)->id);
         }
         free(data);
         break;
@@ -106,6 +112,9 @@ void daemon_read_complete(struct udscs_connection **connp,
         if (vdagent_file_xfers != NULL) {
             vdagent_file_xfers_data(vdagent_file_xfers,
                                     (VDAgentFileXferDataMessage *)data);
+        } else {
+            vdagent_file_xfers_error(*connp,
+                                     ((VDAgentFileXferDataMessage *)data)->id);
         }
         free(data);
         break;
-- 
1.9.0



More information about the Spice-devel mailing list