diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-09-05 16:41:31 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-09-05 16:41:31 +0000 |
commit | 39c0c0fdef116610245c43e825ce9ebeff11234d (patch) | |
tree | 3ef441857c34f1794e3ec0619e63a53c4c61b6a8 | |
parent | 574c6c658c6ce0f249fe833951a70dd5486f4ff4 (diff) | |
download | gnunet-39c0c0fdef116610245c43e825ce9ebeff11234d.tar.gz gnunet-39c0c0fdef116610245c43e825ce9ebeff11234d.zip |
more rework of the logics
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct.c | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c index 1e92074e3..54b54cc0a 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct.c +++ b/src/scalarproduct/gnunet-service-scalarproduct.c | |||
@@ -896,7 +896,6 @@ prepare_service_response (gcry_mpi_t * r, | |||
896 | if ( ! request->service_transmit_handle) | 896 | if ( ! request->service_transmit_handle) |
897 | { | 897 | { |
898 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send service-response message via mesh!)\n")); | 898 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send service-response message via mesh!)\n")); |
899 | GNUNET_CONTAINER_DLL_remove (from_client_head, from_client_tail, response); | ||
900 | 899 | ||
901 | response->client_notification_task = | 900 | response->client_notification_task = |
902 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, | 901 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, |
@@ -1160,8 +1159,6 @@ prepare_service_request (void *cls, | |||
1160 | { | 1159 | { |
1161 | // TODO FEATURE: fallback to fragmentation, in case the message is too long | 1160 | // TODO FEATURE: fallback to fragmentation, in case the message is too long |
1162 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Message too large, fragmentation is currently not supported!\n")); | 1161 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Message too large, fragmentation is currently not supported!\n")); |
1163 | GNUNET_CONTAINER_DLL_remove (from_client_head, from_client_tail, session); | ||
1164 | |||
1165 | session->client_notification_task = | 1162 | session->client_notification_task = |
1166 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, | 1163 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, |
1167 | session); | 1164 | session); |
@@ -1243,8 +1240,6 @@ prepare_service_request (void *cls, | |||
1243 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not send mutlicast message to tunnel!\n")); | 1240 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not send mutlicast message to tunnel!\n")); |
1244 | GNUNET_free (msg_obj); | 1241 | GNUNET_free (msg_obj); |
1245 | GNUNET_free (msg); | 1242 | GNUNET_free (msg); |
1246 | GNUNET_CONTAINER_DLL_remove (from_client_head, from_client_tail, session); | ||
1247 | |||
1248 | session->client_notification_task = | 1243 | session->client_notification_task = |
1249 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, | 1244 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, |
1250 | session); | 1245 | session); |
@@ -1275,10 +1270,15 @@ handle_client_request (void *cls, | |||
1275 | uint32_t i; | 1270 | uint32_t i; |
1276 | 1271 | ||
1277 | GNUNET_SERVER_client_get_user_context (client, session); | 1272 | GNUNET_SERVER_client_get_user_context (client, session); |
1278 | if (NULL != session){ | 1273 | if ((NULL != session) && (session->state != FINALIZED)){ |
1274 | // only one concurrent session per client connection allowed | ||
1275 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1276 | return; | ||
1277 | } | ||
1278 | else if(NULL != session){ | ||
1279 | // old session is already completed, clean it up | ||
1280 | GNUNET_CONTAINER_DLL_remove (from_client_head, from_client_tail, session); | ||
1279 | free_session(session); | 1281 | free_session(session); |
1280 | // FIXME: also terminate active handles and tasks, in it's not finalized | ||
1281 | GNUNET_SERVER_client_set_user_context (client, NULL); | ||
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | //we need at least a peer and one message id to compare | 1284 | //we need at least a peer and one message id to compare |
@@ -1399,13 +1399,12 @@ handle_client_request (void *cls, | |||
1399 | GNUNET_SCHEDULER_add_now (&prepare_service_request, | 1399 | GNUNET_SCHEDULER_add_now (&prepare_service_request, |
1400 | session); | 1400 | session); |
1401 | 1401 | ||
1402 | GNUNET_SERVER_receive_done (client, GNUNET_YES); | ||
1403 | } | 1402 | } |
1404 | else | 1403 | else |
1405 | { | 1404 | { |
1406 | struct ServiceSession * requesting_session; | 1405 | struct ServiceSession * requesting_session; |
1407 | enum SessionState needed_state = REQUEST_FROM_SERVICE_RECEIVED; | 1406 | enum SessionState needed_state = REQUEST_FROM_SERVICE_RECEIVED; |
1408 | 1407 | ||
1409 | session->role = BOB; | 1408 | session->role = BOB; |
1410 | session->mask = NULL; | 1409 | session->mask = NULL; |
1411 | // copy over the elements | 1410 | // copy over the elements |
@@ -1415,7 +1414,6 @@ handle_client_request (void *cls, | |||
1415 | session->state = MESSAGE_FROM_RESPONDING_CLIENT_RECEIVED; | 1414 | session->state = MESSAGE_FROM_RESPONDING_CLIENT_RECEIVED; |
1416 | 1415 | ||
1417 | GNUNET_CONTAINER_DLL_insert (from_client_head, from_client_tail, session); | 1416 | GNUNET_CONTAINER_DLL_insert (from_client_head, from_client_tail, session); |
1418 | GNUNET_SERVER_receive_done (client, GNUNET_YES); | ||
1419 | //check if service queue contains a matching request | 1417 | //check if service queue contains a matching request |
1420 | requesting_session = find_matching_session (from_service_tail, | 1418 | requesting_session = find_matching_session (from_service_tail, |
1421 | &session->key, | 1419 | &session->key, |
@@ -1425,19 +1423,18 @@ handle_client_request (void *cls, | |||
1425 | { | 1423 | { |
1426 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Got client-responder-session with key %s and a matching service-request-session set, processing.\n"), GNUNET_h2s (&session->key)); | 1424 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Got client-responder-session with key %s and a matching service-request-session set, processing.\n"), GNUNET_h2s (&session->key)); |
1427 | if (GNUNET_OK != compute_service_response (requesting_session, session)) | 1425 | if (GNUNET_OK != compute_service_response (requesting_session, session)) |
1428 | { | ||
1429 | GNUNET_CONTAINER_DLL_remove (from_client_head, from_client_tail, session); | ||
1430 | |||
1431 | session->client_notification_task = | 1426 | session->client_notification_task = |
1432 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, | 1427 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, |
1433 | session); | 1428 | session); |
1434 | } | 1429 | |
1435 | } | 1430 | } |
1436 | else | 1431 | else{ |
1437 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Got client-responder-session with key %s but NO matching service-request-session set, queuing element for later use.\n"), GNUNET_h2s (&session->key)); | 1432 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Got client-responder-session with key %s but NO matching service-request-session set, queuing element for later use.\n"), GNUNET_h2s (&session->key)); |
1438 | // no matching session exists yet, store the response | 1433 | // no matching session exists yet, store the response |
1439 | // for later processing by handle_service_request() | 1434 | // for later processing by handle_service_request() |
1435 | } | ||
1440 | } | 1436 | } |
1437 | GNUNET_SERVER_receive_done (client, GNUNET_YES); | ||
1441 | } | 1438 | } |
1442 | 1439 | ||
1443 | 1440 | ||
@@ -1495,12 +1492,6 @@ tunnel_destruction_handler (void *cls, | |||
1495 | 1492 | ||
1496 | if ((FINALIZED != session->state) && (!do_shutdown)) | 1493 | if ((FINALIZED != session->state) && (!do_shutdown)) |
1497 | { | 1494 | { |
1498 | for (curr = from_client_head; NULL != curr; curr = curr->next) | ||
1499 | if (curr == session) | ||
1500 | { | ||
1501 | GNUNET_CONTAINER_DLL_remove (from_client_head, from_client_tail, session); | ||
1502 | break; | ||
1503 | } | ||
1504 | session->tunnel = NULL; | 1495 | session->tunnel = NULL; |
1505 | // if this happened before we received the answer, we must terminate the session | 1496 | // if this happened before we received the answer, we must terminate the session |
1506 | session->client_notification_task = | 1497 | session->client_notification_task = |