aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-01-24 16:14:59 +0000
committerBart Polot <bart@net.in.tum.de>2013-01-24 16:14:59 +0000
commitf4ab6f4d8addaa93b2dd18af393ac5b699013a9b (patch)
treee14ee97d382dc810563ab220ab7a54de32dd1b86 /src
parenta58a3da3dc252c661e7790f83ccf2386aa234a07 (diff)
downloadgnunet-f4ab6f4d8addaa93b2dd18af393ac5b699013a9b.tar.gz
gnunet-f4ab6f4d8addaa93b2dd18af393ac5b699013a9b.zip
- cosmetic changes
Diffstat (limited to 'src')
-rw-r--r--src/regex/gnunet-regex-profiler.c83
1 files changed, 43 insertions, 40 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c
index f0dc98c2f..86183a5fc 100644
--- a/src/regex/gnunet-regex-profiler.c
+++ b/src/regex/gnunet-regex-profiler.c
@@ -21,8 +21,8 @@
21/** 21/**
22 * @file mesh/gnunet-regex-profiler.c 22 * @file mesh/gnunet-regex-profiler.c
23 * @brief Regex profiler for testing distributed regex use. 23 * @brief Regex profiler for testing distributed regex use.
24 * @author Bart Polot 24 * @author Bartlomiej Polot
25 * @author Max Szengel 25 * @author Maximilian Szengel
26 * 26 *
27 */ 27 */
28 28
@@ -33,7 +33,6 @@
33#include "gnunet_util_lib.h" 33#include "gnunet_util_lib.h"
34#include "gnunet_regex_lib.h" 34#include "gnunet_regex_lib.h"
35#include "gnunet_dht_service.h" 35#include "gnunet_dht_service.h"
36// #include "gnunet_stream_lib.h"
37#include "gnunet_testbed_service.h" 36#include "gnunet_testbed_service.h"
38 37
39/** 38/**
@@ -393,12 +392,12 @@ static char * regex_prefix;
393 * @param put_path_length Length of the put_path. 392 * @param put_path_length Length of the put_path.
394 */ 393 */
395static void 394static void
396mesh_peer_connect_handler (void *cls, 395regex_found_handler (void *cls,
397 const struct GNUNET_PeerIdentity *id, 396 const struct GNUNET_PeerIdentity *id,
398 const struct GNUNET_PeerIdentity *get_path, 397 const struct GNUNET_PeerIdentity *get_path,
399 unsigned int get_path_length, 398 unsigned int get_path_length,
400 const struct GNUNET_PeerIdentity *put_path, 399 const struct GNUNET_PeerIdentity *put_path,
401 unsigned int put_path_length); 400 unsigned int put_path_length);
402 401
403 402
404/** 403/**
@@ -798,12 +797,12 @@ do_collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
798 * @param put_path_length Length of the put_path. 797 * @param put_path_length Length of the put_path.
799 */ 798 */
800static void 799static void
801mesh_peer_connect_handler (void *cls, 800regex_found_handler (void *cls,
802 const struct GNUNET_PeerIdentity *id, 801 const struct GNUNET_PeerIdentity *id,
803 const struct GNUNET_PeerIdentity *get_path, 802 const struct GNUNET_PeerIdentity *get_path,
804 unsigned int get_path_length, 803 unsigned int get_path_length,
805 const struct GNUNET_PeerIdentity *put_path, 804 const struct GNUNET_PeerIdentity *put_path,
806 unsigned int put_path_length) 805 unsigned int put_path_length)
807{ 806{
808 struct RegexPeer *peer = cls; 807 struct RegexPeer *peer = cls;
809 char output_buffer[512]; 808 char output_buffer[512];
@@ -811,9 +810,9 @@ mesh_peer_connect_handler (void *cls,
811 810
812 if (GNUNET_YES == peer->search_str_matched) 811 if (GNUNET_YES == peer->search_str_matched)
813 { 812 {
814 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 813 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
815 "String %s on peer %u already matched!\n", 814 "String %s on peer %u already matched!\n",
816 peer->search_str, peer->id); 815 peer->search_str, peer->id);
817 return; 816 return;
818 } 817 }
819 818
@@ -821,6 +820,7 @@ mesh_peer_connect_handler (void *cls,
821 820
822 if (NULL == id) 821 if (NULL == id)
823 { 822 {
823 // FIXME not possible right now
824 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 824 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
825 "String matching timed out for string %s on peer %u (%i/%i)\n", 825 "String matching timed out for string %s on peer %u (%i/%i)\n",
826 peer->search_str, peer->id, peers_found, num_search_strings); 826 peer->search_str, peer->id, peers_found, num_search_strings);
@@ -850,17 +850,16 @@ mesh_peer_connect_handler (void *cls,
850 size = 850 size =
851 GNUNET_snprintf (output_buffer, 851 GNUNET_snprintf (output_buffer,
852 sizeof (output_buffer), 852 sizeof (output_buffer),
853 "%p Peer: %u\n%p Host: %s\n%p Policy file: %s\n%p Search string: %s\n%p Search duration: %s\n\n", 853 "%p Peer: %u\n%p Host: %s\n%p Policy file: %s\n"
854 peer, 854 "%p Search string: %s\n%p Search duration: %s\n\n",
855 peer->id, 855 peer, peer->id,
856 peer, 856 peer,
857 GNUNET_TESTBED_host_get_hostname (peer->host_handle), 857 GNUNET_TESTBED_host_get_hostname (peer->host_handle),
858 peer, 858 peer, peer->policy_file,
859 peer->policy_file, 859 peer, peer->search_str,
860 peer, 860 peer,
861 peer->search_str, 861 GNUNET_STRINGS_relative_time_to_string (prof_time,
862 peer, 862 GNUNET_NO));
863 GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
864 863
865 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size)) 864 if (size != GNUNET_DISK_file_write (data_file, output_buffer, size))
866 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); 865 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
@@ -981,10 +980,10 @@ dht_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
981 GNUNET_assert (peer->dht_handle == ca_result); 980 GNUNET_assert (peer->dht_handle == ca_result);
982 981
983 peer->search_str_matched = GNUNET_NO; 982 peer->search_str_matched = GNUNET_NO;
984 peer->search_handle = 983 peer->search_handle = GNUNET_REGEX_search (peer->dht_handle,
985 GNUNET_REGEX_search (peer->dht_handle, peer->search_str, 984 peer->search_str,
986 &mesh_peer_connect_handler, NULL, 985 &regex_found_handler, NULL,
987 NULL); 986 NULL);
988 peer->prof_start_time = GNUNET_TIME_absolute_get (); 987 peer->prof_start_time = GNUNET_TIME_absolute_get ();
989 988
990 if (peer_cnt < (num_search_strings - 1)) 989 if (peer_cnt < (num_search_strings - 1))
@@ -998,18 +997,22 @@ dht_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
998 peers[next_p].search_str_matched = GNUNET_NO; 997 peers[next_p].search_str_matched = GNUNET_NO;
999 998
1000 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 999 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1001 "Searching for string \"%s\" on peer %d with file %s\n", 1000 "Searching for string \"%s\" on peer %d with file %s\n",
1002 peers[next_p].search_str, next_p, peers[next_p].policy_file); 1001 peers[next_p].search_str, next_p, peers[next_p].policy_file);
1003 1002
1003 /* FIXME
1004 * dont connect to a new dht for each peer, we might want to seach for n
1005 * strings on m peers where n > m
1006 */
1004 peers[next_p].dht_op_handle = 1007 peers[next_p].dht_op_handle =
1005 GNUNET_TESTBED_service_connect (NULL, 1008 GNUNET_TESTBED_service_connect (NULL,
1006 peers[next_p].peer_handle, 1009 peers[next_p].peer_handle,
1007 "dht", 1010 "dht",
1008 &dht_connect_cb, 1011 &dht_connect_cb,
1009 &peers[next_p], 1012 &peers[next_p],
1010 &dht_ca, 1013 &dht_ca,
1011 &dht_da, 1014 &dht_da,
1012 &peers[next_p]); 1015 &peers[next_p]);
1013 } 1016 }
1014} 1017}
1015 1018