diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-12-05 21:52:18 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-12-05 21:52:18 +0000 |
commit | 50d997186e1b13606b0913e254c090281c87167a (patch) | |
tree | 9de817065d1f8304b9bca317ae95a7e756cde214 | |
parent | 3319bc1e3f55d09b648ad8f44fdb48ec400048d0 (diff) | |
download | gnunet-50d997186e1b13606b0913e254c090281c87167a.tar.gz gnunet-50d997186e1b13606b0913e254c090281c87167a.zip |
-fix leaks on error-return, fix indentation
-rw-r--r-- | src/ats/perf_ats_solver.c | 85 |
1 files changed, 58 insertions, 27 deletions
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c index 7767e5496..beb30175d 100644 --- a/src/ats/perf_ats_solver.c +++ b/src/ats/perf_ats_solver.c | |||
@@ -697,19 +697,28 @@ evaluate () | |||
697 | 697 | ||
698 | if (ph.create_plot) | 698 | if (ph.create_plot) |
699 | { | 699 | { |
700 | GNUNET_asprintf (&data_fn_full, "perf_%s_full_%u_%u_%u.data", ph.ats_string, ph.N_peers_start, ph.N_peers_end, ph.N_address); | 700 | GNUNET_asprintf (&data_fn_full, |
701 | "perf_%s_full_%u_%u_%u.data", | ||
702 | ph.ats_string, | ||
703 | ph.N_peers_start, | ||
704 | ph.N_peers_end, | ||
705 | ph.N_address); | ||
701 | f_full = GNUNET_DISK_file_open (data_fn_full, | 706 | f_full = GNUNET_DISK_file_open (data_fn_full, |
702 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 707 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
703 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | 708 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); |
704 | if (NULL == f_full) | 709 | if (NULL == f_full) |
705 | { | 710 | { |
706 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", data_fn_full); | 711 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
712 | "Cannot open gnuplot file `%s'\n", | ||
713 | data_fn_full); | ||
707 | GNUNET_free (data_fn_full); | 714 | GNUNET_free (data_fn_full); |
708 | return; | 715 | return; |
709 | } | 716 | } |
710 | data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; | 717 | data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; |
711 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data))) | 718 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data))) |
712 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn_full); | 719 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
720 | "Cannot write data to log file `%s'\n", | ||
721 | data_fn_full); | ||
713 | write_gnuplot_script (data_fn_full, GNUNET_YES); | 722 | write_gnuplot_script (data_fn_full, GNUNET_YES); |
714 | } | 723 | } |
715 | 724 | ||
@@ -722,13 +731,19 @@ evaluate () | |||
722 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | 731 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); |
723 | if (NULL == f_update) | 732 | if (NULL == f_update) |
724 | { | 733 | { |
725 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", data_fn_update); | 734 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
735 | "Cannot open gnuplot file `%s'\n", data_fn_update); | ||
726 | GNUNET_free (data_fn_update); | 736 | GNUNET_free (data_fn_update); |
737 | if (NULL != f_full) | ||
738 | GNUNET_DISK_file_close (f_full); | ||
739 | GNUNET_free (data_fn_full); | ||
727 | return; | 740 | return; |
728 | } | 741 | } |
729 | data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; | 742 | data = "#peers;addresses;time total in us;#time setup in us;#time lp in us;#time mlp in us;\n"; |
730 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_update, data, strlen(data))) | 743 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data))) |
731 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn_update); | 744 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
745 | "Cannot write data to log file `%s'\n", | ||
746 | data_fn_update); | ||
732 | write_gnuplot_script (data_fn_update, GNUNET_NO); | 747 | write_gnuplot_script (data_fn_update, GNUNET_NO); |
733 | } | 748 | } |
734 | 749 | ||
@@ -744,10 +759,13 @@ evaluate () | |||
744 | /* Print log */ | 759 | /* Print log */ |
745 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us) | 760 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us) |
746 | { | 761 | { |
747 | fprintf (stderr, "Total time to solve %s for %u peers %u addresses: %llu us\n", | 762 | fprintf (stderr, |
748 | (GNUNET_YES == cur->update) ? "updated" : "full", | 763 | "Total time to solve %s for %u peers %u addresses: %llu us\n", |
749 | cur->peers, cur->addresses, (unsigned long long )cur->d_total.rel_value_us); | 764 | (GNUNET_YES == cur->update) ? "updated" : "full", |
750 | GNUNET_asprintf(&str_d_total, "%llu", (unsigned long long )cur->d_total.rel_value_us); | 765 | cur->peers, cur->addresses, (unsigned long long) cur->d_total.rel_value_us); |
766 | GNUNET_asprintf(&str_d_total, | ||
767 | "%llu", | ||
768 | (unsigned long long) cur->d_total.rel_value_us); | ||
751 | } | 769 | } |
752 | else | 770 | else |
753 | GNUNET_asprintf(&str_d_total, "-1"); | 771 | GNUNET_asprintf(&str_d_total, "-1"); |
@@ -762,42 +780,54 @@ evaluate () | |||
762 | GNUNET_asprintf(&str_d_setup, "-1"); | 780 | GNUNET_asprintf(&str_d_setup, "-1"); |
763 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us) | 781 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us) |
764 | { | 782 | { |
765 | fprintf (stderr, "Total time to solve %s LP for %u peers %u addresses: %llu us\n", | 783 | fprintf (stderr, |
766 | (GNUNET_YES == cur->update) ? "updated" : "full", | 784 | "Total time to solve %s LP for %u peers %u addresses: %llu us\n", |
767 | cur->peers, cur->addresses, (unsigned long long )cur->d_lp.rel_value_us); | 785 | (GNUNET_YES == cur->update) ? "updated" : "full", |
768 | GNUNET_asprintf(&str_d_lp, "%llu", (unsigned long long )cur->d_lp.rel_value_us); | 786 | cur->peers, |
787 | cur->addresses, | ||
788 | (unsigned long long )cur->d_lp.rel_value_us); | ||
789 | GNUNET_asprintf (&str_d_lp, | ||
790 | "%llu", | ||
791 | (unsigned long long )cur->d_lp.rel_value_us); | ||
769 | } | 792 | } |
770 | else | 793 | else |
771 | GNUNET_asprintf(&str_d_lp, "-1"); | 794 | GNUNET_asprintf (&str_d_lp, "-1"); |
772 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us) | 795 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us) |
773 | { | 796 | { |
774 | fprintf (stderr, "Total time to solve %s MLP for %u peers %u addresses: %llu us\n", | 797 | fprintf (stderr, "Total time to solve %s MLP for %u peers %u addresses: %llu us\n", |
775 | (GNUNET_YES == cur->update) ? "updated" : "full", | 798 | (GNUNET_YES == cur->update) ? "updated" : "full", |
776 | cur->peers, cur->addresses, (unsigned long long )cur->d_mlp.rel_value_us); | 799 | cur->peers, cur->addresses, (unsigned long long )cur->d_mlp.rel_value_us); |
777 | GNUNET_asprintf(&str_d_mlp, "%llu", (unsigned long long )cur->d_mlp.rel_value_us); | 800 | GNUNET_asprintf (&str_d_mlp, |
801 | "%llu", | ||
802 | (unsigned long long )cur->d_mlp.rel_value_us); | ||
778 | } | 803 | } |
779 | else | 804 | else |
780 | GNUNET_asprintf(&str_d_mlp, "-1"); | 805 | GNUNET_asprintf (&str_d_mlp, "-1"); |
781 | 806 | ||
782 | data = NULL; | 807 | data = NULL; |
783 | if (GNUNET_YES == ph.create_plot) | 808 | if (GNUNET_YES == ph.create_plot) |
784 | { | 809 | { |
785 | 810 | ||
786 | GNUNET_asprintf(&data,"%u;%u;%s;%s;%s;%s\n", | 811 | GNUNET_asprintf (&data, |
787 | cur->peers, cur->addresses, | 812 | "%u;%u;%s;%s;%s;%s\n", |
788 | str_d_total, | 813 | cur->peers, cur->addresses, |
789 | str_d_setup, | 814 | str_d_total, |
790 | str_d_lp, | 815 | str_d_setup, |
791 | str_d_mlp); | 816 | str_d_lp, |
817 | str_d_mlp); | ||
792 | if (cur->update == GNUNET_NO) | 818 | if (cur->update == GNUNET_NO) |
793 | { | 819 | { |
794 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_full, data, strlen(data))) | 820 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_full, data, strlen(data))) |
795 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn_full); | 821 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
822 | "Cannot write data to log file `%s'\n", | ||
823 | data_fn_full); | ||
796 | } | 824 | } |
797 | if ((cur->update == GNUNET_YES) && (NULL != f_update)) | 825 | if ((cur->update == GNUNET_YES) && (NULL != f_update)) |
798 | { | 826 | { |
799 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_update, data, strlen(data))) | 827 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data))) |
800 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", data_fn_update); | 828 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
829 | "Cannot write data to log file `%s'\n", | ||
830 | data_fn_update); | ||
801 | } | 831 | } |
802 | GNUNET_free (data); | 832 | GNUNET_free (data); |
803 | } | 833 | } |
@@ -821,6 +851,7 @@ evaluate () | |||
821 | GNUNET_free_non_null (data_fn_update); | 851 | GNUNET_free_non_null (data_fn_update); |
822 | } | 852 | } |
823 | 853 | ||
854 | |||
824 | static void | 855 | static void |
825 | perf_run () | 856 | perf_run () |
826 | { | 857 | { |