diff options
Diffstat (limited to 'src/peerinfo/perf_peerinfo_api.c')
-rwxr-xr-x | src/peerinfo/perf_peerinfo_api.c | 83 |
1 files changed, 39 insertions, 44 deletions
diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c index 4f490671e..d0eadaf94 100755 --- a/src/peerinfo/perf_peerinfo_api.c +++ b/src/peerinfo/perf_peerinfo_api.c | |||
@@ -54,12 +54,9 @@ check_it (void *cls, | |||
54 | { | 54 | { |
55 | #if DEBUG | 55 | #if DEBUG |
56 | if (addrlen > 0) | 56 | if (addrlen > 0) |
57 | { | 57 | { |
58 | fprintf (stderr, | 58 | fprintf (stderr, "name: %s, addr: %s\n", tname, (const char *) addr); |
59 | "name: %s, addr: %s\n", | 59 | } |
60 | tname, | ||
61 | (const char*) addr); | ||
62 | } | ||
63 | #endif | 60 | #endif |
64 | return GNUNET_OK; | 61 | return GNUNET_OK; |
65 | } | 62 | } |
@@ -75,13 +72,12 @@ address_generator (void *cls, size_t max, void *buf) | |||
75 | if (*agc == 0) | 72 | if (*agc == 0) |
76 | return 0; | 73 | return 0; |
77 | 74 | ||
78 | GNUNET_asprintf(&address, "Address%d", *agc); | 75 | GNUNET_asprintf (&address, "Address%d", *agc); |
79 | 76 | ||
80 | ret = GNUNET_HELLO_add_address ("peerinfotest", | 77 | ret = GNUNET_HELLO_add_address ("peerinfotest", |
81 | GNUNET_TIME_relative_to_absolute | 78 | GNUNET_TIME_relative_to_absolute |
82 | (GNUNET_TIME_UNIT_HOURS), | 79 | (GNUNET_TIME_UNIT_HOURS), |
83 | address, strlen(address) + 1, | 80 | address, strlen (address) + 1, buf, max); |
84 | buf, max); | ||
85 | GNUNET_free (address); | 81 | GNUNET_free (address); |
86 | *agc = 0; | 82 | *agc = 0; |
87 | return ret; | 83 | return ret; |
@@ -106,53 +102,53 @@ add_peer (size_t i) | |||
106 | static void | 102 | static void |
107 | process (void *cls, | 103 | process (void *cls, |
108 | const struct GNUNET_PeerIdentity *peer, | 104 | const struct GNUNET_PeerIdentity *peer, |
109 | const struct GNUNET_HELLO_Message *hello, | 105 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) |
110 | const char * err_msg) | ||
111 | { | 106 | { |
112 | if (peer == NULL) | 107 | if (peer == NULL) |
113 | { | 108 | { |
114 | #if DEBUG | 109 | #if DEBUG |
115 | fprintf(stderr, "Process received NULL response\n"); | 110 | fprintf (stderr, "Process received NULL response\n"); |
116 | #endif | 111 | #endif |
117 | } | 112 | } |
118 | else | 113 | else |
119 | { | 114 | { |
120 | #if DEBUG | 115 | #if DEBUG |
121 | fprintf(stderr, "Processed a peer\n"); | 116 | fprintf (stderr, "Processed a peer\n"); |
122 | #endif | 117 | #endif |
123 | numpeers++; | 118 | numpeers++; |
124 | if (0 && (hello != NULL)) | 119 | if (0 && (hello != NULL)) |
125 | GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &check_it, NULL); | 120 | GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &check_it, NULL); |
126 | 121 | ||
127 | } | 122 | } |
128 | } | 123 | } |
129 | 124 | ||
130 | 125 | ||
131 | static void | 126 | static void |
132 | run (void *cls, | 127 | run (void *cls, |
133 | char *const *args, | 128 | char *const *args, |
134 | const char *cfgfile, | 129 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) |
135 | const struct GNUNET_CONFIGURATION_Handle *c) | ||
136 | { | 130 | { |
137 | size_t i; | 131 | size_t i; |
132 | |||
138 | cfg = c; | 133 | cfg = c; |
139 | h = GNUNET_PEERINFO_connect (cfg); | 134 | h = GNUNET_PEERINFO_connect (cfg); |
140 | GNUNET_assert (h != NULL); | 135 | GNUNET_assert (h != NULL); |
141 | for (i = 0; i < NUM_REQUESTS; i++) | 136 | for (i = 0; i < NUM_REQUESTS; i++) |
142 | { | 137 | { |
143 | add_peer (i); | 138 | add_peer (i); |
144 | ic[i] = GNUNET_PEERINFO_iterate (h, | 139 | ic[i] = GNUNET_PEERINFO_iterate (h, |
145 | NULL, | 140 | NULL, |
146 | GNUNET_TIME_relative_multiply | 141 | GNUNET_TIME_relative_multiply |
147 | (GNUNET_TIME_UNIT_SECONDS, 30), | 142 | (GNUNET_TIME_UNIT_SECONDS, 30), |
148 | &process, cls); | 143 | &process, cls); |
149 | } | 144 | } |
150 | } | 145 | } |
151 | 146 | ||
152 | static int | 147 | static int |
153 | check () | 148 | check () |
154 | { | 149 | { |
155 | int ok = 0; | 150 | int ok = 0; |
151 | |||
156 | char *const argv[] = { "perf-peerinfo-api", | 152 | char *const argv[] = { "perf-peerinfo-api", |
157 | "-c", | 153 | "-c", |
158 | "test_peerinfo_api_data.conf", | 154 | "test_peerinfo_api_data.conf", |
@@ -165,33 +161,32 @@ check () | |||
165 | }; | 161 | }; |
166 | #if START_SERVICE | 162 | #if START_SERVICE |
167 | struct GNUNET_OS_Process *proc; | 163 | struct GNUNET_OS_Process *proc; |
164 | |||
168 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 165 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
169 | GNUNET_GETOPT_OPTION_END | 166 | GNUNET_GETOPT_OPTION_END |
170 | }; | 167 | }; |
171 | proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo", | 168 | proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo", |
172 | "gnunet-service-peerinfo", | 169 | "gnunet-service-peerinfo", |
173 | #if DEBUG_PEERINFO | 170 | #if DEBUG_PEERINFO |
174 | "-L", "DEBUG", | 171 | "-L", "DEBUG", |
175 | #else | 172 | #else |
176 | "-L", "ERROR", | 173 | "-L", "ERROR", |
177 | #endif | 174 | #endif |
178 | "-c", "test_peerinfo_api_data.conf", NULL); | 175 | "-c", "test_peerinfo_api_data.conf", NULL); |
179 | #endif | 176 | #endif |
180 | GNUNET_assert (NULL != proc); | 177 | GNUNET_assert (NULL != proc); |
181 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 178 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, |
182 | argv, "perf-peerinfo-api", "nohelp", | 179 | argv, "perf-peerinfo-api", "nohelp", options, &run, &ok); |
183 | options, &run, &ok); | ||
184 | fprintf (stderr, | 180 | fprintf (stderr, |
185 | "Received %u/%u calls before timeout\n", | 181 | "Received %u/%u calls before timeout\n", |
186 | numpeers, | 182 | numpeers, NUM_REQUESTS * NUM_REQUESTS / 2); |
187 | NUM_REQUESTS * NUM_REQUESTS / 2); | ||
188 | GAUGER ("PEERINFO", "Peerinfo lookups", numpeers / 30, "peers/s"); | 183 | GAUGER ("PEERINFO", "Peerinfo lookups", numpeers / 30, "peers/s"); |
189 | #if START_SERVICE | 184 | #if START_SERVICE |
190 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | 185 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) |
191 | { | 186 | { |
192 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 187 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
193 | ok = 1; | 188 | ok = 1; |
194 | } | 189 | } |
195 | GNUNET_OS_process_wait (proc); | 190 | GNUNET_OS_process_wait (proc); |
196 | GNUNET_OS_process_close (proc); | 191 | GNUNET_OS_process_close (proc); |
197 | proc = NULL; | 192 | proc = NULL; |