Compare commits
3 Commits
d4dc71376e
...
0134deeb56
| Author | SHA1 | Date | |
|---|---|---|---|
| 0134deeb56 | |||
| bccd86ef38 | |||
| 300b4d7aba |
@@ -4,6 +4,8 @@
|
||||
#include <zactor.h>
|
||||
#include <guestfs.h>
|
||||
|
||||
#define STREQ(a, b) (strcmp((a), (b)) == 0)
|
||||
|
||||
void *worker_task;
|
||||
|
||||
char *endpoint(void);
|
||||
@@ -17,14 +19,37 @@ int main(int argc, char **argv) {
|
||||
const int worker_count = argc - 1;
|
||||
|
||||
// One worker per disk image.
|
||||
zactor_t *workers[worker_count];
|
||||
struct {
|
||||
char *name;
|
||||
zactor_t *worker;
|
||||
} worker_map[worker_count];
|
||||
|
||||
for (int i = 0; i < worker_count; i++) {
|
||||
char *path = strtok(argv[i+1], ":");
|
||||
char *name = strtok(NULL, ":");
|
||||
workers[i] = zactor_new(worker_task, (void *) &((struct { char* path; char *name; }) {.path = path, .name = name}));
|
||||
worker_map[i].name = strtok(NULL, ":");
|
||||
zactor_new(worker_map[i].worker, path);
|
||||
}
|
||||
|
||||
char *ep = endpoint();
|
||||
zsock_t *frontend = zsock_new_router(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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user