diff options
Diffstat (limited to 'src/dht/plugin_dhtlog_mysql_dump_load.c')
-rw-r--r-- | src/dht/plugin_dhtlog_mysql_dump_load.c | 638 |
1 files changed, 346 insertions, 292 deletions
diff --git a/src/dht/plugin_dhtlog_mysql_dump_load.c b/src/dht/plugin_dhtlog_mysql_dump_load.c index 956af6bdd..7c3f67942 100644 --- a/src/dht/plugin_dhtlog_mysql_dump_load.c +++ b/src/dht/plugin_dhtlog_mysql_dump_load.c | |||
@@ -69,7 +69,7 @@ FILE *dhtkey_outfile; | |||
69 | FILE *extended_topology_outfile; | 69 | FILE *extended_topology_outfile; |
70 | 70 | ||
71 | static char * | 71 | static char * |
72 | get_sql_time() | 72 | get_sql_time () |
73 | { | 73 | { |
74 | static char date[DATE_STR_SIZE]; | 74 | static char date[DATE_STR_SIZE]; |
75 | time_t timetmp; | 75 | time_t timetmp; |
@@ -97,13 +97,19 @@ int | |||
97 | add_topology (int num_connections) | 97 | add_topology (int num_connections) |
98 | { | 98 | { |
99 | int ret; | 99 | int ret; |
100 | |||
100 | if (outfile == NULL) | 101 | if (outfile == NULL) |
101 | return GNUNET_SYSERR; | 102 | return GNUNET_SYSERR; |
102 | 103 | ||
103 | ret = fprintf(outfile, "insert into topology (trialuid, date, connections) values (@temp_trial, \"%s\", %d);\n", get_sql_time(), num_connections); | 104 | ret = |
105 | fprintf (outfile, | ||
106 | "insert into topology (trialuid, date, connections) values (@temp_trial, \"%s\", %d);\n", | ||
107 | get_sql_time (), num_connections); | ||
104 | if (ret < 0) | 108 | if (ret < 0) |
105 | return GNUNET_SYSERR; | 109 | return GNUNET_SYSERR; |
106 | ret = fprintf(outfile, "select max(topology_uid) from topology into @temp_topology;\n"); | 110 | ret = |
111 | fprintf (outfile, | ||
112 | "select max(topology_uid) from topology into @temp_topology;\n"); | ||
107 | if (ret >= 0) | 113 | if (ret >= 0) |
108 | return GNUNET_OK; | 114 | return GNUNET_OK; |
109 | return GNUNET_SYSERR; | 115 | return GNUNET_SYSERR; |
@@ -117,13 +123,18 @@ add_topology (int num_connections) | |||
117 | * | 123 | * |
118 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 124 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
119 | */ | 125 | */ |
120 | int add_round (unsigned int round_type, unsigned int round_count) | 126 | int |
127 | add_round (unsigned int round_type, unsigned int round_count) | ||
121 | { | 128 | { |
122 | int ret; | 129 | int ret; |
130 | |||
123 | if (outfile == NULL) | 131 | if (outfile == NULL) |
124 | return GNUNET_SYSERR; | 132 | return GNUNET_SYSERR; |
125 | 133 | ||
126 | ret = fprintf(outfile, "insert into rounds (trialuid, round_type, round_count, starttime) values (@temp_trial, \"%u\", \"%u\", \"%s\");\n", round_type, round_count, get_sql_time()); | 134 | ret = |
135 | fprintf (outfile, | ||
136 | "insert into rounds (trialuid, round_type, round_count, starttime) values (@temp_trial, \"%u\", \"%u\", \"%s\");\n", | ||
137 | round_type, round_count, get_sql_time ()); | ||
127 | 138 | ||
128 | if (ret >= 0) | 139 | if (ret >= 0) |
129 | return GNUNET_OK; | 140 | return GNUNET_OK; |
@@ -142,15 +153,21 @@ int add_round (unsigned int round_type, unsigned int round_count) | |||
142 | * | 153 | * |
143 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 154 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
144 | */ | 155 | */ |
145 | int add_round_details (unsigned int round_type, unsigned int round_count, | 156 | int |
146 | unsigned int num_messages, unsigned int num_messages_succeeded) | 157 | add_round_details (unsigned int round_type, unsigned int round_count, |
158 | unsigned int num_messages, | ||
159 | unsigned int num_messages_succeeded) | ||
147 | { | 160 | { |
148 | int ret; | 161 | int ret; |
162 | |||
149 | if (outfile == NULL) | 163 | if (outfile == NULL) |
150 | return GNUNET_SYSERR; | 164 | return GNUNET_SYSERR; |
151 | 165 | ||
152 | ret = fprintf(outfile, "insert into processed_trial_rounds (trialuid, round_type, round_count, starttime, endtime, num_messages, num_messages_succeeded) values (@temp_trial, \"%u\", \"%u\", \"%s\", \"%s\", \"%u\", \"%u\");\n", | 166 | ret = |
153 | round_type, round_count, get_sql_time(), get_sql_time(), num_messages, num_messages_succeeded); | 167 | fprintf (outfile, |
168 | "insert into processed_trial_rounds (trialuid, round_type, round_count, starttime, endtime, num_messages, num_messages_succeeded) values (@temp_trial, \"%u\", \"%u\", \"%s\", \"%s\", \"%u\", \"%u\");\n", | ||
169 | round_type, round_count, get_sql_time (), get_sql_time (), | ||
170 | num_messages, num_messages_succeeded); | ||
154 | 171 | ||
155 | if (ret >= 0) | 172 | if (ret >= 0) |
156 | return GNUNET_OK; | 173 | return GNUNET_OK; |
@@ -166,16 +183,23 @@ int add_round_details (unsigned int round_type, unsigned int round_count, | |||
166 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 183 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
167 | */ | 184 | */ |
168 | int | 185 | int |
169 | add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second) | 186 | add_extended_topology (const struct GNUNET_PeerIdentity *first, |
187 | const struct GNUNET_PeerIdentity *second) | ||
170 | { | 188 | { |
171 | int ret; | 189 | int ret; |
190 | |||
172 | if (outfile == NULL) | 191 | if (outfile == NULL) |
173 | return GNUNET_SYSERR; | 192 | return GNUNET_SYSERR; |
174 | 193 | ||
175 | ret = fprintf(extended_topology_outfile, "insert into extended_topology (topology_uid, uid_first, uid_second) values (%u, %s,", topology_count, GNUNET_h2s_full(&first->hashPubKey)); | 194 | ret = |
195 | fprintf (extended_topology_outfile, | ||
196 | "insert into extended_topology (topology_uid, uid_first, uid_second) values (%u, %s,", | ||
197 | topology_count, GNUNET_h2s_full (&first->hashPubKey)); | ||
176 | if (ret < 0) | 198 | if (ret < 0) |
177 | return GNUNET_SYSERR; | 199 | return GNUNET_SYSERR; |
178 | ret = fprintf(extended_topology_outfile, "%s);\n", GNUNET_h2s_full(&second->hashPubKey)); | 200 | ret = |
201 | fprintf (extended_topology_outfile, "%s);\n", | ||
202 | GNUNET_h2s_full (&second->hashPubKey)); | ||
179 | 203 | ||
180 | if (ret >= 0) | 204 | if (ret >= 0) |
181 | return GNUNET_OK; | 205 | return GNUNET_OK; |
@@ -190,35 +214,46 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNU | |||
190 | * | 214 | * |
191 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 215 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
192 | */ | 216 | */ |
193 | int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | 217 | int |
218 | add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | ||
194 | { | 219 | { |
195 | int ret; | 220 | int ret; |
221 | |||
196 | if (outfile == NULL) | 222 | if (outfile == NULL) |
197 | return GNUNET_SYSERR; | 223 | return GNUNET_SYSERR; |
198 | 224 | ||
199 | ret = fprintf(outfile, "INSERT INTO trials " | 225 | ret = fprintf (outfile, "INSERT INTO trials " |
200 | "(starttime, other_trial_identifier, numnodes, topology," | 226 | "(starttime, other_trial_identifier, numnodes, topology," |
201 | "blacklist_topology, connect_topology, connect_topology_option," | 227 | "blacklist_topology, connect_topology, connect_topology_option," |
202 | "connect_topology_option_modifier, topology_percentage, topology_probability," | 228 | "connect_topology_option_modifier, topology_percentage, topology_probability," |
203 | "puts, gets, " | 229 | "puts, gets, " |
204 | "concurrent, settle_time, num_rounds, malicious_getters," | 230 | "concurrent, settle_time, num_rounds, malicious_getters," |
205 | "malicious_putters, malicious_droppers, malicious_get_frequency," | 231 | "malicious_putters, malicious_droppers, malicious_get_frequency," |
206 | "malicious_put_frequency, stop_closest, stop_found, strict_kademlia, " | 232 | "malicious_put_frequency, stop_closest, stop_found, strict_kademlia, " |
207 | "gets_succeeded, message) " | 233 | "gets_succeeded, message) " |
208 | "VALUES (\"%s\", %u, %u, %u, %u, %u, %u, %f, %f, %f, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, \"%s\");\n", | 234 | "VALUES (\"%s\", %u, %u, %u, %u, %u, %u, %f, %f, %f, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, \"%s\");\n", |
209 | get_sql_time(), trial_info->other_identifier, trial_info->num_nodes, trial_info->topology, | 235 | get_sql_time (), trial_info->other_identifier, |
210 | trial_info->blacklist_topology, trial_info->connect_topology, | 236 | trial_info->num_nodes, trial_info->topology, |
211 | trial_info->connect_topology_option, trial_info->connect_topology_option_modifier, | 237 | trial_info->blacklist_topology, trial_info->connect_topology, |
212 | trial_info->topology_percentage, trial_info->topology_probability, | 238 | trial_info->connect_topology_option, |
213 | trial_info->puts, trial_info->gets, trial_info->concurrent, trial_info->settle_time, | 239 | trial_info->connect_topology_option_modifier, |
214 | trial_info->num_rounds, trial_info->malicious_getters, trial_info->malicious_putters, | 240 | trial_info->topology_percentage, |
215 | trial_info->malicious_droppers, trial_info->malicious_get_frequency, trial_info->malicious_put_frequency, | 241 | trial_info->topology_probability, trial_info->puts, |
216 | trial_info->stop_closest, trial_info->stop_found, trial_info->strict_kademlia, trial_info->gets_succeeded, trial_info->message); | 242 | trial_info->gets, trial_info->concurrent, |
243 | trial_info->settle_time, trial_info->num_rounds, | ||
244 | trial_info->malicious_getters, trial_info->malicious_putters, | ||
245 | trial_info->malicious_droppers, | ||
246 | trial_info->malicious_get_frequency, | ||
247 | trial_info->malicious_put_frequency, trial_info->stop_closest, | ||
248 | trial_info->stop_found, trial_info->strict_kademlia, | ||
249 | trial_info->gets_succeeded, trial_info->message); | ||
217 | 250 | ||
218 | if (ret < 0) | 251 | if (ret < 0) |
219 | return GNUNET_SYSERR; | 252 | return GNUNET_SYSERR; |
220 | 253 | ||
221 | ret = fprintf(outfile, "SELECT MAX( trialuid ) FROM trials into @temp_trial;\n"); | 254 | ret = |
255 | fprintf (outfile, | ||
256 | "SELECT MAX( trialuid ) FROM trials into @temp_trial;\n"); | ||
222 | 257 | ||
223 | if (ret >= 0) | 258 | if (ret >= 0) |
224 | return GNUNET_OK; | 259 | return GNUNET_OK; |
@@ -239,14 +274,15 @@ int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | |||
239 | */ | 274 | */ |
240 | int | 275 | int |
241 | add_generic_stat (const struct GNUNET_PeerIdentity *peer, | 276 | add_generic_stat (const struct GNUNET_PeerIdentity *peer, |
242 | const char *name, | 277 | const char *name, const char *section, uint64_t value) |
243 | const char *section, uint64_t value) | ||
244 | { | 278 | { |
245 | if (outfile == NULL) | 279 | if (outfile == NULL) |
246 | return GNUNET_SYSERR; | 280 | return GNUNET_SYSERR; |
247 | 281 | ||
248 | if (peer != NULL) | 282 | if (peer != NULL) |
249 | fprintf(generic_stat_outfile, "TRIALUID\t%s\t%s\t%s\t%llu\n", GNUNET_h2s_full(&peer->hashPubKey), section, name, (unsigned long long)value); | 283 | fprintf (generic_stat_outfile, "TRIALUID\t%s\t%s\t%s\t%llu\n", |
284 | GNUNET_h2s_full (&peer->hashPubKey), section, name, | ||
285 | (unsigned long long) value); | ||
250 | 286 | ||
251 | return GNUNET_OK; | 287 | return GNUNET_OK; |
252 | } | 288 | } |
@@ -283,22 +319,25 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, | |||
283 | unsigned int data_inserts, unsigned int find_peer_requests, | 319 | unsigned int data_inserts, unsigned int find_peer_requests, |
284 | unsigned int find_peers_started, unsigned int gets_started, | 320 | unsigned int find_peers_started, unsigned int gets_started, |
285 | unsigned int puts_started, unsigned int find_peer_responses_received, | 321 | unsigned int puts_started, unsigned int find_peer_responses_received, |
286 | unsigned int get_responses_received, unsigned int find_peer_responses_sent, | 322 | unsigned int get_responses_received, |
323 | unsigned int find_peer_responses_sent, | ||
287 | unsigned int get_responses_sent) | 324 | unsigned int get_responses_sent) |
288 | { | 325 | { |
289 | int ret; | 326 | int ret; |
327 | |||
290 | if (outfile == NULL) | 328 | if (outfile == NULL) |
291 | return GNUNET_SYSERR; | 329 | return GNUNET_SYSERR; |
292 | 330 | ||
293 | if (peer != NULL) | 331 | if (peer != NULL) |
294 | ret = fprintf(stat_outfile, "TRIALUID\t%s\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\n", | 332 | ret = |
295 | GNUNET_h2s_full(&peer->hashPubKey), | 333 | fprintf (stat_outfile, |
296 | route_requests, route_forwards, result_requests, | 334 | "TRIALUID\t%s\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\n", |
297 | client_requests, result_forwards, gets, puts, | 335 | GNUNET_h2s_full (&peer->hashPubKey), route_requests, |
298 | data_inserts, find_peer_requests, find_peers_started, | 336 | route_forwards, result_requests, client_requests, |
299 | gets_started, puts_started, find_peer_responses_received, | 337 | result_forwards, gets, puts, data_inserts, find_peer_requests, |
300 | get_responses_received, find_peer_responses_sent, | 338 | find_peers_started, gets_started, puts_started, |
301 | get_responses_sent); | 339 | find_peer_responses_received, get_responses_received, |
340 | find_peer_responses_sent, get_responses_sent); | ||
302 | 341 | ||
303 | else | 342 | else |
304 | return GNUNET_SYSERR; | 343 | return GNUNET_SYSERR; |
@@ -308,6 +347,7 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, | |||
308 | else | 347 | else |
309 | return GNUNET_SYSERR; | 348 | return GNUNET_SYSERR; |
310 | } | 349 | } |
350 | |||
311 | /* | 351 | /* |
312 | * Inserts the specified dhtkey into the dhttests.dhtkeys table, | 352 | * Inserts the specified dhtkey into the dhttests.dhtkeys table, |
313 | * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid | 353 | * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid |
@@ -321,13 +361,14 @@ int | |||
321 | add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey) | 361 | add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey) |
322 | { | 362 | { |
323 | int ret; | 363 | int ret; |
364 | |||
324 | if (dhtkeyuid != NULL) | 365 | if (dhtkeyuid != NULL) |
325 | *dhtkeyuid = 0; | 366 | *dhtkeyuid = 0; |
326 | 367 | ||
327 | if ((dhtkey_outfile == NULL) || (dhtkey == NULL)) | 368 | if ((dhtkey_outfile == NULL) || (dhtkey == NULL)) |
328 | return GNUNET_SYSERR; | 369 | return GNUNET_SYSERR; |
329 | 370 | ||
330 | ret = fprintf(dhtkey_outfile, "TRIALUID\t%s\n", GNUNET_h2s_full(dhtkey)); | 371 | ret = fprintf (dhtkey_outfile, "TRIALUID\t%s\n", GNUNET_h2s_full (dhtkey)); |
331 | 372 | ||
332 | if (ret >= 0) | 373 | if (ret >= 0) |
333 | return GNUNET_OK; | 374 | return GNUNET_OK; |
@@ -344,15 +385,17 @@ add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey) | |||
344 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 385 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
345 | */ | 386 | */ |
346 | int | 387 | int |
347 | add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity * node) | 388 | add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity *node) |
348 | { | 389 | { |
349 | int ret; | 390 | int ret; |
350 | 391 | ||
351 | if ((node == NULL) || (node_outfile == NULL)) | 392 | if ((node == NULL) || (node_outfile == NULL)) |
352 | return GNUNET_SYSERR; | 393 | return GNUNET_SYSERR; |
353 | 394 | ||
354 | ret = fprintf(node_outfile, "TRIALUID\t%s\n", GNUNET_h2s_full(&node->hashPubKey)); | 395 | ret = |
355 | fflush(node_outfile); | 396 | fprintf (node_outfile, "TRIALUID\t%s\n", |
397 | GNUNET_h2s_full (&node->hashPubKey)); | ||
398 | fflush (node_outfile); | ||
356 | if (ret >= 0) | 399 | if (ret >= 0) |
357 | return GNUNET_OK; | 400 | return GNUNET_OK; |
358 | return GNUNET_SYSERR; | 401 | return GNUNET_SYSERR; |
@@ -373,8 +416,11 @@ update_trials (unsigned int gets_succeeded) | |||
373 | if (outfile == NULL) | 416 | if (outfile == NULL) |
374 | return GNUNET_SYSERR; | 417 | return GNUNET_SYSERR; |
375 | 418 | ||
376 | ret = fprintf(outfile, "update trials set endtime=\"%s\", gets_succeeded=%u where trialuid = @temp_trial;\n", get_sql_time(), gets_succeeded); | 419 | ret = |
377 | fflush(node_outfile); | 420 | fprintf (outfile, |
421 | "update trials set endtime=\"%s\", gets_succeeded=%u where trialuid = @temp_trial;\n", | ||
422 | get_sql_time (), gets_succeeded); | ||
423 | fflush (node_outfile); | ||
378 | if (ret >= 0) | 424 | if (ret >= 0) |
379 | return GNUNET_OK; | 425 | return GNUNET_OK; |
380 | else | 426 | else |
@@ -398,8 +444,11 @@ set_malicious (struct GNUNET_PeerIdentity *peer) | |||
398 | if (outfile == NULL) | 444 | if (outfile == NULL) |
399 | return GNUNET_SYSERR; | 445 | return GNUNET_SYSERR; |
400 | 446 | ||
401 | ret = fprintf(outfile, "update nodes set malicious_dropper = 1 where trialuid = @temp_trial and nodeid = \"%s\";\n", GNUNET_h2s_full(&peer->hashPubKey)); | 447 | ret = |
402 | fflush(node_outfile); | 448 | fprintf (outfile, |
449 | "update nodes set malicious_dropper = 1 where trialuid = @temp_trial and nodeid = \"%s\";\n", | ||
450 | GNUNET_h2s_full (&peer->hashPubKey)); | ||
451 | fflush (node_outfile); | ||
403 | if (ret >= 0) | 452 | if (ret >= 0) |
404 | return GNUNET_OK; | 453 | return GNUNET_OK; |
405 | else | 454 | else |
@@ -422,8 +471,11 @@ add_connections (unsigned int totalConnections) | |||
422 | if (outfile == NULL) | 471 | if (outfile == NULL) |
423 | return GNUNET_SYSERR; | 472 | return GNUNET_SYSERR; |
424 | 473 | ||
425 | ret = fprintf(outfile, "update trials set totalConnections = %u where trialuid = @temp_trial;\n", totalConnections); | 474 | ret = |
426 | fflush(node_outfile); | 475 | fprintf (outfile, |
476 | "update trials set totalConnections = %u where trialuid = @temp_trial;\n", | ||
477 | totalConnections); | ||
478 | fflush (node_outfile); | ||
427 | if (ret >= 0) | 479 | if (ret >= 0) |
428 | return GNUNET_OK; | 480 | return GNUNET_OK; |
429 | else | 481 | else |
@@ -442,10 +494,14 @@ int | |||
442 | update_topology (unsigned int connections) | 494 | update_topology (unsigned int connections) |
443 | { | 495 | { |
444 | int ret; | 496 | int ret; |
497 | |||
445 | if (outfile == NULL) | 498 | if (outfile == NULL) |
446 | return GNUNET_SYSERR; | 499 | return GNUNET_SYSERR; |
447 | 500 | ||
448 | ret = fprintf(outfile, "update topology set connections = %u where topology_uid = @temp_topology;\n", connections); | 501 | ret = |
502 | fprintf (outfile, | ||
503 | "update topology set connections = %u where topology_uid = @temp_topology;\n", | ||
504 | connections); | ||
449 | topology_count++; | 505 | topology_count++; |
450 | if (ret >= 0) | 506 | if (ret >= 0) |
451 | return GNUNET_OK; | 507 | return GNUNET_OK; |
@@ -469,7 +525,7 @@ update_topology (unsigned int connections) | |||
469 | int | 525 | int |
470 | add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, | 526 | add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, |
471 | unsigned int type, unsigned int hops, int succeeded, | 527 | unsigned int type, unsigned int hops, int succeeded, |
472 | const struct GNUNET_PeerIdentity * node, const GNUNET_HashCode * key) | 528 | const struct GNUNET_PeerIdentity *node, const GNUNET_HashCode * key) |
473 | { | 529 | { |
474 | int ret; | 530 | int ret; |
475 | 531 | ||
@@ -479,12 +535,15 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, | |||
479 | if (sqlqueryuid != NULL) | 535 | if (sqlqueryuid != NULL) |
480 | *sqlqueryuid = 0; | 536 | *sqlqueryuid = 0; |
481 | 537 | ||
482 | ret = fprintf(query_outfile, "TRIALUID\t%s\t", GNUNET_h2s_full(key)); | 538 | ret = fprintf (query_outfile, "TRIALUID\t%s\t", GNUNET_h2s_full (key)); |
483 | 539 | ||
484 | if (ret < 0) | 540 | if (ret < 0) |
485 | return GNUNET_SYSERR; | 541 | return GNUNET_SYSERR; |
486 | 542 | ||
487 | ret = fprintf(query_outfile, "%s\t%llu\t%u\t%u\t%u\t%s\n", GNUNET_h2s_full(&node->hashPubKey), queryid, type, hops, succeeded, get_sql_time()); | 543 | ret = |
544 | fprintf (query_outfile, "%s\t%llu\t%u\t%u\t%u\t%s\n", | ||
545 | GNUNET_h2s_full (&node->hashPubKey), queryid, type, hops, | ||
546 | succeeded, get_sql_time ()); | ||
488 | 547 | ||
489 | if (ret >= 0) | 548 | if (ret >= 0) |
490 | return GNUNET_OK; | 549 | return GNUNET_OK; |
@@ -510,9 +569,10 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, | |||
510 | int | 569 | int |
511 | add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, | 570 | add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, |
512 | unsigned int type, unsigned int hops, | 571 | unsigned int type, unsigned int hops, |
513 | int succeeded, const struct GNUNET_PeerIdentity * node, | 572 | int succeeded, const struct GNUNET_PeerIdentity *node, |
514 | const GNUNET_HashCode * key, const struct GNUNET_PeerIdentity * from_node, | 573 | const GNUNET_HashCode * key, |
515 | const struct GNUNET_PeerIdentity * to_node) | 574 | const struct GNUNET_PeerIdentity *from_node, |
575 | const struct GNUNET_PeerIdentity *to_node) | ||
516 | { | 576 | { |
517 | int ret; | 577 | int ret; |
518 | 578 | ||
@@ -522,24 +582,31 @@ add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, | |||
522 | if (sqlqueryuid != NULL) | 582 | if (sqlqueryuid != NULL) |
523 | *sqlqueryuid = 0; | 583 | *sqlqueryuid = 0; |
524 | 584 | ||
525 | ret = fprintf(route_outfile, "TRIALUID\t%s\t", GNUNET_h2s_full(key)); | 585 | ret = fprintf (route_outfile, "TRIALUID\t%s\t", GNUNET_h2s_full (key)); |
526 | if (ret < 0) | 586 | if (ret < 0) |
527 | return GNUNET_SYSERR; | 587 | return GNUNET_SYSERR; |
528 | 588 | ||
529 | ret = fprintf(route_outfile, "%s\t", GNUNET_h2s_full(&node->hashPubKey)); | 589 | ret = fprintf (route_outfile, "%s\t", GNUNET_h2s_full (&node->hashPubKey)); |
530 | if (ret < 0) | 590 | if (ret < 0) |
531 | return GNUNET_SYSERR; | 591 | return GNUNET_SYSERR; |
532 | if (from_node == NULL) | 592 | if (from_node == NULL) |
533 | ret = fprintf(route_outfile, "0\t"); | 593 | ret = fprintf (route_outfile, "0\t"); |
534 | else | 594 | else |
535 | ret = fprintf(route_outfile, "%s\t", GNUNET_h2s_full(&from_node->hashPubKey)); | 595 | ret = |
596 | fprintf (route_outfile, "%s\t", | ||
597 | GNUNET_h2s_full (&from_node->hashPubKey)); | ||
536 | if (ret < 0) | 598 | if (ret < 0) |
537 | return GNUNET_SYSERR; | 599 | return GNUNET_SYSERR; |
538 | 600 | ||
539 | if (to_node == NULL) | 601 | if (to_node == NULL) |
540 | ret = fprintf(route_outfile, "0\t%llu\t%u\t%u\t%d\n", queryid, type, hops, succeeded); | 602 | ret = |
603 | fprintf (route_outfile, "0\t%llu\t%u\t%u\t%d\n", queryid, type, hops, | ||
604 | succeeded); | ||
541 | else | 605 | else |
542 | ret = fprintf(route_outfile, "%s\t%llu\t%u\t%u\t%d\n", GNUNET_h2s_full(&to_node->hashPubKey), queryid, type, hops, succeeded); | 606 | ret = |
607 | fprintf (route_outfile, "%s\t%llu\t%u\t%u\t%d\n", | ||
608 | GNUNET_h2s_full (&to_node->hashPubKey), queryid, type, hops, | ||
609 | succeeded); | ||
543 | 610 | ||
544 | if (ret >= 0) | 611 | if (ret >= 0) |
545 | return GNUNET_OK; | 612 | return GNUNET_OK; |
@@ -555,7 +622,7 @@ add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, | |||
555 | * @return the handle to the server, or NULL on error | 622 | * @return the handle to the server, or NULL on error |
556 | */ | 623 | */ |
557 | void * | 624 | void * |
558 | libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls) | 625 | libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) |
559 | { | 626 | { |
560 | struct GNUNET_DHTLOG_Plugin *plugin = cls; | 627 | struct GNUNET_DHTLOG_Plugin *plugin = cls; |
561 | char *outfile_name; | 628 | char *outfile_name; |
@@ -566,287 +633,274 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls) | |||
566 | cfg = plugin->cfg; | 633 | cfg = plugin->cfg; |
567 | max_varchar_len = 255; | 634 | max_varchar_len = 255; |
568 | 635 | ||
569 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MySQL (DUMP) DHT Logger: initializing\n"); | 636 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
637 | "MySQL (DUMP) DHT Logger: initializing\n"); | ||
570 | 638 | ||
571 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, | 639 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, |
572 | "MYSQLDUMP", "PATH", | 640 | "MYSQLDUMP", "PATH", |
573 | &outfile_path)) | 641 | &outfile_path)) |
574 | { | 642 | { |
575 | outfile_path = GNUNET_strdup(""); | 643 | outfile_path = GNUNET_strdup (""); |
576 | } | 644 | } |
577 | 645 | ||
578 | GNUNET_asprintf (&outfile_name, | 646 | GNUNET_asprintf (&outfile_name, |
579 | "%s%s-%d", | 647 | "%s%s-%d", outfile_path, "mysqldump", getpid ()); |
580 | outfile_path, | ||
581 | "mysqldump", | ||
582 | getpid()); | ||
583 | 648 | ||
584 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 649 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
585 | 650 | ||
586 | if (fn == NULL) | 651 | if (fn == NULL) |
587 | { | 652 | { |
588 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); | 653 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
589 | GNUNET_free(outfile_path); | 654 | _("Failed to get full path for `%s'\n"), outfile_name); |
590 | GNUNET_free(outfile_name); | 655 | GNUNET_free (outfile_path); |
591 | return NULL; | 656 | GNUNET_free (outfile_name); |
592 | } | 657 | return NULL; |
593 | 658 | } | |
594 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | 659 | |
660 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | ||
595 | outfile = FOPEN (fn, "w"); | 661 | outfile = FOPEN (fn, "w"); |
596 | 662 | ||
597 | if (outfile == NULL) | 663 | if (outfile == NULL) |
598 | { | 664 | { |
599 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); | 665 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); |
600 | if (dirwarn) | 666 | if (dirwarn) |
601 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 667 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
602 | _("Failed to create or access directory for log file `%s'\n"), | 668 | _("Failed to create or access directory for log file `%s'\n"), |
603 | fn); | 669 | fn); |
604 | GNUNET_free(outfile_path); | 670 | GNUNET_free (outfile_path); |
605 | GNUNET_free(outfile_name); | 671 | GNUNET_free (outfile_name); |
606 | GNUNET_free (fn); | 672 | GNUNET_free (fn); |
607 | return NULL; | 673 | return NULL; |
608 | } | 674 | } |
609 | 675 | ||
610 | GNUNET_free(outfile_name); | 676 | GNUNET_free (outfile_name); |
611 | GNUNET_asprintf (&outfile_name, | 677 | GNUNET_asprintf (&outfile_name, |
612 | "%s%s-%d", | 678 | "%s%s-%d", outfile_path, "mysqldump_nodes", getpid ()); |
613 | outfile_path, | 679 | GNUNET_free (fn); |
614 | "mysqldump_nodes", | ||
615 | getpid()); | ||
616 | GNUNET_free(fn); | ||
617 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 680 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
618 | 681 | ||
619 | if (fn == NULL) | 682 | if (fn == NULL) |
620 | { | 683 | { |
621 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); | 684 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
622 | GNUNET_free(outfile_path); | 685 | _("Failed to get full path for `%s'\n"), outfile_name); |
623 | GNUNET_free(outfile_name); | 686 | GNUNET_free (outfile_path); |
624 | return NULL; | 687 | GNUNET_free (outfile_name); |
625 | } | 688 | return NULL; |
626 | 689 | } | |
627 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | 690 | |
691 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | ||
628 | node_outfile = FOPEN (fn, "w"); | 692 | node_outfile = FOPEN (fn, "w"); |
629 | 693 | ||
630 | if (node_outfile == NULL) | 694 | if (node_outfile == NULL) |
631 | { | 695 | { |
632 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); | 696 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); |
633 | if (dirwarn) | 697 | if (dirwarn) |
634 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 698 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
635 | _("Failed to create or access directory for log file `%s'\n"), | 699 | _("Failed to create or access directory for log file `%s'\n"), |
636 | fn); | 700 | fn); |
637 | GNUNET_free(outfile_path); | 701 | GNUNET_free (outfile_path); |
638 | GNUNET_free(outfile_name); | 702 | GNUNET_free (outfile_name); |
639 | GNUNET_free (fn); | 703 | GNUNET_free (fn); |
640 | return NULL; | 704 | return NULL; |
641 | } | 705 | } |
642 | 706 | ||
643 | GNUNET_free(outfile_name); | 707 | GNUNET_free (outfile_name); |
644 | GNUNET_asprintf (&outfile_name, | 708 | GNUNET_asprintf (&outfile_name, |
645 | "%s%s-%d", | 709 | "%s%s-%d", outfile_path, "mysqldump_routes", getpid ()); |
646 | outfile_path, | ||
647 | "mysqldump_routes", | ||
648 | getpid()); | ||
649 | 710 | ||
650 | GNUNET_free(fn); | 711 | GNUNET_free (fn); |
651 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 712 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
652 | 713 | ||
653 | if (fn == NULL) | 714 | if (fn == NULL) |
654 | { | 715 | { |
655 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); | 716 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
656 | GNUNET_free(outfile_path); | 717 | _("Failed to get full path for `%s'\n"), outfile_name); |
657 | GNUNET_free(outfile_name); | 718 | GNUNET_free (outfile_path); |
658 | return NULL; | 719 | GNUNET_free (outfile_name); |
659 | } | 720 | return NULL; |
660 | 721 | } | |
661 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | 722 | |
723 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | ||
662 | route_outfile = FOPEN (fn, "w"); | 724 | route_outfile = FOPEN (fn, "w"); |
663 | 725 | ||
664 | if (route_outfile == NULL) | 726 | if (route_outfile == NULL) |
665 | { | 727 | { |
666 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); | 728 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); |
667 | if (dirwarn) | 729 | if (dirwarn) |
668 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 730 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
669 | _("Failed to create or access directory for log file `%s'\n"), | 731 | _("Failed to create or access directory for log file `%s'\n"), |
670 | fn); | 732 | fn); |
671 | GNUNET_free(outfile_path); | 733 | GNUNET_free (outfile_path); |
672 | GNUNET_free(outfile_name); | 734 | GNUNET_free (outfile_name); |
673 | GNUNET_free (fn); | 735 | GNUNET_free (fn); |
674 | return NULL; | 736 | return NULL; |
675 | } | 737 | } |
676 | 738 | ||
677 | GNUNET_free(outfile_name); | 739 | GNUNET_free (outfile_name); |
678 | GNUNET_asprintf (&outfile_name, | 740 | GNUNET_asprintf (&outfile_name, |
679 | "%s%s-%d", | 741 | "%s%s-%d", outfile_path, "mysqldump_queries", getpid ()); |
680 | outfile_path, | ||
681 | "mysqldump_queries", | ||
682 | getpid()); | ||
683 | 742 | ||
684 | GNUNET_free(fn); | 743 | GNUNET_free (fn); |
685 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 744 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
686 | 745 | ||
687 | if (fn == NULL) | 746 | if (fn == NULL) |
688 | { | 747 | { |
689 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); | 748 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
690 | GNUNET_free(outfile_path); | 749 | _("Failed to get full path for `%s'\n"), outfile_name); |
691 | GNUNET_free(outfile_name); | 750 | GNUNET_free (outfile_path); |
692 | return NULL; | 751 | GNUNET_free (outfile_name); |
693 | } | 752 | return NULL; |
694 | 753 | } | |
695 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | 754 | |
755 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | ||
696 | query_outfile = FOPEN (fn, "w"); | 756 | query_outfile = FOPEN (fn, "w"); |
697 | 757 | ||
698 | if (query_outfile == NULL) | 758 | if (query_outfile == NULL) |
699 | { | 759 | { |
700 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); | 760 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); |
701 | if (dirwarn) | 761 | if (dirwarn) |
702 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 762 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
703 | _("Failed to create or access directory for log file `%s'\n"), | 763 | _("Failed to create or access directory for log file `%s'\n"), |
704 | fn); | 764 | fn); |
705 | GNUNET_free(outfile_path); | 765 | GNUNET_free (outfile_path); |
706 | GNUNET_free(outfile_name); | 766 | GNUNET_free (outfile_name); |
707 | GNUNET_free (fn); | 767 | GNUNET_free (fn); |
708 | return NULL; | 768 | return NULL; |
709 | } | 769 | } |
710 | 770 | ||
711 | GNUNET_free(outfile_name); | 771 | GNUNET_free (outfile_name); |
712 | GNUNET_asprintf (&outfile_name, | 772 | GNUNET_asprintf (&outfile_name, |
713 | "%s%s-%d", | 773 | "%s%s-%d", outfile_path, "mysqldump_stats", getpid ()); |
714 | outfile_path, | ||
715 | "mysqldump_stats", | ||
716 | getpid()); | ||
717 | 774 | ||
718 | GNUNET_free(fn); | 775 | GNUNET_free (fn); |
719 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 776 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
720 | 777 | ||
721 | if (fn == NULL) | 778 | if (fn == NULL) |
722 | { | 779 | { |
723 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); | 780 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
724 | GNUNET_free(outfile_path); | 781 | _("Failed to get full path for `%s'\n"), outfile_name); |
725 | GNUNET_free(outfile_name); | 782 | GNUNET_free (outfile_path); |
726 | return NULL; | 783 | GNUNET_free (outfile_name); |
727 | } | 784 | return NULL; |
728 | 785 | } | |
729 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | 786 | |
787 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | ||
730 | stat_outfile = FOPEN (fn, "w"); | 788 | stat_outfile = FOPEN (fn, "w"); |
731 | 789 | ||
732 | if (stat_outfile == NULL) | 790 | if (stat_outfile == NULL) |
733 | { | 791 | { |
734 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); | 792 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); |
735 | if (dirwarn) | 793 | if (dirwarn) |
736 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 794 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
737 | _("Failed to create or access directory for log file `%s'\n"), | 795 | _("Failed to create or access directory for log file `%s'\n"), |
738 | fn); | 796 | fn); |
739 | GNUNET_free(outfile_path); | 797 | GNUNET_free (outfile_path); |
740 | GNUNET_free(outfile_name); | 798 | GNUNET_free (outfile_name); |
741 | GNUNET_free (fn); | 799 | GNUNET_free (fn); |
742 | return NULL; | 800 | return NULL; |
743 | } | 801 | } |
744 | 802 | ||
745 | GNUNET_free(outfile_name); | 803 | GNUNET_free (outfile_name); |
746 | GNUNET_asprintf (&outfile_name, | 804 | GNUNET_asprintf (&outfile_name, |
747 | "%s%s-%d", | 805 | "%s%s-%d", |
748 | outfile_path, | 806 | outfile_path, "mysqldump_generic_stats", getpid ()); |
749 | "mysqldump_generic_stats", | 807 | GNUNET_free (fn); |
750 | getpid()); | ||
751 | GNUNET_free(fn); | ||
752 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 808 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
753 | 809 | ||
754 | if (fn == NULL) | 810 | if (fn == NULL) |
755 | { | 811 | { |
756 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); | 812 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
757 | GNUNET_free(outfile_path); | 813 | _("Failed to get full path for `%s'\n"), outfile_name); |
758 | GNUNET_free(outfile_name); | 814 | GNUNET_free (outfile_path); |
759 | return NULL; | 815 | GNUNET_free (outfile_name); |
760 | } | 816 | return NULL; |
761 | 817 | } | |
762 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | 818 | |
819 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | ||
763 | generic_stat_outfile = FOPEN (fn, "w"); | 820 | generic_stat_outfile = FOPEN (fn, "w"); |
764 | 821 | ||
765 | if (generic_stat_outfile == NULL) | 822 | if (generic_stat_outfile == NULL) |
766 | { | 823 | { |
767 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); | 824 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); |
768 | if (dirwarn) | 825 | if (dirwarn) |
769 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 826 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
770 | _("Failed to create or access directory for log file `%s'\n"), | 827 | _("Failed to create or access directory for log file `%s'\n"), |
771 | fn); | 828 | fn); |
772 | GNUNET_free(outfile_path); | 829 | GNUNET_free (outfile_path); |
773 | GNUNET_free(outfile_name); | 830 | GNUNET_free (outfile_name); |
774 | GNUNET_free (fn); | 831 | GNUNET_free (fn); |
775 | return NULL; | 832 | return NULL; |
776 | } | 833 | } |
777 | 834 | ||
778 | GNUNET_free(outfile_name); | 835 | GNUNET_free (outfile_name); |
779 | GNUNET_asprintf (&outfile_name, | 836 | GNUNET_asprintf (&outfile_name, |
780 | "%s%s-%d", | 837 | "%s%s-%d", outfile_path, "mysqldump_dhtkey", getpid ()); |
781 | outfile_path, | 838 | GNUNET_free (fn); |
782 | "mysqldump_dhtkey", | ||
783 | getpid()); | ||
784 | GNUNET_free(fn); | ||
785 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 839 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
786 | 840 | ||
787 | if (fn == NULL) | 841 | if (fn == NULL) |
788 | { | 842 | { |
789 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); | 843 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
790 | GNUNET_free(outfile_path); | 844 | _("Failed to get full path for `%s'\n"), outfile_name); |
791 | GNUNET_free(outfile_name); | 845 | GNUNET_free (outfile_path); |
792 | return NULL; | 846 | GNUNET_free (outfile_name); |
793 | } | 847 | return NULL; |
794 | 848 | } | |
795 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | 849 | |
850 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | ||
796 | dhtkey_outfile = FOPEN (fn, "w"); | 851 | dhtkey_outfile = FOPEN (fn, "w"); |
797 | 852 | ||
798 | if (dhtkey_outfile == NULL) | 853 | if (dhtkey_outfile == NULL) |
799 | { | 854 | { |
800 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); | 855 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); |
801 | if (dirwarn) | 856 | if (dirwarn) |
802 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 857 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
803 | _("Failed to create or access directory for log file `%s'\n"), | 858 | _("Failed to create or access directory for log file `%s'\n"), |
804 | fn); | 859 | fn); |
805 | GNUNET_free(outfile_path); | 860 | GNUNET_free (outfile_path); |
806 | GNUNET_free(outfile_name); | 861 | GNUNET_free (outfile_name); |
807 | GNUNET_free (fn); | 862 | GNUNET_free (fn); |
808 | return NULL; | 863 | return NULL; |
809 | } | 864 | } |
810 | 865 | ||
811 | GNUNET_free(outfile_name); | 866 | GNUNET_free (outfile_name); |
812 | GNUNET_asprintf (&outfile_name, | 867 | GNUNET_asprintf (&outfile_name, |
813 | "%s%s-%d", | 868 | "%s%s-%d", |
814 | outfile_path, | 869 | outfile_path, "mysqldump_extended_topology", getpid ()); |
815 | "mysqldump_extended_topology", | 870 | GNUNET_free (fn); |
816 | getpid()); | ||
817 | GNUNET_free(fn); | ||
818 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 871 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
819 | 872 | ||
820 | if (fn == NULL) | 873 | if (fn == NULL) |
821 | { | 874 | { |
822 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name); | 875 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
823 | GNUNET_free(outfile_path); | 876 | _("Failed to get full path for `%s'\n"), outfile_name); |
824 | GNUNET_free(outfile_name); | 877 | GNUNET_free (outfile_path); |
825 | return NULL; | 878 | GNUNET_free (outfile_name); |
826 | } | 879 | return NULL; |
827 | 880 | } | |
828 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | 881 | |
882 | dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); | ||
829 | extended_topology_outfile = FOPEN (fn, "w"); | 883 | extended_topology_outfile = FOPEN (fn, "w"); |
830 | 884 | ||
831 | if (extended_topology_outfile == NULL) | 885 | if (extended_topology_outfile == NULL) |
832 | { | 886 | { |
833 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); | 887 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); |
834 | if (dirwarn) | 888 | if (dirwarn) |
835 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 889 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
836 | _("Failed to create or access directory for log file `%s'\n"), | 890 | _("Failed to create or access directory for log file `%s'\n"), |
837 | fn); | 891 | fn); |
838 | GNUNET_free(outfile_path); | 892 | GNUNET_free (outfile_path); |
839 | GNUNET_free(outfile_name); | 893 | GNUNET_free (outfile_name); |
840 | GNUNET_free (fn); | 894 | GNUNET_free (fn); |
841 | return NULL; | 895 | return NULL; |
842 | } | 896 | } |
843 | 897 | ||
844 | GNUNET_free (outfile_path); | 898 | GNUNET_free (outfile_path); |
845 | GNUNET_free (outfile_name); | 899 | GNUNET_free (outfile_name); |
846 | GNUNET_free (fn); | 900 | GNUNET_free (fn); |
847 | 901 | ||
848 | GNUNET_assert(plugin->dhtlog_api == NULL); | 902 | GNUNET_assert (plugin->dhtlog_api == NULL); |
849 | plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle)); | 903 | plugin->dhtlog_api = GNUNET_malloc (sizeof (struct GNUNET_DHTLOG_Handle)); |
850 | plugin->dhtlog_api->insert_trial = &add_trial; | 904 | plugin->dhtlog_api->insert_trial = &add_trial; |
851 | plugin->dhtlog_api->insert_stat = &add_stat; | 905 | plugin->dhtlog_api->insert_stat = &add_stat; |
852 | plugin->dhtlog_api->insert_round = &add_round; | 906 | plugin->dhtlog_api->insert_round = &add_round; |
@@ -870,21 +924,21 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls) | |||
870 | * Shutdown the plugin. | 924 | * Shutdown the plugin. |
871 | */ | 925 | */ |
872 | void * | 926 | void * |
873 | libgnunet_plugin_dhtlog_mysql_dump_load_done (void * cls) | 927 | libgnunet_plugin_dhtlog_mysql_dump_load_done (void *cls) |
874 | { | 928 | { |
875 | struct GNUNET_DHTLOG_Handle *dhtlog_api = cls; | 929 | struct GNUNET_DHTLOG_Handle *dhtlog_api = cls; |
876 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 930 | |
877 | "MySQL DHT Logger: database shutdown\n"); | 931 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MySQL DHT Logger: database shutdown\n"); |
878 | GNUNET_assert(dhtlog_api != NULL); | 932 | GNUNET_assert (dhtlog_api != NULL); |
879 | 933 | ||
880 | fclose(outfile); | 934 | fclose (outfile); |
881 | fclose(node_outfile); | 935 | fclose (node_outfile); |
882 | fclose(query_outfile); | 936 | fclose (query_outfile); |
883 | fclose(route_outfile); | 937 | fclose (route_outfile); |
884 | fclose(stat_outfile); | 938 | fclose (stat_outfile); |
885 | fclose(generic_stat_outfile); | 939 | fclose (generic_stat_outfile); |
886 | fclose(extended_topology_outfile); | 940 | fclose (extended_topology_outfile); |
887 | GNUNET_free(dhtlog_api); | 941 | GNUNET_free (dhtlog_api); |
888 | return NULL; | 942 | return NULL; |
889 | } | 943 | } |
890 | 944 | ||