diff options
Diffstat (limited to 'src/transport/gnunet-transport.c')
-rw-r--r-- | src/transport/gnunet-transport.c | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index c701970d1..28c4c84fb 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -701,6 +701,14 @@ process_validation_cb (void *cls, | |||
701 | { | 701 | { |
702 | if ((NULL == peer) && (NULL == address)) | 702 | if ((NULL == peer) && (NULL == address)) |
703 | { | 703 | { |
704 | if (monitor_validation) | ||
705 | { | ||
706 | FPRINTF (stdout, | ||
707 | "%s", | ||
708 | _("Monitor disconnected from transport service. Reconnecting.\n")); | ||
709 | return; | ||
710 | } | ||
711 | |||
704 | /* done */ | 712 | /* done */ |
705 | vic = NULL; | 713 | vic = NULL; |
706 | if (GNUNET_SCHEDULER_NO_TASK != end) | 714 | if (GNUNET_SCHEDULER_NO_TASK != end) |
@@ -851,6 +859,7 @@ transmit_data (void *cls, size_t size, void *buf) | |||
851 | return size; | 859 | return size; |
852 | } | 860 | } |
853 | 861 | ||
862 | |||
854 | /** | 863 | /** |
855 | * Function called to notify transport users that another | 864 | * Function called to notify transport users that another |
856 | * peer connected to us. | 865 | * peer connected to us. |
@@ -971,6 +980,7 @@ monitor_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
971 | _("Connected to"), GNUNET_i2s (peer), monitor_connect_counter); | 980 | _("Connected to"), GNUNET_i2s (peer), monitor_connect_counter); |
972 | } | 981 | } |
973 | 982 | ||
983 | |||
974 | /** | 984 | /** |
975 | * Function called to notify transport users that another | 985 | * Function called to notify transport users that another |
976 | * peer disconnected from us. | 986 | * peer disconnected from us. |
@@ -991,6 +1001,7 @@ monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
991 | _("Disconnected from"), GNUNET_i2s (peer), monitor_connect_counter); | 1001 | _("Disconnected from"), GNUNET_i2s (peer), monitor_connect_counter); |
992 | } | 1002 | } |
993 | 1003 | ||
1004 | |||
994 | /** | 1005 | /** |
995 | * Function called by the transport for each received message. | 1006 | * Function called by the transport for each received message. |
996 | * | 1007 | * |
@@ -999,8 +1010,9 @@ monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
999 | * @param message the message | 1010 | * @param message the message |
1000 | */ | 1011 | */ |
1001 | static void | 1012 | static void |
1002 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 1013 | notify_receive (void *cls, |
1003 | const struct GNUNET_MessageHeader *message) | 1014 | const struct GNUNET_PeerIdentity *peer, |
1015 | const struct GNUNET_MessageHeader *message) | ||
1004 | { | 1016 | { |
1005 | if (benchmark_receive) | 1017 | if (benchmark_receive) |
1006 | { | 1018 | { |
@@ -1140,7 +1152,6 @@ resolve_peer_address (const struct GNUNET_PeerIdentity *id, | |||
1140 | * NULL on disconnect or when done | 1152 | * NULL on disconnect or when done |
1141 | * @param state current state this peer is in | 1153 | * @param state current state this peer is in |
1142 | * @param state_timeout time out for the current state | 1154 | * @param state_timeout time out for the current state |
1143 | * | ||
1144 | */ | 1155 | */ |
1145 | static void | 1156 | static void |
1146 | process_peer_iteration_cb (void *cls, | 1157 | process_peer_iteration_cb (void *cls, |
@@ -1151,12 +1162,6 @@ process_peer_iteration_cb (void *cls, | |||
1151 | { | 1162 | { |
1152 | if (NULL == peer) | 1163 | if (NULL == peer) |
1153 | { | 1164 | { |
1154 | if (monitor_connections) | ||
1155 | { | ||
1156 | FPRINTF (stdout, | ||
1157 | _("Monitor disconnected from transport service. Reconnecting.\n")); | ||
1158 | return; | ||
1159 | } | ||
1160 | /* done */ | 1165 | /* done */ |
1161 | address_resolution_in_progress = GNUNET_NO; | 1166 | address_resolution_in_progress = GNUNET_NO; |
1162 | pic = NULL; | 1167 | pic = NULL; |
@@ -1166,13 +1171,14 @@ process_peer_iteration_cb (void *cls, | |||
1166 | return; | 1171 | return; |
1167 | } | 1172 | } |
1168 | 1173 | ||
1169 | if ((GNUNET_NO == iterate_all) && (GNUNET_NO == GNUNET_TRANSPORT_is_connected(state)) ) | 1174 | if ( (GNUNET_NO == iterate_all) && |
1175 | (GNUNET_NO == GNUNET_TRANSPORT_is_connected(state)) ) | ||
1170 | return; /* Display only connected peers */ | 1176 | return; /* Display only connected peers */ |
1171 | 1177 | ||
1172 | if (GNUNET_SCHEDULER_NO_TASK != op_timeout) | 1178 | if (GNUNET_SCHEDULER_NO_TASK != op_timeout) |
1173 | GNUNET_SCHEDULER_cancel (op_timeout); | 1179 | GNUNET_SCHEDULER_cancel (op_timeout); |
1174 | op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, | 1180 | op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, |
1175 | NULL ); | 1181 | NULL); |
1176 | 1182 | ||
1177 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1183 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1178 | "Received address for peer `%s': %s\n", | 1184 | "Received address for peer `%s': %s\n", |
@@ -1197,28 +1203,26 @@ process_peer_iteration_cb (void *cls, | |||
1197 | * | 1203 | * |
1198 | */ | 1204 | */ |
1199 | static void | 1205 | static void |
1200 | process_peer_monitoring_cb (void *cls, const struct GNUNET_PeerIdentity *peer, | 1206 | process_peer_monitoring_cb (void *cls, |
1201 | const struct GNUNET_HELLO_Address *address, | 1207 | const struct GNUNET_PeerIdentity *peer, |
1202 | enum GNUNET_TRANSPORT_PeerState state, | 1208 | const struct GNUNET_HELLO_Address *address, |
1203 | struct GNUNET_TIME_Absolute state_timeout) | 1209 | enum GNUNET_TRANSPORT_PeerState state, |
1210 | struct GNUNET_TIME_Absolute state_timeout) | ||
1204 | { | 1211 | { |
1205 | struct MonitoredPeer *m; | 1212 | struct MonitoredPeer *m; |
1206 | 1213 | ||
1207 | if (peer == NULL ) | 1214 | if (NULL == peer) |
1208 | { | 1215 | { |
1209 | /* done */ | 1216 | FPRINTF (stdout, |
1210 | address_resolution_in_progress = GNUNET_NO; | 1217 | "%s", |
1211 | pic = NULL; | 1218 | _("Monitor disconnected from transport service. Reconnecting.\n")); |
1212 | if (GNUNET_SCHEDULER_NO_TASK != end) | ||
1213 | GNUNET_SCHEDULER_cancel (end); | ||
1214 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL ); | ||
1215 | return; | 1219 | return; |
1216 | } | 1220 | } |
1217 | 1221 | ||
1218 | if (GNUNET_SCHEDULER_NO_TASK != op_timeout) | 1222 | if (GNUNET_SCHEDULER_NO_TASK != op_timeout) |
1219 | GNUNET_SCHEDULER_cancel (op_timeout); | 1223 | GNUNET_SCHEDULER_cancel (op_timeout); |
1220 | op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, | 1224 | op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, &operation_timeout, |
1221 | NULL ); | 1225 | NULL); |
1222 | 1226 | ||
1223 | if (NULL == (m = GNUNET_CONTAINER_multipeermap_get (monitored_peers, peer))) | 1227 | if (NULL == (m = GNUNET_CONTAINER_multipeermap_get (monitored_peers, peer))) |
1224 | { | 1228 | { |
@@ -1490,7 +1494,8 @@ testservice_task (void *cls, int result) | |||
1490 | { | 1494 | { |
1491 | monitor_connect_counter = 0; | 1495 | monitor_connect_counter = 0; |
1492 | handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, | 1496 | handle = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, |
1493 | &monitor_notify_connect, &monitor_notify_disconnect); | 1497 | &monitor_notify_connect, |
1498 | &monitor_notify_disconnect); | ||
1494 | if (NULL == handle) | 1499 | if (NULL == handle) |
1495 | { | 1500 | { |
1496 | FPRINTF (stderr, "%s", _("Failed to connect to transport service\n") ); | 1501 | FPRINTF (stderr, "%s", _("Failed to connect to transport service\n") ); |