[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16654 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16654 - gnunet/src/mesh |
Date: |
Wed, 31 Aug 2011 12:14:17 +0200 |
Author: toelke
Date: 2011-08-31 12:14:17 +0200 (Wed, 31 Aug 2011)
New Revision: 16654
Modified:
gnunet/src/mesh/mesh_api.c
Log:
send a hello-packet for the mesh regularily
Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c 2011-08-31 10:14:14 UTC (rev 16653)
+++ gnunet/src/mesh/mesh_api.c 2011-08-31 10:14:17 UTC (rev 16654)
@@ -112,6 +112,13 @@
struct GNUNET_TRANSPORT_ATS_Information atsi;
struct peer_list_element *next, *prev;
+
+ /* The handle that sends the hellos to this peer */
+ struct GNUNET_CORE_TransmitHandle *hello;
+
+ GNUNET_SCHEDULER_TaskIdentifier sched;
+
+ struct GNUNET_MESH_Handle *handle;
};
struct peer_list
@@ -191,7 +198,9 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending hello\n");
- struct GNUNET_MESH_Handle *handle = cls;
+ struct peer_list_element *element = cls;
+ struct GNUNET_MESH_Handle *handle = element->handle;
+ element->hello = NULL;
struct GNUNET_MessageHeader *hdr = buf;
size_t sent =
@@ -207,7 +216,25 @@
return sent;
}
+void schedule_hello_message(void* cls, const struct
GNUNET_SCHEDULER_TaskContext* tctx)
+{
+ struct peer_list_element *element = cls;
+ element->sched = GNUNET_SCHEDULER_NO_TASK;
+ if ((tctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
+ return;
+
+ if (element->hello == NULL)
+ element->hello = GNUNET_CORE_notify_transmit_ready (element->handle->core,
GNUNET_NO, 42,
+
GNUNET_TIME_UNIT_SECONDS, &element->peer,
+ sizeof (struct
GNUNET_MessageHeader) +
+
element->handle->hello_message_size,
+
&send_hello_message, element);
+
+ element->sched = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_MINUTES,
schedule_hello_message, cls);
+}
+
+
/**
* Core calls this if we are connected to a new peer.
*
@@ -223,18 +250,15 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Core tells us we are connected to peer %s\n", GNUNET_i2s
(peer));
- /* Send a hello to this peer */
- GNUNET_CORE_notify_transmit_ready (handle->core, GNUNET_NO, 42,
- GNUNET_TIME_UNIT_SECONDS, peer,
- sizeof (struct GNUNET_MessageHeader) +
- handle->hello_message_size,
- &send_hello_message, cls);
-
/* put the new peer into the list of connected peers */
struct peer_list_element *element =
GNUNET_malloc (sizeof (struct peer_list_element));
memcpy (&element->peer, peer, sizeof (struct GNUNET_PeerIdentity));
+ element->handle = handle;
+ /* Send a hello to this peer */
+ element->sched = GNUNET_SCHEDULER_add_now(schedule_hello_message, element);
+
if (NULL != atsi)
memcpy (&element->atsi, atsi,
sizeof (struct GNUNET_TRANSPORT_ATS_Information));
@@ -303,6 +327,8 @@
tail);
GNUNET_free (tail);
}
+ GNUNET_CORE_notify_transmit_ready_cancel(element->hello);
+ GNUNET_SCHEDULER_cancel(element->sched);
GNUNET_free (element);
}
@@ -859,6 +885,8 @@
tail);
GNUNET_free (tail);
}
+ GNUNET_CORE_notify_transmit_ready_cancel(element->hello);
+ GNUNET_SCHEDULER_cancel(element->sched);
GNUNET_free (element);
element = next;
}
@@ -884,4 +912,4 @@
GNUNET_free (handle);
}
-/* end of mesh_api.c */
\ No newline at end of file
+/* end of mesh_api.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16654 - gnunet/src/mesh,
gnunet <=