aboutsummaryrefslogtreecommitdiff
path: root/src/dht/plugin_dhtlog_mysql_dump.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-09-01 13:19:43 +0000
committerNathan S. Evans <evans@in.tum.de>2010-09-01 13:19:43 +0000
commit05186db103486d199c2dc9357264a265e9c33117 (patch)
treef0fba3bc564c59e9ef13de8fe44aa2181268c179 /src/dht/plugin_dhtlog_mysql_dump.c
parentc34548d2d6629269e689a9b2685df7e375a9c7a8 (diff)
downloadgnunet-05186db103486d199c2dc9357264a265e9c33117.tar.gz
gnunet-05186db103486d199c2dc9357264a265e9c33117.zip
klocwork fixes, dht routing changes (hopefully fixes)
Diffstat (limited to 'src/dht/plugin_dhtlog_mysql_dump.c')
-rw-r--r--src/dht/plugin_dhtlog_mysql_dump.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c
index 1965d1c80..21ddc238e 100644
--- a/src/dht/plugin_dhtlog_mysql_dump.c
+++ b/src/dht/plugin_dhtlog_mysql_dump.c
@@ -203,6 +203,8 @@ add_topology (int num_connections)
203 return GNUNET_SYSERR; 203 return GNUNET_SYSERR;
204 ret = fprintf(outfile, "execute insert_topology using " 204 ret = fprintf(outfile, "execute insert_topology using "
205 "@date, @num;\n"); 205 "@date, @num;\n");
206 if (ret < 0)
207 return GNUNET_SYSERR;
206 208
207 ret = fprintf(outfile, "execute select_topology;\n"); 209 ret = fprintf(outfile, "execute select_topology;\n");
208 210
@@ -324,7 +326,8 @@ int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned in
324 "@m_gets, @m_puts, @m_drops," 326 "@m_gets, @m_puts, @m_drops,"
325 "@m_g_f, @m_p_f, @s_c, @s_f," 327 "@m_g_f, @m_p_f, @s_c, @s_f,"
326 "@s_k, @g_s, @message;\n"); 328 "@s_k, @g_s, @message;\n");
327 329 if (ret < 0)
330 return GNUNET_SYSERR;
328 ret = fprintf(outfile, "execute select_trial;\n"); 331 ret = fprintf(outfile, "execute select_trial;\n");
329 332
330 if (ret >= 0) 333 if (ret >= 0)
@@ -357,6 +360,9 @@ add_generic_stat (const struct GNUNET_PeerIdentity *peer,
357 else 360 else
358 ret = fprintf(outfile, "set @temp_node = 0;\n"); 361 ret = fprintf(outfile, "set @temp_node = 0;\n");
359 362
363 if (ret < 0)
364 return GNUNET_SYSERR;
365
360 ret = fprintf(outfile, "set @temp_section = \"%s\", @temp_stat = \"%s\", @temp_value = %llu;\n", 366 ret = fprintf(outfile, "set @temp_section = \"%s\", @temp_stat = \"%s\", @temp_value = %llu;\n",
361 section, name, (unsigned long long)value); 367 section, name, (unsigned long long)value);
362 368
@@ -365,6 +371,8 @@ add_generic_stat (const struct GNUNET_PeerIdentity *peer,
365 371
366 ret = fprintf(outfile, "execute insert_generic_stat;\n"); 372 ret = fprintf(outfile, "execute insert_generic_stat;\n");
367 373
374 if (ret < 0)
375 return GNUNET_SYSERR;
368 return GNUNET_OK; 376 return GNUNET_OK;
369} 377}
370 378
@@ -411,6 +419,8 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests,
411 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_node;\n", GNUNET_h2s_full(&peer->hashPubKey)); 419 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_node;\n", GNUNET_h2s_full(&peer->hashPubKey));
412 else 420 else
413 ret = fprintf(outfile, "set @temp_node = 0;\n"); 421 ret = fprintf(outfile, "set @temp_node = 0;\n");
422 if (ret < 0)
423 return GNUNET_SYSERR;
414 424
415 ret = fprintf(outfile, "set @r_r = %u, @r_f = %u, @res_r = %u, @c_r = %u, " 425 ret = fprintf(outfile, "set @r_r = %u, @r_f = %u, @res_r = %u, @c_r = %u, "
416 "@res_f = %u, @gets = %u, @puts = %u, @d_i = %u, " 426 "@res_f = %u, @gets = %u, @puts = %u, @d_i = %u, "
@@ -431,7 +441,8 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests,
431 "@res_f, @gets, @puts, @d_i, " 441 "@res_f, @gets, @puts, @d_i, "
432 "@f_p_r, @f_p_s, @g_s, @p_s, " 442 "@f_p_r, @f_p_s, @g_s, @p_s, "
433 "@f_p_r_r, @g_r_r, @f_p_r_s, @g_r_s;\n"); 443 "@f_p_r_r, @g_r_r, @f_p_r_s, @g_r_s;\n");
434 444 if (ret < 0)
445 return GNUNET_SYSERR;
435 return GNUNET_OK; 446 return GNUNET_OK;
436} 447}
437/* 448/*
@@ -663,11 +674,17 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid,
663 else 674 else
664 ret = fprintf(outfile, "set @temp_dhtkey = 0;\n"); 675 ret = fprintf(outfile, "set @temp_dhtkey = 0;\n");
665 676
677 if (ret < 0)
678 return GNUNET_SYSERR;
679
666 if (node != NULL) 680 if (node != NULL)
667 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_node;\n", GNUNET_h2s_full(&node->hashPubKey)); 681 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_node;\n", GNUNET_h2s_full(&node->hashPubKey));
668 else 682 else
669 ret = fprintf(outfile, "set @temp_node = 0;\n"); 683 ret = fprintf(outfile, "set @temp_node = 0;\n");
670 684
685 if (ret < 0)
686 return GNUNET_SYSERR;
687
671 ret = fprintf(outfile, "set @qid = %llu, @type = %u, @hops = %u, @succ = %d;\n", queryid, type, hops, succeeded); 688 ret = fprintf(outfile, "set @qid = %llu, @type = %u, @hops = %u, @succ = %d;\n", queryid, type, hops, succeeded);
672 689
673 if (ret < 0) 690 if (ret < 0)
@@ -716,21 +733,33 @@ add_route (unsigned long long *sqlqueryuid, unsigned long long queryid,
716 else 733 else
717 ret = fprintf(outfile, "set @temp_dhtkey = 0;\n"); 734 ret = fprintf(outfile, "set @temp_dhtkey = 0;\n");
718 735
736 if (ret < 0)
737 return GNUNET_SYSERR;
738
719 if (node != NULL) 739 if (node != NULL)
720 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_node;\n", GNUNET_h2s_full(&node->hashPubKey)); 740 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_node;\n", GNUNET_h2s_full(&node->hashPubKey));
721 else 741 else
722 ret = fprintf(outfile, "set @temp_node = 0;\n"); 742 ret = fprintf(outfile, "set @temp_node = 0;\n");
723 743
744 if (ret < 0)
745 return GNUNET_SYSERR;
746
724 if (from_node != NULL) 747 if (from_node != NULL)
725 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_from_node;\n", GNUNET_h2s_full(&from_node->hashPubKey)); 748 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_from_node;\n", GNUNET_h2s_full(&from_node->hashPubKey));
726 else 749 else
727 ret = fprintf(outfile, "set @temp_from_node = 0;\n"); 750 ret = fprintf(outfile, "set @temp_from_node = 0;\n");
728 751
752 if (ret < 0)
753 return GNUNET_SYSERR;
754
729 if (to_node != NULL) 755 if (to_node != NULL)
730 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_to_node;\n", GNUNET_h2s_full(&to_node->hashPubKey)); 756 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_to_node;\n", GNUNET_h2s_full(&to_node->hashPubKey));
731 else 757 else
732 ret = fprintf(outfile, "set @temp_to_node = 0;\n"); 758 ret = fprintf(outfile, "set @temp_to_node = 0;\n");
733 759
760 if (ret < 0)
761 return GNUNET_SYSERR;
762
734 ret = fprintf(outfile, "set @qid = %llu, @type = %u, @hops = %u, @succ = %d;\n", queryid, type, hops, succeeded); 763 ret = fprintf(outfile, "set @qid = %llu, @type = %u, @hops = %u, @succ = %d;\n", queryid, type, hops, succeeded);
735 764
736 if (ret < 0) 765 if (ret < 0)
@@ -780,6 +809,14 @@ libgnunet_plugin_dhtlog_mysql_dump_init (void * cls)
780 809
781 fn = GNUNET_STRINGS_filename_expand (outfile_name); 810 fn = GNUNET_STRINGS_filename_expand (outfile_name);
782 811
812 if (fn == NULL)
813 {
814 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to get full path for `%s'\n"), outfile_name);
815 GNUNET_free(outfile_path);
816 GNUNET_free(outfile_name);
817 return NULL;
818 }
819
783 dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); 820 dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn));
784 outfile = FOPEN (fn, "w"); 821 outfile = FOPEN (fn, "w");
785 822