Add loop to map messages to workers
This commit is contained in:
@@ -4,6 +4,8 @@
|
|||||||
#include <zactor.h>
|
#include <zactor.h>
|
||||||
#include <guestfs.h>
|
#include <guestfs.h>
|
||||||
|
|
||||||
|
#define STREQ(a, b) (strcmp((a), (b)) == 0)
|
||||||
|
|
||||||
void *worker_task;
|
void *worker_task;
|
||||||
|
|
||||||
char *endpoint(void);
|
char *endpoint(void);
|
||||||
@@ -25,14 +27,29 @@ int main(int argc, char **argv) {
|
|||||||
for (int i = 0; i < worker_count; i++) {
|
for (int i = 0; i < worker_count; i++) {
|
||||||
char *path = strtok(argv[i+1], ":");
|
char *path = strtok(argv[i+1], ":");
|
||||||
worker_map[i].name = strtok(NULL, ":");
|
worker_map[i].name = strtok(NULL, ":");
|
||||||
zactor_new(worker_map[i].worker, (void *) &((struct { char* path; char *name; }) {.path = path, .name = name}));
|
zactor_new(worker_map[i].worker, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *ep = endpoint();
|
char *ep = endpoint();
|
||||||
zsock_t *frontend = zsock_new_router(ep);
|
zsock_t *frontend = zsock_new_router(ep);
|
||||||
|
|
||||||
free(ep);
|
free(ep);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
zmsg_t *msg = zmsg_recv(frontend);
|
||||||
|
|
||||||
|
if (!msg) break;
|
||||||
|
|
||||||
|
// Find the worker with the given name.
|
||||||
|
zactor_t *worker = NULL;
|
||||||
|
for (int i = 0; i < worker_count; i++) {
|
||||||
|
|
||||||
|
}
|
||||||
|
if (worker) {
|
||||||
|
zmsg_send(&msg, zactor_sock(worker));
|
||||||
|
} else {
|
||||||
|
// The name specified does not exist.
|
||||||
|
}
|
||||||
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user