diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-08-22 17:35:24 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-08-22 17:35:24 +0000 |
commit | 6aae69bbb5a389a2e47478b46fa1d5620c2cfbcd (patch) | |
tree | 0c5fcbe071884d54d02b149483854152c314845b /src/mesh/gnunet-service-mesh.c | |
parent | f38f964610d4abe9e8b8aa8d20ce5bd6af67da15 (diff) | |
download | gnunet-6aae69bbb5a389a2e47478b46fa1d5620c2cfbcd.tar.gz gnunet-6aae69bbb5a389a2e47478b46fa1d5620c2cfbcd.zip |
Various changes, can't get indent to work
Diffstat (limited to 'src/mesh/gnunet-service-mesh.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 338def09a..a5c9b131a 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -55,7 +55,7 @@ | |||
55 | #include "mesh_protocol.h" | 55 | #include "mesh_protocol.h" |
56 | #include "gnunet_dht_service.h" | 56 | #include "gnunet_dht_service.h" |
57 | 57 | ||
58 | #define MESH_DEBUG 0 | 58 | #define MESH_DEBUG GNUNET_YES |
59 | 59 | ||
60 | #if MESH_DEBUG | 60 | #if MESH_DEBUG |
61 | /** | 61 | /** |
@@ -70,7 +70,7 @@ mesh_debug (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
70 | { | 70 | { |
71 | return; | 71 | return; |
72 | } | 72 | } |
73 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s", s); | 73 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: %s", s); |
74 | } | 74 | } |
75 | #endif | 75 | #endif |
76 | 76 | ||
@@ -462,6 +462,7 @@ GNUNET_SCHEDULER_TaskIdentifier announce_applications_task; | |||
462 | */ | 462 | */ |
463 | GNUNET_SCHEDULER_TaskIdentifier announce_id_task; | 463 | GNUNET_SCHEDULER_TaskIdentifier announce_id_task; |
464 | 464 | ||
465 | |||
465 | /******************************************************************************/ | 466 | /******************************************************************************/ |
466 | /****************** GENERAL HELPER FUNCTIONS ************************/ | 467 | /****************** GENERAL HELPER FUNCTIONS ************************/ |
467 | /******************************************************************************/ | 468 | /******************************************************************************/ |
@@ -818,7 +819,7 @@ announce_applications (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
818 | GNUNET_PEER_resolve (myid, &id); | 819 | GNUNET_PEER_resolve (myid, &id); |
819 | for (i = 0; i < n_applications; i++) | 820 | for (i = 0; i < n_applications; i++) |
820 | { | 821 | { |
821 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting PUT for app %d\n", | 822 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Starting PUT for app %d\n", |
822 | applications[i]); | 823 | applications[i]); |
823 | *p = htonl (applications[i]); | 824 | *p = htonl (applications[i]); |
824 | GNUNET_CRYPTO_hash (buffer, 12, &hash); | 825 | GNUNET_CRYPTO_hash (buffer, 12, &hash); |
@@ -829,7 +830,7 @@ announce_applications (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
829 | APP_ANNOUNCE_TIME), | 830 | APP_ANNOUNCE_TIME), |
830 | APP_ANNOUNCE_TIME, | 831 | APP_ANNOUNCE_TIME, |
831 | #if MESH_DEBUG | 832 | #if MESH_DEBUG |
832 | &mesh_debug, "DHT_put for app completed\n"); | 833 | &mesh_debug, "MESH: DHT_put for app completed\n"); |
833 | #else | 834 | #else |
834 | NULL, NULL); | 835 | NULL, NULL); |
835 | #endif | 836 | #endif |
@@ -909,7 +910,7 @@ send_core_create_path_for_peer (void *cls, size_t size, void *buf) | |||
909 | 910 | ||
910 | if (0 == size && NULL == buf) | 911 | if (0 == size && NULL == buf) |
911 | { | 912 | { |
912 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Retransmitting create path\n"); | 913 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Retransmitting create path\n"); |
913 | GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); | 914 | GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); |
914 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, | 915 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
915 | GNUNET_TIME_UNIT_FOREVER_REL, &id, | 916 | GNUNET_TIME_UNIT_FOREVER_REL, &id, |
@@ -1293,7 +1294,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1293 | struct MeshPeerInfo *orig_peer_info; | 1294 | struct MeshPeerInfo *orig_peer_info; |
1294 | struct MeshTunnel *t; | 1295 | struct MeshTunnel *t; |
1295 | 1296 | ||
1296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received a MESH path create msg\n"); | 1297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Received a MESH path create msg\n"); |
1297 | size = ntohs (message->size); | 1298 | size = ntohs (message->size); |
1298 | if (size < sizeof (struct GNUNET_MESH_ManipulatePath)) | 1299 | if (size < sizeof (struct GNUNET_MESH_ManipulatePath)) |
1299 | { | 1300 | { |
@@ -1324,7 +1325,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1324 | 1325 | ||
1325 | if (NULL == t) | 1326 | if (NULL == t) |
1326 | { | 1327 | { |
1327 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating tunnel\n"); | 1328 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Creating tunnel\n"); |
1328 | t = GNUNET_malloc (sizeof (struct MeshTunnel)); | 1329 | t = GNUNET_malloc (sizeof (struct MeshTunnel)); |
1329 | t->id.oid = GNUNET_PEER_intern (pi); | 1330 | t->id.oid = GNUNET_PEER_intern (pi); |
1330 | t->id.tid = tid; | 1331 | t->id.tid = tid; |
@@ -1993,7 +1994,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
1993 | unsigned int i; | 1994 | unsigned int i; |
1994 | unsigned int j; | 1995 | unsigned int j; |
1995 | 1996 | ||
1996 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "client disconnected\n"); | 1997 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: client disconnected\n"); |
1997 | c = clients; | 1998 | c = clients; |
1998 | while (NULL != c) | 1999 | while (NULL != c) |
1999 | { | 2000 | { |
@@ -2044,12 +2045,12 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
2044 | } | 2045 | } |
2045 | else | 2046 | else |
2046 | { | 2047 | { |
2047 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ... searching\n"); | 2048 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: ... searching\n"); |
2048 | c = c->next; | 2049 | c = c->next; |
2049 | } | 2050 | } |
2050 | } | 2051 | } |
2051 | 2052 | ||
2052 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " done!\n"); | 2053 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: done!\n"); |
2053 | return; | 2054 | return; |
2054 | } | 2055 | } |
2055 | 2056 | ||
@@ -2074,7 +2075,7 @@ handle_local_new_client (void *cls, struct GNUNET_SERVER_Client *client, | |||
2074 | uint16_t j; | 2075 | uint16_t j; |
2075 | int known; | 2076 | int known; |
2076 | 2077 | ||
2077 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "new client connected\n"); | 2078 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: new client connected\n"); |
2078 | /* Check data sanity */ | 2079 | /* Check data sanity */ |
2079 | size = ntohs (message->size) - sizeof (struct GNUNET_MESH_ClientConnect); | 2080 | size = ntohs (message->size) - sizeof (struct GNUNET_MESH_ClientConnect); |
2080 | cc_msg = (struct GNUNET_MESH_ClientConnect *) message; | 2081 | cc_msg = (struct GNUNET_MESH_ClientConnect *) message; |
@@ -2136,7 +2137,7 @@ handle_local_new_client (void *cls, struct GNUNET_SERVER_Client *client, | |||
2136 | } | 2137 | } |
2137 | } | 2138 | } |
2138 | } | 2139 | } |
2139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " client has %u+%u subscriptions\n", | 2140 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: client has %u+%u subscriptions\n", |
2140 | c->type_counter, c->app_counter); | 2141 | c->type_counter, c->app_counter); |
2141 | 2142 | ||
2142 | GNUNET_CONTAINER_DLL_insert (clients, clients_tail, c); | 2143 | GNUNET_CONTAINER_DLL_insert (clients, clients_tail, c); |
@@ -2704,7 +2705,7 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server, | |||
2704 | const struct GNUNET_PeerIdentity *identity, | 2705 | const struct GNUNET_PeerIdentity *identity, |
2705 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) | 2706 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) |
2706 | { | 2707 | { |
2707 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core init\n"); | 2708 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Core init\n"); |
2708 | core_handle = server; | 2709 | core_handle = server; |
2709 | myid = GNUNET_PEER_intern (identity); | 2710 | myid = GNUNET_PEER_intern (identity); |
2710 | announce_id_task = GNUNET_SCHEDULER_add_now (&announce_id, cls); | 2711 | announce_id_task = GNUNET_SCHEDULER_add_now (&announce_id, cls); |
@@ -2726,11 +2727,11 @@ core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2726 | struct MeshPeerInfo *peer_info; | 2727 | struct MeshPeerInfo *peer_info; |
2727 | struct MeshPath *path; | 2728 | struct MeshPath *path; |
2728 | 2729 | ||
2729 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer connected\n"); | 2730 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer connected\n"); |
2730 | peer_info = get_peer_info (peer); | 2731 | peer_info = get_peer_info (peer); |
2731 | if (myid == peer_info->id) | 2732 | if (myid == peer_info->id) |
2732 | { | 2733 | { |
2733 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " (self)\n"); | 2734 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n"); |
2734 | } | 2735 | } |
2735 | path = GNUNET_malloc (sizeof (struct MeshPath)); | 2736 | path = GNUNET_malloc (sizeof (struct MeshPath)); |
2736 | path->length = 2; | 2737 | path->length = 2; |
@@ -2753,7 +2754,7 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
2753 | struct MeshPeerInfo *pi; | 2754 | struct MeshPeerInfo *pi; |
2754 | unsigned int i; | 2755 | unsigned int i; |
2755 | 2756 | ||
2756 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer disconnected\n"); | 2757 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Peer disconnected\n"); |
2757 | pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); | 2758 | pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); |
2758 | if (!pi) | 2759 | if (!pi) |
2759 | { | 2760 | { |
@@ -2771,7 +2772,7 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
2771 | } | 2772 | } |
2772 | if (myid == pi->id) | 2773 | if (myid == pi->id) |
2773 | { | 2774 | { |
2774 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " (self)\n"); | 2775 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: (self)\n"); |
2775 | } | 2776 | } |
2776 | return; | 2777 | return; |
2777 | } | 2778 | } |
@@ -2790,7 +2791,7 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
2790 | static void | 2791 | static void |
2791 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 2792 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
2792 | { | 2793 | { |
2793 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shutting down\n"); | 2794 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: shutting down\n"); |
2794 | if (core_handle != NULL) | 2795 | if (core_handle != NULL) |
2795 | { | 2796 | { |
2796 | GNUNET_CORE_disconnect (core_handle); | 2797 | GNUNET_CORE_disconnect (core_handle); |
@@ -2806,7 +2807,11 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2806 | GNUNET_SERVER_notification_context_destroy (nc); | 2807 | GNUNET_SERVER_notification_context_destroy (nc); |
2807 | nc = NULL; | 2808 | nc = NULL; |
2808 | } | 2809 | } |
2809 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shut down\n"); | 2810 | if (0 != announce_id_task) { |
2811 | GNUNET_SCHEDULER_cancel(announce_id_task); | ||
2812 | announce_id_task = 0; | ||
2813 | } | ||
2814 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: shut down\n"); | ||
2810 | } | 2815 | } |
2811 | 2816 | ||
2812 | /** | 2817 | /** |
@@ -2820,7 +2825,7 @@ static void | |||
2820 | run (void *cls, struct GNUNET_SERVER_Handle *server, | 2825 | run (void *cls, struct GNUNET_SERVER_Handle *server, |
2821 | const struct GNUNET_CONFIGURATION_Handle *c) | 2826 | const struct GNUNET_CONFIGURATION_Handle *c) |
2822 | { | 2827 | { |
2823 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "starting to run\n"); | 2828 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: starting to run\n"); |
2824 | GNUNET_SERVER_add_handlers (server, plugin_handlers); | 2829 | GNUNET_SERVER_add_handlers (server, plugin_handlers); |
2825 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); | 2830 | GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); |
2826 | server_handle = server; | 2831 | server_handle = server; |
@@ -2868,7 +2873,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
2868 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 2873 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
2869 | NULL); | 2874 | NULL); |
2870 | 2875 | ||
2871 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "end of run()\n"); | 2876 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: end of run()\n"); |
2872 | } | 2877 | } |
2873 | 2878 | ||
2874 | /** | 2879 | /** |
@@ -2883,10 +2888,11 @@ main (int argc, char *const *argv) | |||
2883 | { | 2888 | { |
2884 | int ret; | 2889 | int ret; |
2885 | 2890 | ||
2891 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: main()\n"); | ||
2886 | ret = | 2892 | ret = |
2887 | (GNUNET_OK == | 2893 | (GNUNET_OK == |
2888 | GNUNET_SERVICE_run (argc, argv, "mesh", GNUNET_SERVICE_OPTION_NONE, &run, | 2894 | GNUNET_SERVICE_run (argc, argv, "mesh", GNUNET_SERVICE_OPTION_NONE, &run, |
2889 | NULL)) ? 0 : 1; | 2895 | NULL)) ? 0 : 1; |
2890 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "end of main()\n"); | 2896 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: main() END\n"); |
2891 | return ret; | 2897 | return ret; |
2892 | } | 2898 | } |