aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-02-05 15:22:13 +0000
committerNathan S. Evans <evans@in.tum.de>2010-02-05 15:22:13 +0000
commit3229140d0264b5e51b1f9d13354ee28dc6c9b683 (patch)
treecb5bcd57cd56cab288dc9558b27385ea773d57b1 /src
parent9e85aa70d212bfed69a33b436f3794947cc11968 (diff)
downloadgnunet-3229140d0264b5e51b1f9d13354ee28dc6c9b683.tar.gz
gnunet-3229140d0264b5e51b1f9d13354ee28dc6c9b683.zip
changes to continuations required change of state machine maintenance (or so I claim)
Diffstat (limited to 'src')
-rw-r--r--src/core/gnunet-service-core.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index 0150ec8f3..f86514a93 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -1508,6 +1508,21 @@ retry_plaintext_processing (void *cls,
1508 */ 1508 */
1509static void send_key (struct Neighbour *n); 1509static void send_key (struct Neighbour *n);
1510 1510
1511/**
1512 * Task that will retry "send_key" if our previous attempt failed
1513 * to yield a PONG.
1514 */
1515static void
1516set_key_retry_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1517{
1518 struct Neighbour *n = cls;
1519
1520 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
1521 n->set_key_retry_frequency =
1522 GNUNET_TIME_relative_multiply (n->set_key_retry_frequency, 2);
1523 send_key (n);
1524}
1525
1511 1526
1512/** 1527/**
1513 * Check if we have plaintext messages for the specified neighbour 1528 * Check if we have plaintext messages for the specified neighbour
@@ -1545,6 +1560,13 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
1545#endif 1560#endif
1546 return; 1561 return;
1547 case PEER_STATE_KEY_SENT: 1562 case PEER_STATE_KEY_SENT:
1563 if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK)
1564 {
1565 n->retry_set_key_task
1566 = GNUNET_SCHEDULER_add_delayed (sched,
1567 n->set_key_retry_frequency,
1568 &set_key_retry_task, n);
1569 }
1548 GNUNET_assert (n->retry_set_key_task != 1570 GNUNET_assert (n->retry_set_key_task !=
1549 GNUNET_SCHEDULER_NO_TASK); 1571 GNUNET_SCHEDULER_NO_TASK);
1550#if DEBUG_CORE 1572#if DEBUG_CORE
@@ -1554,6 +1576,13 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
1554#endif 1576#endif
1555 return; 1577 return;
1556 case PEER_STATE_KEY_RECEIVED: 1578 case PEER_STATE_KEY_RECEIVED:
1579 if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK)
1580 {
1581 n->retry_set_key_task
1582 = GNUNET_SCHEDULER_add_delayed (sched,
1583 n->set_key_retry_frequency,
1584 &set_key_retry_task, n);
1585 }
1557 GNUNET_assert (n->retry_set_key_task != 1586 GNUNET_assert (n->retry_set_key_task !=
1558 GNUNET_SCHEDULER_NO_TASK); 1587 GNUNET_SCHEDULER_NO_TASK);
1559#if DEBUG_CORE 1588#if DEBUG_CORE
@@ -1918,22 +1947,6 @@ static struct GNUNET_SERVER_MessageHandler handlers[] = {
1918 1947
1919 1948
1920/** 1949/**
1921 * Task that will retry "send_key" if our previous attempt failed
1922 * to yield a PONG.
1923 */
1924static void
1925set_key_retry_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1926{
1927 struct Neighbour *n = cls;
1928
1929 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
1930 n->set_key_retry_frequency =
1931 GNUNET_TIME_relative_multiply (n->set_key_retry_frequency, 2);
1932 send_key (n);
1933}
1934
1935
1936/**
1937 * PEERINFO is giving us a HELLO for a peer. Add the public key to 1950 * PEERINFO is giving us a HELLO for a peer. Add the public key to
1938 * the neighbour's struct and retry send_key. Or, if we did not get a 1951 * the neighbour's struct and retry send_key. Or, if we did not get a
1939 * HELLO, just do nothing. 1952 * HELLO, just do nothing.
@@ -1962,9 +1975,9 @@ process_hello_retry_send_key (void *cls,
1962 send_key (n); 1975 send_key (n);
1963 else 1976 else
1964 n->retry_set_key_task 1977 n->retry_set_key_task
1965 = GNUNET_SCHEDULER_add_delayed (sched, 1978 = GNUNET_SCHEDULER_add_delayed (sched,
1966 n->set_key_retry_frequency, 1979 n->set_key_retry_frequency,
1967 &set_key_retry_task, n); 1980 &set_key_retry_task, n);
1968 return; 1981 return;
1969 } 1982 }
1970 1983