[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r29198 - gnunet/src/scalarproduct
From: |
gnunet |
Subject: |
[GNUnet-SVN] r29198 - gnunet/src/scalarproduct |
Date: |
Wed, 11 Sep 2013 14:20:04 +0200 |
Author: cfuchs
Date: 2013-09-11 14:20:03 +0200 (Wed, 11 Sep 2013)
New Revision: 29198
Modified:
gnunet/src/scalarproduct/gnunet-scalarproduct.c
gnunet/src/scalarproduct/scalarproduct.h
gnunet/src/scalarproduct/scalarproduct_api.c
Log:
added propper shutdown task to SP-client
fixed a logics mixup in the SP-API between alice's client and bob's
client-function
fixed a memory allocation bug in SP-API
adjusted message formats to use uint32_t instead of 16 for all element counts
and mask lengths
Modified: gnunet/src/scalarproduct/gnunet-scalarproduct.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-scalarproduct.c 2013-09-11 12:19:45 UTC
(rev 29197)
+++ gnunet/src/scalarproduct/gnunet-scalarproduct.c 2013-09-11 12:20:03 UTC
(rev 29198)
@@ -151,6 +151,18 @@
}
}
+/**
+ * Task run during shutdown.
+ *
+ * @param cls unused
+ * @param tc unused
+ */
+static void
+shutdown_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_SCALARPRODUCT_disconnect ();
+}
/**
* Main function that will be run by the scheduler.
@@ -310,6 +322,10 @@
(void
*) &closure)))
return;
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
+ &shutdown_task,
+ NULL);
+
ret = 0;
}
Modified: gnunet/src/scalarproduct/scalarproduct.h
===================================================================
--- gnunet/src/scalarproduct/scalarproduct.h 2013-09-11 12:19:45 UTC (rev
29197)
+++ gnunet/src/scalarproduct/scalarproduct.h 2013-09-11 12:20:03 UTC (rev
29198)
@@ -73,12 +73,12 @@
/**
* how many elements the vector in payload contains
*/
- uint16_t element_count GNUNET_PACKED;
+ uint32_t element_count GNUNET_PACKED;
/**
* how many bytes the mask has
*/
- uint16_t mask_length GNUNET_PACKED;
+ uint32_t mask_length GNUNET_PACKED;
/**
* the transaction/session key used to identify a session
@@ -108,12 +108,12 @@
/**
* how many bytes the mask has
*/
- uint16_t mask_length GNUNET_PACKED;
+ uint32_t mask_length GNUNET_PACKED;
/**
* the length of the publickey contained within this message
*/
- uint16_t pk_length GNUNET_PACKED;
+ uint32_t pk_length GNUNET_PACKED;
/**
* the transaction/session key used to identify a session
@@ -123,12 +123,12 @@
/**
* how many elements the vector in payload contains
*/
- uint16_t element_count GNUNET_PACKED;
+ uint32_t element_count GNUNET_PACKED;
/**
* how many elements are actually included after the mask was applied.
*/
- uint16_t used_element_count GNUNET_PACKED;
+ uint32_t used_element_count GNUNET_PACKED;
/**
* followed by mask | public_key | vector[used_element_count]
@@ -148,12 +148,12 @@
/**
* how many elements the vector in payload contains
*/
- uint16_t element_count GNUNET_PACKED;
+ uint32_t element_count GNUNET_PACKED;
/**
* how many elements are actually included after the mask was applied.
*/
- uint16_t used_element_count GNUNET_PACKED;
+ uint32_t used_element_count GNUNET_PACKED;
/**
* the transaction/session key used to identify a session
Modified: gnunet/src/scalarproduct/scalarproduct_api.c
===================================================================
--- gnunet/src/scalarproduct/scalarproduct_api.c 2013-09-11 12:19:45 UTC
(rev 29197)
+++ gnunet/src/scalarproduct/scalarproduct_api.c 2013-09-11 12:20:03 UTC
(rev 29198)
@@ -351,14 +351,14 @@
h->cont_status = cont;
h->cont_cls = cont_cls;
- h->response_proc = &process_result_message;
+ h->response_proc = &process_status_message;
h->cfg = cfg;
- h->msg = GNUNET_malloc (size);
memcpy (&h->key, key, sizeof (struct GNUNET_HashCode));
-
- msg = (struct GNUNET_SCALARPRODUCT_client_request*) h->msg;
+
+ msg = (struct GNUNET_SCALARPRODUCT_client_request*) GNUNET_malloc (size);
+ h->msg = msg;
msg->header.size = htons (size);
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE);
+ msg->header.type = htons (GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_BOB);
msg->element_count = htonl (element_count);
vector = (int32_t*) & msg[1];
@@ -444,16 +444,16 @@
h->cont_datum = cont;
h->cont_cls = cont_cls;
- h->response_proc = &process_status_message;
+ h->response_proc = &process_result_message;
h->cfg = cfg;
memcpy (&h->key, key, sizeof (struct GNUNET_HashCode));
-
+
msg = (struct GNUNET_SCALARPRODUCT_client_request*) GNUNET_malloc (size);
h->msg = msg;
msg->header.size = htons (size);
msg->header.type = htons (GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE);
- msg->element_count = htons (element_count);
- msg->mask_length = htons (mask_bytes);
+ msg->element_count = htonl (element_count);
+ msg->mask_length = htonl (mask_bytes);
vector = (int32_t*) & msg[1];
// copy each element over to the message
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r29198 - gnunet/src/scalarproduct,
gnunet <=