summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-02 11:21:00 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-02 11:21:00 +0000
commit147d72a99e4ed0558c98fe7c9c41062ede51a68a (patch)
treef712c8aa222e53dc3e299972f3144ad92b15b180
parent8439fe12f24ab3ae5a1821face2b79d443fa044e (diff)
cleanup API for get_hello and get_hello_cancel
-rw-r--r--src/core/test_core_api.c11
-rw-r--r--src/core/test_core_api_preferences.c11
-rw-r--r--src/core/test_core_api_reliability.c11
-rw-r--r--src/core/test_core_quota_compliance.c11
-rw-r--r--src/dht/gnunet-service-dht.c13
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist.c5
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_reconnect.c5
-rw-r--r--src/include/gnunet_testing_lib.h9
-rw-r--r--src/include/gnunet_transport_service.h17
-rw-r--r--src/mesh/mesh_api.c2
-rw-r--r--src/nat/test_nat_test.c14
-rw-r--r--src/testing/testing.c35
-rw-r--r--src/transport/Makefile.am5
-rw-r--r--src/transport/gnunet-service-transport.c3
-rw-r--r--src/transport/gnunet-service-transport_validation.c4
-rw-r--r--src/transport/test_quota_compliance.c8
-rw-r--r--src/transport/test_transport_api_disconnect.c12
-rw-r--r--src/transport/transport-testing.c13
-rw-r--r--src/transport/transport-testing.h2
-rw-r--r--src/transport/transport_api.c56
20 files changed, 135 insertions, 112 deletions
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c
index 28805a372..894e4f642 100644
--- a/src/core/test_core_api.c
+++ b/src/core/test_core_api.c
@@ -46,6 +46,7 @@ struct PeerContext
struct GNUNET_CORE_Handle *ch;
struct GNUNET_PeerIdentity id;
struct GNUNET_TRANSPORT_Handle *th;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
struct GNUNET_MessageHeader *hello;
int connect_status;
#if START_ARM
@@ -91,8 +92,8 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_assert (ok == 6);
GNUNET_CORE_disconnect (p1.ch);
GNUNET_CORE_disconnect (p2.ch);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_TRANSPORT_disconnect (p2.th);
ok = 0;
@@ -118,13 +119,13 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
}
if (p1.th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
GNUNET_TRANSPORT_disconnect (p1.th);
p1.th = NULL;
}
if (p2.th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_TRANSPORT_disconnect (p2.th);
p2.th = NULL;
}
@@ -312,7 +313,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+ p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
diff --git a/src/core/test_core_api_preferences.c b/src/core/test_core_api_preferences.c
index 8bc977df2..d3364463a 100644
--- a/src/core/test_core_api_preferences.c
+++ b/src/core/test_core_api_preferences.c
@@ -43,6 +43,7 @@ struct PeerContext
struct GNUNET_CORE_Handle *ch;
struct GNUNET_PeerIdentity id;
struct GNUNET_TRANSPORT_Handle *th;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
struct GNUNET_MessageHeader *hello;
int connect_status;
#if START_ARM
@@ -86,8 +87,8 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
#endif
GNUNET_assert (ok == 6);
GNUNET_assert (NULL == irc);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_CORE_disconnect (p1.ch);
GNUNET_CORE_disconnect (p2.ch);
GNUNET_TRANSPORT_disconnect (p1.th);
@@ -119,8 +120,8 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_SCHEDULER_cancel (ask_task);
ask_task = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_CORE_disconnect (p1.ch);
GNUNET_CORE_disconnect (p2.ch);
GNUNET_TRANSPORT_disconnect (p1.th);
@@ -425,7 +426,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+ p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index 47d1ae8ac..ad6e6a761 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -74,6 +74,7 @@ struct PeerContext
struct GNUNET_PeerIdentity id;
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_MessageHeader *hello;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
int connect_status;
#if START_ARM
struct GNUNET_OS_Process *arm_proc;
@@ -121,8 +122,8 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
unsigned long long delta;
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_CORE_disconnect (p1.ch);
p1.ch = NULL;
GNUNET_CORE_disconnect (p2.ch);
@@ -156,13 +157,13 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
}
if (p1.th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
GNUNET_TRANSPORT_disconnect (p1.th);
p1.th = NULL;
}
if (p2.th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_TRANSPORT_disconnect (p2.th);
p2.th = NULL;
}
@@ -436,7 +437,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+ p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c
index 41d156c6b..d955e0fd0 100644
--- a/src/core/test_core_quota_compliance.c
+++ b/src/core/test_core_quota_compliance.c
@@ -81,6 +81,7 @@ struct PeerContext
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_MessageHeader *hello;
struct GNUNET_STATISTICS_Handle *stats;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
int connect_status;
#if START_ARM
struct GNUNET_OS_Process *arm_proc;
@@ -122,8 +123,8 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_CORE_Handle *ch;
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
ch = p1.ch;
p1.ch = NULL;
GNUNET_CORE_disconnect (ch);
@@ -147,8 +148,8 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (measure_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (measure_task);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_CORE_disconnect (p1.ch);
p1.ch = NULL;
@@ -563,7 +564,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
GNUNET_assert (p->stats != NULL);
p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+ p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index cbeecb5cc..b864e39e3 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -782,6 +782,10 @@ static struct GNUNET_DATACACHE_Handle *datacache;
*/
struct GNUNET_STATISTICS_Handle *stats;
+/**
+ * Handle to get our current HELLO.
+ */
+static struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
/**
* The configuration the DHT service is running with
@@ -5001,11 +5005,16 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
int bucket_count;
struct PeerInfo *pos;
+ if (NULL != ghh)
+ {
+ GNUNET_TRANSPORT_get_hello_cancel (ghh);
+ ghh = NULL;
+ }
if (transport_handle != NULL)
{
GNUNET_free_non_null (my_hello);
- GNUNET_TRANSPORT_get_hello_cancel (transport_handle, &process_hello, NULL);
GNUNET_TRANSPORT_disconnect (transport_handle);
+ transport_handle = NULL;
}
if (coreAPI != NULL)
{
@@ -5304,7 +5313,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
transport_handle =
GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL);
if (transport_handle != NULL)
- GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL);
+ ghh = GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL);
else
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to connect to transport service!\n");
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c
index 909b946e7..b6d0a1736 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist.c
@@ -46,6 +46,7 @@ struct PeerContext
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_MessageHeader *hello;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
#if START_ARM
struct GNUNET_OS_Process *arm_proc;
#endif
@@ -117,7 +118,7 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
{
struct PeerContext *p = cls;
- GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p);
+ GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received HELLO, starting hostlist service.\n");
}
@@ -140,7 +141,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
p->th =
GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, &notify_connect, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+ p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
index ff625cf8e..078c2a54e 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
@@ -47,6 +47,7 @@ struct PeerContext
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_MessageHeader *hello;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
#if START_ARM
struct GNUNET_OS_Process *arm_proc;
#endif
@@ -121,7 +122,7 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
{
struct PeerContext *p = cls;
- GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p);
+ GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received HELLO, starting hostlist service.\n");
}
@@ -144,7 +145,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
p->th =
GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, &notify_connect, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+ p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h
index 786522cdd..945a3900b 100644
--- a/src/include/gnunet_testing_lib.h
+++ b/src/include/gnunet_testing_lib.h
@@ -319,6 +319,11 @@ struct GNUNET_TESTING_Daemon
struct GNUNET_TRANSPORT_Handle *th;
/**
+ * Handle for getting HELLOs from transport
+ */
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
+
+ /**
* HELLO message for this peer
*/
struct GNUNET_HELLO_Message *hello;
@@ -723,7 +728,7 @@ GNUNET_TESTING_daemons_continue_startup (struct GNUNET_TESTING_PeerGroup *pg);
* @param cb function to call at the end
* @param cb_cls closure for cb
*/
-struct GNUNET_TESTING_ConnectContext *
+void /* struct GNUNET_TESTING_ConnectContext * */
GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
struct GNUNET_TESTING_Daemon *d2,
struct GNUNET_TIME_Relative timeout,
@@ -733,6 +738,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
void *cb_cls);
+#if 0
/**
* Cancel an attempt to connect two daemons.
*
@@ -741,6 +747,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
void
GNUNET_TESTING_daemons_connect_cancel (struct GNUNET_TESTING_ConnectContext
*cc);
+#endif
/**
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index e90acab4d..84a13ed68 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -573,13 +573,20 @@ typedef void (*GNUNET_TRANSPORT_HelloUpdateCallback) (void *cls,
/**
+ * Handle to cancel a 'GNUNET_TRANSPORT_get_hello' operation.
+ */
+struct GNUNET_TRANSPORT_GetHelloHandle;
+
+
+/**
* Obtain updates on changes to the HELLO message for this peer.
*
* @param handle connection to transport service
* @param rec function to call with the HELLO
* @param rec_cls closure for rec
+ * @return handle to cancel the operation, NULL on error
*/
-void
+struct GNUNET_TRANSPORT_GetHelloHandle *
GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
GNUNET_TRANSPORT_HelloUpdateCallback rec,
void *rec_cls);
@@ -588,14 +595,10 @@ GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
/**
* Stop receiving updates about changes to our HELLO message.
*
- * @param handle connection to transport service
- * @param rec function previously registered to be called with the HELLOs
- * @param rec_cls closure for rec
+ * @param ghh handle returned from 'GNUNET_TRANSPORT_get_hello')
*/
void
-GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_Handle *handle,
- GNUNET_TRANSPORT_HelloUpdateCallback rec,
- void *rec_cls);
+GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh);
/**
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c
index 615593621..8476be396 100644
--- a/src/mesh/mesh_api.c
+++ b/src/mesh/mesh_api.c
@@ -921,4 +921,4 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle)
GNUNET_free (handle);
}
-/* end of mesh_api.c */ \ No newline at end of file
+/* end of mesh_api.c */
diff --git a/src/nat/test_nat_test.c b/src/nat/test_nat_test.c
index 5a716bd8e..1b4d1bc1d 100644
--- a/src/nat/test_nat_test.c
+++ b/src/nat/test_nat_test.c
@@ -111,18 +111,14 @@ main (int argc, char *const argv[])
nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server");
if (GNUNET_NO == nat_res)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Cannot run NAT test: `%s' %s \n",
- "gnunet-nat-server",
- "SUID not set");
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Cannot run NAT test: `%s' %s \n",
+ "gnunet-nat-server", "SUID not set");
return 0;
}
- if (GNUNET_SYSERR == nat_res)
+ if (GNUNET_SYSERR == nat_res)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Cannot run NAT test: `%s' %s \n",
- "gnunet-nat-server",
- "file not found");
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Cannot run NAT test: `%s' %s \n",
+ "gnunet-nat-server", "file not found");
return 0;
}
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 3a712f071..5eaa0a12b 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -137,9 +137,9 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
{
return;
}
- if (daemon->th != NULL)
+ if (daemon->ghh != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (daemon->th, &process_hello, daemon);
+ GNUNET_TRANSPORT_get_hello_cancel (daemon->ghh);
}
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -246,7 +246,7 @@ testing_init (void *cls, struct GNUNET_CORE_Handle *server,
GNUNET_i2s (my_identity));
#endif
- GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
+ d->ghh = GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
/* wait some more */
if (d->task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (d->task);
@@ -706,7 +706,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_i2s (&d->id));
#endif
- GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
+ d->ghh = GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
GNUNET_SCHEDULER_add_now (&notify_daemon_started, d);
/*cb = d->cb;
* d->cb = NULL;
@@ -836,7 +836,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
("either `gnunet-arm' or `ssh' does not seem to terminate.\n"));
if (d->th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+ GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+ d->ghh = NULL;
GNUNET_TRANSPORT_disconnect (d->th);
d->th = NULL;
}
@@ -865,7 +866,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
("shutdown (either `gnunet-arm' or `ssh') did not complete cleanly.\n"));
if (d->th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+ GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+ d->ghh = NULL;
GNUNET_TRANSPORT_disconnect (d->th);
d->th = NULL;
}
@@ -896,7 +898,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
if (d->th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+ GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+ d->ghh = NULL;
GNUNET_TRANSPORT_disconnect (d->th);
d->th = NULL;
}
@@ -1473,7 +1476,8 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
if (d->th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+ GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+ d->ghh = NULL;
GNUNET_TRANSPORT_disconnect (d->th);
d->th = NULL;
}
@@ -1715,7 +1719,8 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
d->churn = GNUNET_YES;
if (d->th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+ GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+ d->ghh = NULL;
GNUNET_TRANSPORT_disconnect (d->th);
d->th = NULL;
}
@@ -2215,14 +2220,16 @@ reattempt_daemons_connect (void *cls,
ctx->d2->hello = NULL;
if (NULL != ctx->d2->th)
{
- GNUNET_TRANSPORT_get_hello_cancel (ctx->d2->th, &process_hello, ctx->d2);
+ GNUNET_TRANSPORT_get_hello_cancel (ctx->d2->ghh);
+ ctx->d2->ghh = NULL;
GNUNET_TRANSPORT_disconnect (ctx->d2->th);
}
ctx->d2->th =
GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL,
NULL);
GNUNET_assert (ctx->d2->th != NULL);
- GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
+ ctx->d2->ghh =
+ GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
}
if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL))
@@ -2240,7 +2247,8 @@ reattempt_daemons_connect (void *cls,
_("Failed to connect to transport service!\n"));
return;
}
- GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
+ ctx->d2->ghh =
+ GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
}
if (ctx->send_hello == GNUNET_YES)
@@ -2342,7 +2350,8 @@ core_initial_iteration (void *cls, const struct GNUNET_PeerIdentity *peer,
_("Failed to connect to transport service!\n"));
return;
}
- GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
+ ctx->d2->ghh =
+ GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
}
if (ctx->send_hello == GNUNET_YES)
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index bfe717958..c9bc8c440 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -69,7 +69,7 @@ noinst_PROGRAMS = $(WLAN_BIN_DUMMY)
lib_LTLIBRARIES = \
libgnunettransport.la \
libgnunettransporttesting.la
-
+
libgnunettransporttesting_la_SOURCES = \
transport-testing.c
libgnunettransporttesting_la_LIBADD = \
@@ -355,7 +355,6 @@ test_transport_api_disconnect_LDADD = \
$(top_builddir)/src/transport/libgnunettransport.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
test_transport_startonly_SOURCES = \
@@ -364,7 +363,6 @@ test_transport_startonly_LDADD = \
$(top_builddir)/src/transport/libgnunettransport.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/transport/libgnunettransporttesting.la
@@ -374,7 +372,6 @@ test_transport_ats_LDADD = -lm \
-lglpk \
$(top_builddir)/src/transport/libgnunettransport.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
test_transport_ats_multiple_peers_SOURCES = \
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 5bf3c4c77..74ff1749c 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -1616,7 +1616,8 @@ transmit_send_continuation (void *cls, const struct GNUNET_PeerIdentity *target,
if (n == NULL)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "transmit_send_continuation",
- "Neighbour `%s' no longer exists\n", GNUNET_i2s (&mq->neighbour_id));
+ "Neighbour `%s' no longer exists\n",
+ GNUNET_i2s (&mq->neighbour_id));
return;
}
if (mq->client != NULL)
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index a79803afc..654bf52b8 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -218,7 +218,7 @@ struct ValidationEntry
size_t addrlen;
/**
- * When passing the address in 'add_valid_peer_address', did we
+ * When passing the address in 'add_valid_peer_address', did we
* copy the address to the HELLO yet?
*/
int copied;
@@ -880,7 +880,7 @@ add_valid_peer_address (void *cls, size_t max, void *buf)
struct ValidationEntry *ve = cls;
if (GNUNET_YES == ve->copied)
- return 0; /* terminate */
+ return 0; /* terminate */
ve->copied = GNUNET_YES;
return GNUNET_HELLO_add_address (ve->transport_name, ve->valid_until,
ve->addr, ve->addrlen, buf, max);
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index 71332bf36..63bd7da02 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -601,8 +601,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
GNUNET_SCHEDULER_cancel (tct);
tct = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
if (is_asymmetric_send_constant == GNUNET_YES)
measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA);
else if (is_asymmetric_recv_constant == GNUNET_YES)
@@ -776,8 +776,8 @@ run (void *cls, char *const *args, const char *cfgfile,
GNUNET_assert (p1.th != NULL);
GNUNET_assert (p2.th != NULL);
- GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
- GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
+ p1.ghh = GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
+ p2.ghh = GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
}
diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c
index 540d3b729..a96a1a152 100644
--- a/src/transport/test_transport_api_disconnect.c
+++ b/src/transport/test_transport_api_disconnect.c
@@ -170,8 +170,8 @@ end_badly ()
}
else
{
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
}
GNUNET_TRANSPORT_disconnect (p1.th);
@@ -314,8 +314,8 @@ peers_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from Transport \n");
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
GNUNET_TRANSPORT_disconnect (p1.th);
p1.th = NULL;
@@ -358,8 +358,8 @@ peers_connect ()
GNUNET_assert (p1.th != NULL);
GNUNET_assert (p2.th != NULL);
- GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
- GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
+ p1.ghh = GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
+ p2.ghh = GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
}
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index 02bab07f4..e604c5961 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -34,7 +34,6 @@ struct ConnectingContext
GNUNET_SCHEDULER_TaskIdentifier tct;
GNUNET_TRANSPORT_TESTING_connect_cb cb;
void *cb_cls;
-
struct GNUNET_TRANSPORT_Handle *th_p1;
struct GNUNET_TRANSPORT_Handle *th_p2;
int p1_c;
@@ -73,8 +72,8 @@ notify_connect_internal (void *cls, const struct GNUNET_PeerIdentity *peer,
if ((cc->p2_c == GNUNET_YES) && (cc->p2_c == GNUNET_YES))
{
/* clean up */
- GNUNET_TRANSPORT_get_hello_cancel (cc->th_p2, &exchange_hello_last, cc);
- GNUNET_TRANSPORT_get_hello_cancel (cc->th_p1, &exchange_hello, cc);
+ GNUNET_TRANSPORT_get_hello_cancel (cc->p1->ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (cc->p2->ghh);
if (cc->tct != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (cc->tct);
@@ -315,8 +314,8 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct PeerContext *p1,
GNUNET_assert (cc->th_p1 != NULL);
GNUNET_assert (cc->th_p2 != NULL);
- GNUNET_TRANSPORT_get_hello (cc->th_p1, &exchange_hello, cc);
- GNUNET_TRANSPORT_get_hello (cc->th_p2, &exchange_hello_last, cc);
+ p1->ghh = GNUNET_TRANSPORT_get_hello (cc->th_p1, &exchange_hello, cc);
+ p2->ghh = GNUNET_TRANSPORT_get_hello (cc->th_p2, &exchange_hello_last, cc);
cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc);
return cc;
@@ -333,8 +332,8 @@ void GNUNET_TRANSPORT_TESTING_connect_peers_cancel
struct ConnectingContext *cc = ccr;
/* clean up */
- GNUNET_TRANSPORT_get_hello_cancel (cc->th_p2, &exchange_hello_last, cc);
- GNUNET_TRANSPORT_get_hello_cancel (cc->th_p1, &exchange_hello, cc);
+ GNUNET_TRANSPORT_get_hello_cancel (cc->p1->ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (cc->p2->ghh);
if (cc->tct != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (cc->tct);
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h
index 852f060e4..80eae3630 100644
--- a/src/transport/transport-testing.h
+++ b/src/transport/transport-testing.h
@@ -44,6 +44,8 @@ struct PeerContext
struct GNUNET_TRANSPORT_Handle *th;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
+
struct GNUNET_PeerIdentity id;
struct GNUNET_OS_Process *arm_proc;
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index a6d2fa0ba..bbfe1e63d 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -150,18 +150,23 @@ struct Neighbour
/**
* Linked list of functions to call whenever our HELLO is updated.
*/
-struct HelloWaitList
+struct GNUNET_TRANSPORT_GetHelloHandle
{
/**
* This is a doubly linked list.
*/
- struct HelloWaitList *next;
+ struct GNUNET_TRANSPORT_GetHelloHandle *next;
/**
* This is a doubly linked list.
*/
- struct HelloWaitList *prev;
+ struct GNUNET_TRANSPORT_GetHelloHandle *prev;
+
+ /**
+ * Transport handle.
+ */
+ struct GNUNET_TRANSPORT_Handle *handle;
/**
* Callback to call once we got our HELLO.
@@ -232,12 +237,12 @@ struct GNUNET_TRANSPORT_Handle
/**
* Linked list of pending requests for our HELLO.
*/
- struct HelloWaitList *hwl_head;
+ struct GNUNET_TRANSPORT_GetHelloHandle *hwl_head;
/**
* Linked list of pending requests for our HELLO.
*/
- struct HelloWaitList *hwl_tail;
+ struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail;
/**
* My configuration.
@@ -397,8 +402,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
const struct InboundMessage *im;
const struct GNUNET_MessageHeader *imm;
const struct SendOkMessage *okm;
- struct HelloWaitList *hwl;
- struct HelloWaitList *next_hwl;
+ struct GNUNET_TRANSPORT_GetHelloHandle *hwl;
+ struct GNUNET_TRANSPORT_GetHelloHandle *next_hwl;
struct Neighbour *n;
struct GNUNET_PeerIdentity me;
uint16_t size;
@@ -1189,50 +1194,39 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
* (handshake with transport service pending/failed).
* cost estimate will be 0.
* @param rec_cls closure for rec
+ * @return handle to cancel the operation, NULL on error
*/
-void
+struct GNUNET_TRANSPORT_GetHelloHandle *
GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
GNUNET_TRANSPORT_HelloUpdateCallback rec,
void *rec_cls)
{
- struct HelloWaitList *hwl;
+ struct GNUNET_TRANSPORT_GetHelloHandle *hwl;
- hwl = GNUNET_malloc (sizeof (struct HelloWaitList));
+ if (handle->my_hello == NULL)
+ return NULL;
+ hwl = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_GetHelloHandle));
hwl->rec = rec;
hwl->rec_cls = rec_cls;
+ hwl->handle = handle;
GNUNET_CONTAINER_DLL_insert (handle->hwl_head, handle->hwl_tail, hwl);
- if (handle->my_hello == NULL)
- return;
rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello);
+ return hwl;
}
/**
* Stop receiving updates about changes to our HELLO message.
*
- * @param handle connection to transport service
- * @param rec function previously registered to be called with the HELLOs
- * @param rec_cls closure for rec
+ * @param ghh handle to cancel
*/
void
-GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_Handle *handle,
- GNUNET_TRANSPORT_HelloUpdateCallback rec,
- void *rec_cls)
+GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh)
{
- struct HelloWaitList *pos;
+ struct GNUNET_TRANSPORT_Handle *handle = ghh->handle;
- pos = handle->hwl_head;
- while (pos != NULL)
- {
- if ((pos->rec == rec) && (pos->rec_cls == rec_cls))
- break;
- pos = pos->next;
- }
- GNUNET_break (pos != NULL);
- if (pos == NULL)
- return;
- GNUNET_CONTAINER_DLL_remove (handle->hwl_head, handle->hwl_tail, pos);
- GNUNET_free (pos);
+ GNUNET_CONTAINER_DLL_remove (handle->hwl_head, handle->hwl_tail, ghh);
+ GNUNET_free (ghh);
}