testing
This commit is contained in:
@@ -29,7 +29,7 @@ static int count_mountpoints(char *const *argv) {
|
||||
|
||||
static void cat_file(guestfs_h *g, char *file_path, char **file_content, size_t *file_size) {
|
||||
if (guestfs_is_file_opts(g, file_path, GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) {
|
||||
printf("path:: %s\n", file_path);
|
||||
//printf("path:: %s\n", file_path);
|
||||
(*file_content) = guestfs_read_file(g, file_path, file_size);
|
||||
if ((*file_content) == NULL) {
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -91,7 +91,6 @@ static guestfs_h* init_guestfs(char *disk_path) {
|
||||
|
||||
static void worker_task(zsock_t *pipe, char *disk_path) {
|
||||
guestfs_h *g;
|
||||
|
||||
g = init_guestfs(disk_path);
|
||||
|
||||
zsock_t *worker = zsock_new_dealer("inproc://workers");
|
||||
@@ -104,7 +103,7 @@ static void worker_task(zsock_t *pipe, char *disk_path) {
|
||||
if (!msg) {
|
||||
break;
|
||||
}
|
||||
printf("Received a message in the worker\n");
|
||||
//printf("Received a message in the worker\n");
|
||||
zframe_t *client_id = zmsg_pop(msg);
|
||||
|
||||
struct guestfs_inpsect_command *command = guestfs_inspect_zmsg_to_command(msg);
|
||||
@@ -115,10 +114,10 @@ static void worker_task(zsock_t *pipe, char *disk_path) {
|
||||
}
|
||||
|
||||
switch (command->command) {
|
||||
case GUESTFS_COMMAND_LS: printf("Enter ls command\n");
|
||||
case GUESTFS_COMMAND_LS: puts("");
|
||||
zmsg_pushstr(reply, "From worker! -- not implemented");
|
||||
break;
|
||||
case GUESTFS_COMMAND_CAT: printf("Entering cat command\n");
|
||||
case GUESTFS_COMMAND_CAT: puts("");
|
||||
char *res = NULL;
|
||||
size_t s = 0;
|
||||
cat_file(g, command->args.cat.paths[0], &res, &s);
|
||||
@@ -157,7 +156,7 @@ void mapping_zactor_worker(char *name, zactor_t *worker, zactor_worker_map **map
|
||||
map[mapper_size - 1] = malloc(sizeof(zactor_worker_map));
|
||||
(*map[mapper_size - 1]).name = strdup(name);
|
||||
(*map[mapper_size - 1]).worker = worker;
|
||||
printf("Registering inside mapper %s :: %p\n", name, worker);
|
||||
//printf("Registering inside mapper %s :: %p\n", name, worker);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -209,26 +208,33 @@ int main(int argc, char **argv) {
|
||||
zsock_t *backend = zsock_new(ZMQ_ROUTER);
|
||||
zsock_bind(backend, "inproc://workers");
|
||||
|
||||
for (int i = 0; i < worker_map_size; i++) {
|
||||
printf("Found:: %s :: %p\n", worker_map[i]->name, worker_map[i]->worker);
|
||||
}
|
||||
|
||||
// Connecting frontend to backend
|
||||
zpoller_t *poller = zpoller_new(frontend, backend, NULL);
|
||||
assert(poller);
|
||||
|
||||
while (true) {
|
||||
void *sock = zpoller_wait(poller, -1);
|
||||
|
||||
if (!sock) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (sock == frontend) {
|
||||
printf("Frontend message:\n");
|
||||
zmsg_t *msg = zmsg_recv(frontend);
|
||||
zmsg_print(msg);
|
||||
// reply id
|
||||
zframe_t *identity = zmsg_pop(msg);
|
||||
// Null frame
|
||||
zmsg_pop(msg);
|
||||
|
||||
struct guestfs_inpsect_command *c = guestfs_inspect_zmsg_to_command(msg);
|
||||
if (c == NULL) {
|
||||
printf("Error creating inspect command\n");
|
||||
zmsg_destroy(&msg);
|
||||
zframe_destroy(&identity);
|
||||
continue;
|
||||
}
|
||||
|
||||
zactor_t *zactor_tmp = zactor_worker_lookup(c->name, worker_map, worker_map_size);
|
||||
if (zactor_tmp != NULL) {
|
||||
@@ -248,6 +254,8 @@ int main(int argc, char **argv) {
|
||||
zmsg_pop(msg); // Removing backend id
|
||||
zmsg_send(&msg, frontend);
|
||||
zmsg_destroy(&msg);
|
||||
} else {
|
||||
printf("Recieved unknown message\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user