diff options
Diffstat (limited to '')
-rw-r--r-- | src/mds-registry/registry.c | 37 | ||||
-rw-r--r-- | src/mds-registry/slave.c | 5 |
2 files changed, 21 insertions, 21 deletions
diff --git a/src/mds-registry/registry.c b/src/mds-registry/registry.c index 359bfc3..53b905b 100644 --- a/src/mds-registry/registry.c +++ b/src/mds-registry/registry.c @@ -378,15 +378,26 @@ static int list_registry(const char* recv_client_id, const char* recv_message_id /* Make sure the message headers can fit the send buffer. */ - i = strlen(recv_message_id) + strlen(recv_client_id) + 10 + 19; - i += strlen("To: %s\nIn response to: %s\nMessage ID: %" PRIu32 "\nLength: %" PRIu64 "\n\n"); + i = sizeof("To: \n" + "In response to: \n" + "Message ID: \n" + "Origin command: register\n" + "Length: \n" + "\n") / sizeof(char) - 1; + i += strlen(recv_message_id) + strlen(recv_client_id) + 10 + 19; while (ptr + i >= send_buffer_size) fail_if (growalloc(old, send_buffer, send_buffer_size, char)); /* Construct message headers. */ - sprintf(send_buffer + ptr, "To: %s\nIn response to: %s\nMessage ID: %" PRIu32 "\nLength: %" PRIu64 "\n\n", + sprintf(send_buffer + ptr, + "To: %s\n" + "In response to: %s\n" + "Message ID: %" PRIu32 "\n" + "Origin command: register\n" + "Length: %" PRIu64 "\n" + "\n", recv_client_id, recv_message_id, message_id, ptr); /* Increase message ID. */ @@ -441,25 +452,13 @@ static int handle_register_message(void) /* Validate headers. */ if ((recv_client_id == NULL) || (strequals(recv_client_id, "0:0"))) - { - eprint("received message from anonymous sender, ignoring."); - return 0; - } + return eprint("received message from anonymous sender, ignoring."), 0; else if (strchr(recv_client_id, ':') == NULL) - { - eprint("received message from sender without a colon it its ID, ignoring, invalid ID."); - return 0; - } + return eprint("received message from sender without a colon it its ID, ignoring, invalid ID."), 0; else if ((recv_length == NULL) && ((recv_action == NULL) || !strequals(recv_action, "list"))) - { - eprint("received empty message without `Action: list`, ignoring, has no effect."); - return 0; - } + return eprint("received empty message without `Action: list`, ignoring, has no effect."), 0; else if (recv_message_id == NULL) - { - eprint("received message without ID, ignoring, master server is misbehaving."); - return 0; - } + return eprint("received message without ID, ignoring, master server is misbehaving."), 0; /* Get message length, and make sure the action is defined. */ diff --git a/src/mds-registry/slave.c b/src/mds-registry/slave.c index b7f0456..a2f4005 100644 --- a/src/mds-registry/slave.c +++ b/src/mds-registry/slave.c @@ -40,11 +40,12 @@ */ static int slave_notify_client(slave_t* slave) { - char buf[sizeof("To: %s\nIn response to: %s\nMessage ID: %" PRIu32 "\n\n") / sizeof(char) + 41]; + char buf[sizeof("To: %s\nIn response to: %s\nMessage ID: %" PRIu32 "\nOrigin command: register\n\n") + / sizeof(char) + 41]; size_t ptr = 0, sent, left; /* Construct message headers. */ - sprintf(buf, "To: %s\nIn response to: %s\nMessage ID: %" PRIu32 "\n\n", + sprintf(buf, "To: %s\nIn response to: %s\nMessage ID: %" PRIu32 "\nOrigin command: register\n\n", slave->client_id, slave->message_id, message_id); /* Increase message ID. */ |