aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r--src/transport/gnunet-service-transport.c65
1 files changed, 46 insertions, 19 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 83f54c0b9..445fb4315 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -798,24 +798,32 @@ try_alternative_plugins (struct NeighbourList *neighbour)
798 798
799 799
800/** 800/**
801 * Check the ready list for the given neighbour and 801 * The peer specified by the given neighbour has timed-out or a plugin
802 * if a plugin is ready for transmission (and if we 802 * has disconnected. We may either need to do nothing (other plugins
803 * have a message), do so! 803 * still up), or trigger a full disconnect and clean up. This
804 * function updates our state and do the necessary notifications.
805 * Also notifies our clients that the neighbour is now officially
806 * gone.
804 * 807 *
805 * @param neighbour target peer for which to check the plugins 808 * @param n the neighbour list entry for the peer
809 * @param check should we just check if all plugins
810 * disconnected or must we ask all plugins to
811 * disconnect?
806 */ 812 */
807static void try_transmission_to_peer (struct NeighbourList *neighbour); 813static void
814disconnect_neighbour (struct NeighbourList *n,
815 int check);
808 816
809 817
810/** 818/**
811 * The peer specified by the given neighbour has timed-out. Update 819 * Check the ready list for the given neighbour and
812 * our state and do the necessary notifications. Also notifies 820 * if a plugin is ready for transmission (and if we
813 * our clients that the neighbour is now officially gone. 821 * have a message), do so!
814 * 822 *
815 * @param n the neighbour list entry for the peer 823 * @param neighbour target peer for which to check the plugins
816 */ 824 */
817static void 825static void
818disconnect_neighbour (struct NeighbourList *n); 826try_transmission_to_peer (struct NeighbourList *neighbour);
819 827
820 828
821/** 829/**
@@ -868,6 +876,7 @@ transmit_send_continuation (void *cls,
868 "Transmission to peer `%s' failed, marking connection as down.\n", 876 "Transmission to peer `%s' failed, marking connection as down.\n",
869 GNUNET_i2s(target)); 877 GNUNET_i2s(target));
870 rl->connected = GNUNET_NO; 878 rl->connected = GNUNET_NO;
879 rl->plugin_handle = NULL;
871 } 880 }
872 if (!mq->internal_msg) 881 if (!mq->internal_msg)
873 rl->transmit_ready = GNUNET_YES; 882 rl->transmit_ready = GNUNET_YES;
@@ -889,8 +898,8 @@ transmit_send_continuation (void *cls,
889 another message (if available) */ 898 another message (if available) */
890 if (result == GNUNET_OK) 899 if (result == GNUNET_OK)
891 try_transmission_to_peer (n); 900 try_transmission_to_peer (n);
892 else 901 else
893 disconnect_neighbour (n); 902 disconnect_neighbour (n, GNUNET_YES);
894} 903}
895 904
896 905
@@ -1837,19 +1846,37 @@ process_hello (struct TransportPlugin *plugin,
1837 1846
1838 1847
1839/** 1848/**
1840 * The peer specified by the given neighbour has timed-out. Update 1849 * The peer specified by the given neighbour has timed-out or a plugin
1841 * our state and do the necessary notifications. Also notifies 1850 * has disconnected. We may either need to do nothing (other plugins
1842 * our clients that the neighbour is now officially gone. 1851 * still up), or trigger a full disconnect and clean up. This
1852 * function updates our state and do the necessary notifications.
1853 * Also notifies our clients that the neighbour is now officially
1854 * gone.
1843 * 1855 *
1844 * @param n the neighbour list entry for the peer 1856 * @param n the neighbour list entry for the peer
1857 * @param check should we just check if all plugins
1858 * disconnected or must we ask all plugins to
1859 * disconnect?
1845 */ 1860 */
1846static void 1861static void
1847disconnect_neighbour (struct NeighbourList *n) 1862disconnect_neighbour (struct NeighbourList *n,
1863 int check)
1848{ 1864{
1849 struct ReadyList *rpos; 1865 struct ReadyList *rpos;
1850 struct NeighbourList *npos; 1866 struct NeighbourList *npos;
1851 struct NeighbourList *nprev; 1867 struct NeighbourList *nprev;
1852 struct MessageQueue *mq; 1868 struct MessageQueue *mq;
1869
1870 if (GNUNET_YES == check)
1871 {
1872 rpos = n->plugins;
1873 while (NULL != rpos)
1874 {
1875 if (GNUNET_YES == rpos->connected)
1876 return; /* still connected */
1877 rpos = rpos->next;
1878 }
1879 }
1853 1880
1854#if DEBUG_TRANSPORT 1881#if DEBUG_TRANSPORT
1855 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, 1882 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
@@ -1945,7 +1972,7 @@ neighbour_timeout_task (void *cls,
1945 GNUNET_i2s(&n->id)); 1972 GNUNET_i2s(&n->id));
1946#endif 1973#endif
1947 n->timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; 1974 n->timeout_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK;
1948 disconnect_neighbour (n); 1975 disconnect_neighbour (n, GNUNET_NO);
1949} 1976}
1950 1977
1951 1978
@@ -2063,7 +2090,7 @@ plugin_env_receive (void *cls,
2063 service_context->connected = GNUNET_NO; 2090 service_context->connected = GNUNET_NO;
2064 service_context->plugin_handle = NULL; 2091 service_context->plugin_handle = NULL;
2065 } 2092 }
2066 disconnect_neighbour (n); 2093 disconnect_neighbour (n, GNUNET_YES);
2067 return NULL; 2094 return NULL;
2068 } 2095 }
2069#if DEBUG_TRANSPORT 2096#if DEBUG_TRANSPORT