aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-02-03 19:34:30 +0000
committerNathan S. Evans <evans@in.tum.de>2010-02-03 19:34:30 +0000
commitebcb0910344d8a148cd2fac4015b548471cc62ee (patch)
treef4efa9849312a8283f92e96bdc8c1db0534644fe /src
parent4fe3386a587534dcfcb82ddf885a40ac93e603ca (diff)
downloadgnunet-ebcb0910344d8a148cd2fac4015b548471cc62ee.tar.gz
gnunet-ebcb0910344d8a148cd2fac4015b548471cc62ee.zip
some minor changes that made things not work, but other things still are keeping things from working now
Diffstat (limited to 'src')
-rw-r--r--src/core/gnunet-service-core.c92
1 files changed, 67 insertions, 25 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index a0e1fb1c7..3b617ed30 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -1744,7 +1744,7 @@ handle_client_send (void *cls,
1744 { 1744 {
1745#if DEBUG_CORE 1745#if DEBUG_CORE
1746 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1746 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1747 "Core received `%s' request for `%4s', will try to establish connection within %llu ms\n", 1747 "\n\n\nCore received `%s' request for `%4s', will try to establish connection within %llu ms\n\n\n",
1748 "SEND", 1748 "SEND",
1749 GNUNET_i2s (&sm->peer), 1749 GNUNET_i2s (&sm->peer),
1750 GNUNET_TIME_absolute_get_remaining 1750 GNUNET_TIME_absolute_get_remaining
@@ -1917,6 +1917,22 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = {
1917 1917
1918 1918
1919/** 1919/**
1920 * Task that will retry "send_key" if our previous attempt failed
1921 * to yield a PONG.
1922 */
1923static void
1924set_key_retry_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1925{
1926 struct Neighbour *n = cls;
1927
1928 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
1929 n->set_key_retry_frequency =
1930 GNUNET_TIME_relative_multiply (n->set_key_retry_frequency, 2);
1931 send_key (n);
1932}
1933
1934
1935/**
1920 * PEERINFO is giving us a HELLO for a peer. Add the public key to 1936 * PEERINFO is giving us a HELLO for a peer. Add the public key to
1921 * the neighbour's struct and retry send_key. Or, if we did not get a 1937 * the neighbour's struct and retry send_key. Or, if we did not get a
1922 * HELLO, just do nothing. 1938 * HELLO, just do nothing.
@@ -1936,11 +1952,36 @@ process_hello_retry_send_key (void *cls,
1936 1952
1937 if (peer == NULL) 1953 if (peer == NULL)
1938 { 1954 {
1955#if DEBUG_CORE
1956 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1957 "Entered process_hello_retry_send_key Peer is null!\n");
1958#endif
1939 n->pitr = NULL; 1959 n->pitr = NULL;
1960 if (n->public_key != NULL)
1961 send_key (n);
1962 else
1963 n->retry_set_key_task
1964 = GNUNET_SCHEDULER_add_delayed (sched,
1965 n->set_key_retry_frequency,
1966 &set_key_retry_task, n);
1940 return; 1967 return;
1941 } 1968 }
1969
1970#if DEBUG_CORE
1971 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1972 "process_hello_retry_send_key for peer %s\n",
1973 GNUNET_i2s (peer));
1974#endif
1942 if (n->public_key != NULL) 1975 if (n->public_key != NULL)
1943 return; 1976 {
1977#if DEBUG_CORE
1978 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1979 "already have public key for peer %s!! (so why are we here?)\n",
1980 GNUNET_i2s (peer));
1981#endif
1982 return;
1983 }
1984
1944#if DEBUG_CORE 1985#if DEBUG_CORE
1945 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1986 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1946 "Received new `%s' message for `%4s', initiating key exchange.\n", 1987 "Received new `%s' message for `%4s', initiating key exchange.\n",
@@ -1953,25 +1994,12 @@ process_hello_retry_send_key (void *cls,
1953 { 1994 {
1954 GNUNET_free (n->public_key); 1995 GNUNET_free (n->public_key);
1955 n->public_key = NULL; 1996 n->public_key = NULL;
1997#if DEBUG_CORE
1998 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1999 "GNUNET_HELLO_get_key returned awfully\n");
2000#endif
1956 return; 2001 return;
1957 } 2002 }
1958 send_key (n);
1959}
1960
1961
1962/**
1963 * Task that will retry "send_key" if our previous attempt failed
1964 * to yield a PONG.
1965 */
1966static void
1967set_key_retry_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1968{
1969 struct Neighbour *n = cls;
1970
1971 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
1972 n->set_key_retry_frequency =
1973 GNUNET_TIME_relative_multiply (n->set_key_retry_frequency, 2);
1974 send_key (n);
1975} 2003}
1976 2004
1977 2005
@@ -1990,7 +2018,15 @@ send_key (struct Neighbour *n)
1990 2018
1991 if ( (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) || 2019 if ( (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) ||
1992 (n->pitr != NULL) ) 2020 (n->pitr != NULL) )
1993 return; /* already in progress */ 2021 {
2022#if DEBUG_CORE
2023 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2024 "Key exchange in progress with `%4s'.\n",
2025 GNUNET_i2s (&n->peer));
2026#endif
2027 return; /* already in progress */
2028 }
2029
1994#if DEBUG_CORE 2030#if DEBUG_CORE
1995 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2031 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1996 "Asked to perform key exchange with `%4s'.\n", 2032 "Asked to perform key exchange with `%4s'.\n",
@@ -2001,15 +2037,16 @@ send_key (struct Neighbour *n)
2001 /* lookup n's public key, then try again */ 2037 /* lookup n's public key, then try again */
2002#if DEBUG_CORE 2038#if DEBUG_CORE
2003 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2039 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2004 "Lacking public key for `%4s', trying to obtain one.\n", 2040 "Lacking public key for `%4s', trying to obtain one (send_key).\n",
2005 GNUNET_i2s (&n->peer)); 2041 GNUNET_i2s (&n->peer));
2006#endif 2042#endif
2007 GNUNET_assert (n->pitr == NULL); 2043 GNUNET_assert (n->pitr == NULL);
2044 //sleep(10);
2008 n->pitr = GNUNET_PEERINFO_iterate (cfg, 2045 n->pitr = GNUNET_PEERINFO_iterate (cfg,
2009 sched, 2046 sched,
2010 &n->peer, 2047 &n->peer,
2011 0, 2048 0,
2012 GNUNET_TIME_UNIT_MINUTES, 2049 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20),
2013 &process_hello_retry_send_key, n); 2050 &process_hello_retry_send_key, n);
2014 return; 2051 return;
2015 } 2052 }
@@ -2266,7 +2303,7 @@ handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m)
2266 { 2303 {
2267#if DEBUG_CORE 2304#if DEBUG_CORE
2268 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2305 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2269 "Lacking public key for peer, trying to obtain one.\n"); 2306 "Lacking public key for peer, trying to obtain one (handle_set_key).\n");
2270#endif 2307#endif
2271 m_cpy = GNUNET_malloc (sizeof (struct SetKeyMessage)); 2308 m_cpy = GNUNET_malloc (sizeof (struct SetKeyMessage));
2272 memcpy (m_cpy, m, sizeof (struct SetKeyMessage)); 2309 memcpy (m_cpy, m, sizeof (struct SetKeyMessage));
@@ -2428,10 +2465,10 @@ handle_pong (struct Neighbour *n, const struct PingMessage *m)
2428 /* PONG malformed */ 2465 /* PONG malformed */
2429#if DEBUG_CORE 2466#if DEBUG_CORE
2430 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2467 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2431 "Received malfromed `%s' wanted sender `%4s' with challenge %u\n", 2468 "Received malformed `%s' wanted sender `%4s' with challenge %u\n",
2432 "PONG", GNUNET_i2s (&n->peer), n->ping_challenge); 2469 "PONG", GNUNET_i2s (&n->peer), n->ping_challenge);
2433 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2470 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2434 "Received malfromed `%s' received from `%4s' with challenge %u\n", 2471 "Received malformed `%s' received from `%4s' with challenge %u\n",
2435 "PONG", GNUNET_i2s (&t.target), ntohl (t.challenge)); 2472 "PONG", GNUNET_i2s (&t.target), ntohl (t.challenge));
2436#endif 2473#endif
2437 GNUNET_break_op (0); 2474 GNUNET_break_op (0);
@@ -2447,6 +2484,11 @@ handle_pong (struct Neighbour *n, const struct PingMessage *m)
2447 return; 2484 return;
2448 case PEER_STATE_KEY_RECEIVED: 2485 case PEER_STATE_KEY_RECEIVED:
2449 n->status = PEER_STATE_KEY_CONFIRMED; 2486 n->status = PEER_STATE_KEY_CONFIRMED;
2487#if DEBUG_CORE
2488 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2489 "Confirmed key via %s for peer %s\n",
2490 "PONG", GNUNET_i2s (&n->peer));
2491#endif
2450 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) 2492 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
2451 { 2493 {
2452 GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); 2494 GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task);