/*
This file is part of GNUnet.
- (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
+ (C) 2009-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
*/
#define TYPEMAP_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
+/**
+ * How often do we transmit our typemap on first attempt?
+ */
+#define TYPEMAP_FREQUENCY_FIRST GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+
/**
* Message ready for encryption. This struct is followed by the
*/
struct GSC_TypeMap *tmap;
- /**
- * At what time did we initially establish this session?
- * (currently unused, should be integrated with ATS in the
- * future...).
- */
- struct GNUNET_TIME_Absolute time_established;
-
/**
* Task to transmit corked messages with a delay.
*/
*/
int ready_to_transmit;
+ /**
+ * Is this the first time we're sending the typemap? If so,
+ * we want to send it a bit faster the second time. 0 if
+ * we are sending for the first time, 1 if not.
+ */
+ int first_typemap;
};
struct GNUNET_MessageHeader *hdr;
struct GNUNET_TIME_Relative delay;
- delay = TYPEMAP_FREQUENCY;
+ if (0 == session->first_typemap)
+ {
+ delay = TYPEMAP_FREQUENCY_FIRST;
+ session->first_typemap = 1;
+ }
+ else
+ {
+ delay = TYPEMAP_FREQUENCY;
+ }
/* randomize a bit to avoid spont. sync */
- delay.rel_value +=
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000);
+ delay.rel_value_us +=
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000 * 1000);
session->typemap_task =
GNUNET_SCHEDULER_add_delayed (delay, &transmit_typemap_task, session);
GNUNET_STATISTICS_update (GSC_stats,
session->tmap = GSC_TYPEMAP_create ();
session->peer = *peer;
session->kxinfo = kx;
- session->time_established = GNUNET_TIME_absolute_get ();
session->typemap_task =
GNUNET_SCHEDULER_add_now (&transmit_typemap_task, session);
GNUNET_assert (GNUNET_OK ==
* @return GNUNET_OK (continue to iterate)
*/
static int
-notify_client_about_session (void *cls, const GNUNET_HashCode * key,
+notify_client_about_session (void *cls, const struct GNUNET_HashCode * key,
void *value)
{
struct GSC_Client *client = cls;
{
pos = nxt;
nxt = pos->next;
- if ((pos->deadline.abs_value < now.abs_value) &&
+ if ((pos->deadline.abs_value_us < now.abs_value_us) &&
(GNUNET_YES != pos->was_solicited))
{
GNUNET_STATISTICS_update (GSC_stats,
now = GNUNET_TIME_absolute_get ();
if ((msize == 0) ||
((msize < GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE / 2) &&
- (min_deadline.abs_value > now.abs_value)))
+ (min_deadline.abs_value_us > now.abs_value_us)))
{
/* not enough ready yet, try to solicit more */
solicit_messages (session);
* @return always GNUNET_OK
*/
static int
-do_send_message (void *cls, const GNUNET_HashCode * key, void *value)
+do_send_message (void *cls, const struct GNUNET_HashCode * key, void *value)
{
const struct GNUNET_MessageHeader *hdr = cls;
struct Session *session = value;
*/
#include "core.h"
static int
-queue_connect_message (void *cls, const GNUNET_HashCode * key, void *value)
+queue_connect_message (void *cls, const struct GNUNET_HashCode * key, void *value)
{
struct GNUNET_SERVER_TransmitContext *tc = cls;
struct Session *session = value;
/* FIXME: code duplication with clients... */
cnm.header.size = htons (sizeof (struct ConnectNotifyMessage));
cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
- // FIXME: full ats...
- cnm.ats_count = htonl (0);
cnm.peer = session->peer;
GNUNET_SERVER_transmit_context_append_message (tc, &cnm.header);
return GNUNET_OK;
void
GSC_SESSIONS_init ()
{
- sessions = GNUNET_CONTAINER_multihashmap_create (128);
+ sessions = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
}
* @return GNUNET_OK (continue to iterate)
*/
static int
-free_session_helper (void *cls, const GNUNET_HashCode * key, void *value)
+free_session_helper (void *cls, const struct GNUNET_HashCode * key, void *value)
{
struct Session *session = value;
void
GSC_SESSIONS_done ()
{
- GNUNET_CONTAINER_multihashmap_iterate (sessions, &free_session_helper, NULL);
- GNUNET_CONTAINER_multihashmap_destroy (sessions);
- sessions = NULL;
+ if (NULL != sessions)
+ {
+ GNUNET_CONTAINER_multihashmap_iterate (sessions, &free_session_helper, NULL);
+ GNUNET_CONTAINER_multihashmap_destroy (sessions);
+ sessions = NULL;
+ }
}
/* end of gnunet-service-core_sessions.c */