aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-07-16 16:38:45 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-07-16 16:38:45 +0200
commit8a37d71ce6ca77f87f773299461cbdbf2058565b (patch)
treedb304189dd0cf2c3c5e6ac83530906a78fdd90f1
parent877c0690c62fb038de3f47a3d7f41bb32960ed33 (diff)
downloadmarkov-k-ram-8a37d71ce6ca77f87f773299461cbdbf2058565b.zip
markov-k-ram-8a37d71ce6ca77f87f773299461cbdbf2058565b.tar.bz2
Adds support for ?RPV.
-rw-r--r--src/server/server.c7
-rw-r--r--src/server/server_initialize.c18
-rw-r--r--src/server/server_worker_handle_request.c22
3 files changed, 35 insertions, 12 deletions
diff --git a/src/server/server.c b/src/server/server.c
index 709a9a7..8299d73 100644
--- a/src/server/server.c
+++ b/src/server/server.c
@@ -15,12 +15,6 @@ int JH_server_main
JH_index retries;
retries = 0;
- /* TODO
- if (JH_server_set_signal_handlers < 0)
- {
- return -1;
- }
- */
if (JH_server_initialize(&server, params) < 0)
{
@@ -32,7 +26,6 @@ int JH_server_main
switch (JH_server_wait_for_event(&server))
{
case 0: /* Timed out or signal'd. */
- //JH_S_DEBUG(stderr, 1, "Timed out...");
JH_server_handle_joining_threads(&server);
retries = 0;
diff --git a/src/server/server_initialize.c b/src/server/server_initialize.c
index be1341e..42f19f7 100644
--- a/src/server/server_initialize.c
+++ b/src/server/server_initialize.c
@@ -48,6 +48,8 @@ static int initialize_worker_collection
if (error != 0)
{
+ pthread_mutex_destroy(&(c->mutex));
+
JH_FATAL
(
stderr,
@@ -61,7 +63,16 @@ static int initialize_worker_collection
return 0;
}
-void initialize_thread_parameters
+static void finalize_worker_collection
+(
+ struct JH_server_thread_collection c [const restrict static 1]
+)
+{
+ pthread_mutex_destroy(&(c->mutex));
+ pthread_barrier_destroy(&(c->barrier));
+}
+
+static void initialize_thread_parameters
(
struct JH_server server [const restrict static 1],
const struct JH_parameters params [const restrict static 1]
@@ -91,7 +102,8 @@ int JH_server_initialize
if (JH_knowledge_initialize(&(server->k)) < 0)
{
- /* TODO: finalize "server->workers" */
+ finalize_worker_collection(&(server->workers));
+
return -1;
}
@@ -104,7 +116,7 @@ int JH_server_initialize
) < 0
)
{
- /* TODO: finalize "server->workers" */
+ finalize_worker_collection(&(server->workers));
JH_knowledge_finalize(&(server->k));
return -2;
diff --git a/src/server/server_worker_handle_request.c b/src/server/server_worker_handle_request.c
index 25f93bc..67efaf5 100644
--- a/src/server/server_worker_handle_request.c
+++ b/src/server/server_worker_handle_request.c
@@ -98,9 +98,27 @@ static int handle_rpv
struct JH_server_worker worker [const restrict static 1]
)
{
- /* TODO */
+ if
+ (
+ (worker->buffer[5] == '1')
+ &&
+ (
+ (worker->buffer[6] == ',')
+ || (worker->buffer[6] == '\n')
+ )
+ )
+ {
+ if (JH_server_worker_send_confirm_protocol_version(worker) < 0)
+ {
+ return -1;
+ }
- return -1;
+ return JH_server_worker_send_positive(worker);
+ }
+ else
+ {
+ return JH_server_worker_send_negative(worker);
+ }
}
static int handle_rps