Trying to send a reply string from the worker
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <czmq.h>
|
#include <czmq.h>
|
||||||
#include <zactor.h>
|
#include <zactor.h>
|
||||||
|
#include <zmsg.h>
|
||||||
#include <guestfs.h>
|
#include <guestfs.h>
|
||||||
|
|
||||||
#include "libguestfs-inspect.h"
|
#include "libguestfs-inspect.h"
|
||||||
@@ -103,9 +104,30 @@ static void *worker_task(zsock_t *pipe, char *disk_path) {
|
|||||||
// do something here
|
// do something here
|
||||||
printf("Received a message in the worker\n");
|
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
|
// 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(&msg);
|
||||||
|
zmsg_destroy(&reply);
|
||||||
|
|
||||||
|
printf("Sent reply from the worker\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
guestfs_close(g);
|
guestfs_close(g);
|
||||||
|
|||||||
Reference in New Issue
Block a user