Reflector: report received bytes

+ some small improvements
This commit is contained in:
Martin Pulec
2013-06-26 10:50:25 +02:00
parent 4a6dd92dc6
commit 29820960df
7 changed files with 65 additions and 4 deletions

View File

@@ -20,6 +20,8 @@ struct response *send_message(struct module *root, const char *const_path, struc
*/
if(receiver == NULL) {
fprintf(stderr, "%s not found:\n", const_path);
dump_tree(root, 0);
snprintf(buf, sizeof(buf), "(path: %s)", const_path);
return new_response(RESPONSE_NOT_FOUND, strdup(buf));
}
@@ -42,11 +44,12 @@ struct response *send_message(struct module *root, const char *const_path, struc
struct response *send_message_to_receiver(struct module *receiver, struct message *msg)
{
lock_guard guard(receiver->lock);
if(receiver->msg_callback) {
lock_guard guard(receiver->lock);
return receiver->msg_callback(receiver, msg);
} else {
return new_response(RESPONSE_NOT_IMPL, NULL);
simple_linked_list_append(receiver->msg_queue, msg);
return new_response(RESPONSE_ACCEPTED, NULL);
}
}
@@ -114,3 +117,16 @@ const char *response_status_to_text(int status)
return NULL;
}
struct message *check_message(struct module *mod)
{
struct message *ret;
lock_guard guard(mod->lock);
if(simple_linked_list_size(mod->msg_queue) > 0) {
return (struct message *) simple_linked_list_pop(mod->msg_queue);
} else {
return NULL;
}
}