[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25974 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25974 - gnunet/src/transport |
Date: |
Fri, 1 Feb 2013 13:49:17 +0100 |
Author: harsha
Date: 2013-02-01 13:49:17 +0100 (Fri, 01 Feb 2013)
New Revision: 25974
Modified:
gnunet/src/transport/transport_api.c
Log:
GNUNET_TRANSPORT_get_hello() to call its callback asynchronously
Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c 2013-02-01 11:14:12 UTC (rev
25973)
+++ gnunet/src/transport/transport_api.c 2013-02-01 12:49:17 UTC (rev
25974)
@@ -181,6 +181,11 @@
GNUNET_TRANSPORT_HelloUpdateCallback rec;
/**
+ * Task for calling the HelloUpdateCallback when we already have a HELLO
+ */
+ GNUNET_SCHEDULER_TaskIdentifier notify_task;
+
+ /**
* Closure for rec.
*/
void *rec_cls;
@@ -1262,7 +1267,28 @@
return GNUNET_NO;
}
+
/**
+ * Task to call the HelloUpdateCallback of the GetHelloHandle
+ *
+ * @param cls the GetHelloHandle
+ * @param tc the scheduler task context
+ */
+static void
+call_hello_update_cb_async (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh = cls;
+
+ GNUNET_assert (NULL != ghh->handle->my_hello);
+ GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != ghh->notify_task);
+ ghh->notify_task = GNUNET_SCHEDULER_NO_TASK;
+ ghh->rec (ghh->rec_cls,
+ (const struct GNUNET_MessageHeader *) ghh->handle->my_hello);
+}
+
+
+/**
* Obtain the HELLO message for this peer.
*
* @param handle connection to transport service
@@ -1286,7 +1312,8 @@
hwl->handle = handle;
GNUNET_CONTAINER_DLL_insert (handle->hwl_head, handle->hwl_tail, hwl);
if (handle->my_hello != NULL)
- rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello);
+ hwl->notify_task = GNUNET_SCHEDULER_add_now (&call_hello_update_cb_async,
+ hwl);
return hwl;
}
@@ -1301,6 +1328,8 @@
{
struct GNUNET_TRANSPORT_Handle *handle = ghh->handle;
+ if (GNUNET_SCHEDULER_NO_TASK != ghh->notify_task)
+ GNUNET_SCHEDULER_cancel (ghh->notify_task);
GNUNET_CONTAINER_DLL_remove (handle->hwl_head, handle->hwl_tail, ghh);
GNUNET_free (ghh);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25974 - gnunet/src/transport,
gnunet <=