From 187acad82a8c0cbcc0c2e831691f22449b32ee33 Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Sun, 3 Mar 2024 14:19:32 -0500 Subject: [PATCH] Trying to send a reply string from the worker --- guestfs-inspectd.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/guestfs-inspectd.c b/guestfs-inspectd.c index 6c17ad3..307814e 100644 --- a/guestfs-inspectd.c +++ b/guestfs-inspectd.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "libguestfs-inspect.h" @@ -103,9 +104,30 @@ static void *worker_task(zsock_t *pipe, char *disk_path) { // do something here printf("Received a message in the worker\n"); + printf("Size: %zu\tContent size: %zu\n", zmsg_size(msg), zmsg_content_size(msg)); + struct guestfs_inpsect_command *command = malloc(80); + memcpy(command, zmsg_last(msg), 80); + printf("Name: %s\n", command->name); + + free(command); + // Sending reply - zmsg_send(&msg, pipe); + /* zmsg_send(&msg, pipe); */ + /* zstr_send(pipe, ); */ + zmsg_t *reply = zmsg_new(); + if (!reply) { + printf("wuddahec\n"); + exit(EXIT_FAILURE); + } + + zmsg_addstr(reply, "Hello from the worker!"); + zmsg_set_routing_id(reply, zmsg_routing_id(msg)); + zmsg_send(reply, pipe); + zmsg_destroy(&msg); + zmsg_destroy(&reply); + + printf("Sent reply from the worker\n"); } guestfs_close(g);