Skip to content

Commit

Permalink
Fixed stupid bug. Using m_log in Easy sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeDP committed Mar 17, 2018
1 parent 2157fcd commit 1e471b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions Lib/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#define GET_MOD_IN_STATE(self, state) \
GET_MOD(self); \
if (!module_is(mod, state)) { return MOD_WRONG_STATE; }
if (!module_is(s, state)) { return MOD_WRONG_STATE; }

#define CHILDREN_LOOP(f) \
child_t *tmp = m->children; \
Expand Down Expand Up @@ -151,19 +151,19 @@ int module_register(const char *name, const char *ctx_name, const void **self, u
}

MODULE_DEBUG("Registering module %s.\n", name);

mod = malloc(sizeof(module));
MOD_ASSERT(mod, "Failed to malloc.", MOD_ERR);

*mod = (module) {0};
if (hashmap_put(context->modules, (char *)name, mod) == MAP_OK) {
if (hashmap_put(context->modules, (char *)name, mod) == MAP_OK) {
mod->hook = hook;
mod->state = IDLE;
mod->self.name = strdup(name);
mod->self.ctx = strdup(ctx_name);
mod->subscriptions = hashmap_new();
*self = &mod->self;
evaluate_module(NULL, mod);
*self = &mod->self;
evaluate_module(NULL, mod);
return MOD_OK;
}
free(mod);
Expand Down Expand Up @@ -266,7 +266,7 @@ static int evaluate_module(void *data, void *m) {
module *mod = (module *)m;
if (module_is(&mod->self, IDLE)
&& mod->hook->evaluate()) {

int fd = mod->hook->get_fd();
module_start(&mod->self, fd);
}
Expand Down Expand Up @@ -401,7 +401,7 @@ int module_is(const void *self, const enum module_states st) {

/** Module state setters **/

int module_start(const void *self, int fd) {
int module_start(const void *self, int fd) {
GET_MOD_IN_STATE(self, IDLE);

mod->fd = fd;
Expand Down
2 changes: 1 addition & 1 deletion Samples/Easy/a.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ static void recv_ready(msg_t *msg, const void *userdata) {
m_unbecome();
}
} else {
printf("Received message %s from %s.\n", msg->message->message, msg->message->sender);
m_log("Received message %s from %s.\n", msg->message->message, msg->message->sender);
}
}
2 changes: 1 addition & 1 deletion Samples/Easy/b.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static void recv(msg_t *msg, const void *userdata) {
m_log("received signal %d. Leaving.\n", fdsi.ssi_signo);
modules_quit();
} else {
printf("Received message '%s' from %s on topic '%s'.\n", msg->message->message, msg->message->sender, msg->message->topic);
m_log("Received message '%s' from %s on topic '%s'.\n", msg->message->message, msg->message->sender, msg->message->topic);
m_tell("Nice!", msg->message->sender);
}
}

0 comments on commit 1e471b6

Please sign in to comment.