In ICMP taps, don't use g_slist_insert_sorted (which results in
authorEvan Huus <eapache@gmail.com>
Tue, 28 May 2013 23:20:44 +0000 (23:20 -0000)
committerEvan Huus <eapache@gmail.com>
Tue, 28 May 2013 23:20:44 +0000 (23:20 -0000)
n^2 time on the number of packets). Just prepend to the list, then sort
it when we actually need to calculate the statistics.

Should fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8721

svn path=/trunk/; revision=49606

ui/cli/tap-icmpstat.c
ui/cli/tap-icmpv6stat.c

index a39236091210fa9870328c6a546db08ff229636d..39c0c10e96849105dd0e79fd77f716b49cc9e9d5 100644 (file)
@@ -128,7 +128,7 @@ icmpstat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_,
         if (rt == NULL)
             return 0;
         *rt = resp_time;
         if (rt == NULL)
             return 0;
         *rt = resp_time;
-        icmpstat->rt_list = g_slist_insert_sorted(icmpstat->rt_list, rt, compare_doubles);
+        icmpstat->rt_list = g_slist_prepend(icmpstat->rt_list, rt);
         icmpstat->num_resps++;
         if (icmpstat->min_msecs > resp_time) {
             icmpstat->min_frame = trans->resp_frame;
         icmpstat->num_resps++;
         if (icmpstat->min_msecs > resp_time) {
             icmpstat->min_frame = trans->resp_frame;
@@ -153,10 +153,13 @@ icmpstat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_,
  */
 static void compute_stats(icmpstat_t *icmpstat, double *mean, double *med, double *sdev)
 {
  */
 static void compute_stats(icmpstat_t *icmpstat, double *mean, double *med, double *sdev)
 {
-    GSList *slist = icmpstat->rt_list;
+    GSList *slist;
     double diff;
     double sq_diff_sum = 0.0;
 
     double diff;
     double sq_diff_sum = 0.0;
 
+    icmpstat->rt_list = g_slist_sort(icmpstat->rt_list, compare_doubles);
+    slist = icmpstat->rt_list;
+
     if (icmpstat->num_resps == 0 || slist == NULL) {
         *mean = 0.0;
         *med = 0.0;
     if (icmpstat->num_resps == 0 || slist == NULL) {
         *mean = 0.0;
         *med = 0.0;
index 406998222e12e4b20fee76d40cbc8ad044e60f1d..88bb472b53b8273d0135ba2eaf7d84b0fcb8d39a 100644 (file)
@@ -129,7 +129,7 @@ icmpv6stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_
         if (rt == NULL)
             return 0;
         *rt = resp_time;
         if (rt == NULL)
             return 0;
         *rt = resp_time;
-        icmpv6stat->rt_list = g_slist_insert_sorted(icmpv6stat->rt_list, rt, compare_doubles);
+        icmpv6stat->rt_list = g_slist_prepend(icmpv6stat->rt_list, rt);
         icmpv6stat->num_resps++;
         if (icmpv6stat->min_msecs > resp_time) {
             icmpv6stat->min_frame = trans->resp_frame;
         icmpv6stat->num_resps++;
         if (icmpv6stat->min_msecs > resp_time) {
             icmpv6stat->min_frame = trans->resp_frame;
@@ -154,10 +154,13 @@ icmpv6stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_
  */
 static void compute_stats(icmpv6stat_t *icmpv6stat, double *mean, double *med, double *sdev)
 {
  */
 static void compute_stats(icmpv6stat_t *icmpv6stat, double *mean, double *med, double *sdev)
 {
-    GSList *slist = icmpv6stat->rt_list;
+    GSList *slist;
     double diff;
     double sq_diff_sum = 0.0;
 
     double diff;
     double sq_diff_sum = 0.0;
 
+    icmpv6stat->rt_list = g_slist_sort(icmpv6stat->rt_list, compare_doubles);
+    slist = icmpv6stat->rt_list;
+
     if (icmpv6stat->num_resps == 0 || slist == NULL) {
         *mean = 0.0;
         *med = 0.0;
     if (icmpv6stat->num_resps == 0 || slist == NULL) {
         *mean = 0.0;
         *med = 0.0;