aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-08-24 17:11:40 +0200
committerMattias Andrée <maandree@operamail.com>2015-08-24 17:11:40 +0200
commit9032427b752f5cf3e39867321e933d9f21306917 (patch)
tree8e0bdcb22fe4e3d0a39c83eb56d25abfeee9ce97
parentmds-registry: fix buffer overflow (diff)
downloadmds-9032427b752f5cf3e39867321e933d9f21306917.tar.gz
mds-9032427b752f5cf3e39867321e933d9f21306917.tar.bz2
mds-9032427b752f5cf3e39867321e933d9f21306917.tar.xz
mds-server: style
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--src/mds-server/globals.c43
-rw-r--r--src/mds-server/globals.h4
-rw-r--r--src/mds-server/receiving.c8
3 files changed, 49 insertions, 6 deletions
diff --git a/src/mds-server/globals.c b/src/mds-server/globals.c
index 9ee67aa..2030fa7 100644
--- a/src/mds-server/globals.c
+++ b/src/mds-server/globals.c
@@ -18,16 +18,59 @@
#include "globals.h"
+/**
+ * The program run state, 1 when running, 0 when shutting down
+ */
volatile sig_atomic_t running = 1;
+
+/**
+ * The number of running slaves
+ */
size_t running_slaves = 0;
+
+/**
+ * Mutex for slave data
+ */
pthread_mutex_t slave_mutex;
+
+/**
+ * Condition for slave data
+ */
pthread_cond_t slave_cond;
+
+/**
+ * Map from client socket file descriptor to all information (`client_t`)
+ */
fd_table_t client_map;
+
+/**
+ * List of client information (`client_t`)
+ */
linked_list_t client_list;
+
+/**
+ * The next free ID for a client
+ */
uint64_t next_client_id = 1;
+
+/**
+ * The next free ID for a message modifications
+ */
uint64_t next_modify_id = 1;
+
+/**
+ * Mutex for message modification
+ */
pthread_mutex_t modify_mutex;
+
+/**
+ * Condition for message modification
+ */
pthread_cond_t modify_cond;
+
+/**
+ * Map from modification ID to waiting client
+ */
hash_table_t modify_map;
diff --git a/src/mds-server/globals.h b/src/mds-server/globals.h
index 63b1e34..cfebdee 100644
--- a/src/mds-server/globals.h
+++ b/src/mds-server/globals.h
@@ -57,12 +57,12 @@ extern pthread_mutex_t slave_mutex;
extern pthread_cond_t slave_cond;
/**
- * Map from client socket file descriptor to all information (client_t)
+ * Map from client socket file descriptor to all information (`client_t`)
*/
extern fd_table_t client_map;
/**
- * List of client information (client_t)
+ * List of client information (`client_t`)
*/
extern linked_list_t client_list;
diff --git a/src/mds-server/receiving.c b/src/mds-server/receiving.c
index b18c222..28823f7 100644
--- a/src/mds-server/receiving.c
+++ b/src/mds-server/receiving.c
@@ -120,7 +120,7 @@ static int add_intercept_conditions_from_message(client_t* client, int modifying
fail_if (xmalloc(buf, size + 1, char));
- /* All messages */
+ /* All messages. */
if (client->message.payload_size == 0)
{
*buf = '\0';
@@ -128,7 +128,7 @@ static int add_intercept_conditions_from_message(client_t* client, int modifying
goto done;
}
- /* Filtered messages */
+ /* Filtered messages. */
for (;;)
{
char* end = memchr(payload, '\n', payload_size);
@@ -182,8 +182,8 @@ static int assign_and_send_id(client_t* client, const char* message_id)
int rc = -1;
/* Construct response. */
- n = 2 * 10 + strlen(message_id) + 1;
- n += strlen("ID assignment: :\nIn response to: \n\n");
+ n = 2 * 10 + strlen(message_id);
+ n += sizeof("ID assignment: :\nIn response to: \n\n") / sizeof(char);
fail_if (xmalloc(msgbuf, n, char));
snprintf(msgbuf, n,
"ID assignment: %" PRIu32 ":%" PRIu32 "\n"