diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-06-29 09:26:40 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-06-29 09:26:40 +0000 |
commit | 2265f50f2fa412d412fe239f44c0264b99d494d6 (patch) | |
tree | 4abf177ae7d3d006329da61cbc98d4553631c436 /src/transport/plugin_transport_http.c | |
parent | 65bd2954fccfb94b0ccc91eba559d73c2852f803 (diff) | |
download | gnunet-2265f50f2fa412d412fe239f44c0264b99d494d6.tar.gz gnunet-2265f50f2fa412d412fe239f44c0264b99d494d6.zip |
- fixed session code
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r-- | src/transport/plugin_transport_http.c | 82 |
1 files changed, 37 insertions, 45 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index d99f531b7..7d13960f0 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -1495,80 +1495,72 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1495 | struct Session *s = cls; | 1495 | struct Session *s = cls; |
1496 | 1496 | ||
1497 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1497 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
1498 | 1498 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
1499 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %p was idle for %llu, disconnecting\n", | 1499 | "Session %p was idle for %llu ms, disconnecting\n", |
1500 | s, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); | 1500 | s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); |
1501 | 1501 | ||
1502 | /* call session destroy function */ | 1502 | /* call session destroy function */ |
1503 | if (s->inbound == GNUNET_NO) | 1503 | if (s->inbound == GNUNET_NO) |
1504 | GNUNET_assert (GNUNET_OK == client_disconnect (s)); | 1504 | GNUNET_assert (GNUNET_OK == client_disconnect (s)); |
1505 | else | 1505 | else |
1506 | GNUNET_assert (GNUNET_OK == server_disconnect (s)); | 1506 | GNUNET_assert (GNUNET_OK == server_disconnect (s)); |
1507 | |||
1508 | } | 1507 | } |
1509 | 1508 | ||
1510 | 1509 | ||
1511 | /** | 1510 | /** |
1512 | * Start session timeout | 1511 | * Start session timeout |
1513 | */ | 1512 | */ |
1514 | static void | 1513 | static void |
1515 | start_session_timeout (struct Session *s) | 1514 | start_session_timeout (struct Session *s) |
1516 | { | 1515 | { |
1517 | GNUNET_assert (NULL != s); | 1516 | GNUNET_assert (NULL != s); |
1518 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == s->timeout_task); | 1517 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == s->timeout_task); |
1519 | 1518 | s->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | |
1520 | s->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | 1519 | &session_timeout, |
1521 | &session_timeout, | 1520 | s); |
1522 | s); | 1521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1523 | 1522 | "Timeout for session %p set to %llu ms\n", | |
1524 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout for session %p set to %llu\n", | 1523 | s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); |
1525 | s, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); | ||
1526 | } | 1524 | } |
1527 | 1525 | ||
1528 | 1526 | ||
1529 | /** | 1527 | /** |
1530 | * Increment session timeout due to activity | 1528 | * Increment session timeout due to activity |
1531 | */ | 1529 | */ |
1532 | static void | 1530 | static void |
1533 | reschedule_session_timeout (struct Session *s) | 1531 | reschedule_session_timeout (struct Session *s) |
1534 | { | 1532 | { |
1535 | GNUNET_assert (NULL != s); | 1533 | GNUNET_assert (NULL != s); |
1536 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != s->timeout_task); | 1534 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != s->timeout_task); |
1537 | 1535 | ||
1538 | GNUNET_SCHEDULER_cancel (s->timeout_task); | 1536 | GNUNET_SCHEDULER_cancel (s->timeout_task); |
1539 | s->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | 1537 | s->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, |
1540 | &session_timeout, | 1538 | &session_timeout, |
1541 | s); | 1539 | s); |
1542 | 1540 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
1543 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout rescheduled for session %p set to %llu\n", | 1541 | "Timeout rescheduled for session %p set to %llu ms\n", |
1544 | s, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); | 1542 | s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); |
1545 | } | 1543 | } |
1546 | 1544 | ||
1547 | 1545 | ||
1548 | /** | 1546 | /** |
1549 | * Cancel timeout | 1547 | * Cancel timeout |
1550 | */ | 1548 | */ |
1551 | static void | 1549 | static void |
1552 | stop_session_timeout (struct Session *s) | 1550 | stop_session_timeout (struct Session *s) |
1553 | { | 1551 | { |
1554 | GNUNET_assert (NULL != s); | 1552 | GNUNET_assert (NULL != s); |
1555 | 1553 | ||
1556 | if (GNUNET_SCHEDULER_NO_TASK != s->timeout_task) | 1554 | if (GNUNET_SCHEDULER_NO_TASK != s->timeout_task) |
1557 | { | 1555 | { |
1558 | GNUNET_SCHEDULER_cancel (s->timeout_task); | 1556 | GNUNET_SCHEDULER_cancel (s->timeout_task); |
1559 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1557 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
1560 | 1558 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
1561 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout rescheduled for session %p canceled\n", | 1559 | "Timeout stopped for session %p canceled\n", |
1562 | s, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); | 1560 | s, (unsigned long long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); |
1563 | } | 1561 | } |
1564 | else | ||
1565 | { | ||
1566 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout for session %p was not active\n", | ||
1567 | s); | ||
1568 | } | ||
1569 | } | 1562 | } |
1570 | 1563 | ||
1571 | |||
1572 | /** | 1564 | /** |
1573 | * Entry point for the plugin. | 1565 | * Entry point for the plugin. |
1574 | */ | 1566 | */ |