]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/inetutils-1.4.2-ping-1.patch
Wir kehren zurueck zu Kudzu, da hwinfo noch mehr Aerger macht.
[people/teissler/ipfire-2.x.git] / src / patches / inetutils-1.4.2-ping-1.patch
1 Submitted By: Jim Gifford (patches at jg555 dot com)
2 Date: 2003-09-10
3 Initial Package Version: 1.4.2
4 Origin: inetutils CVS
5 Description: Fixes Ping Errors
6 If you try to only send one ping, it will not stop
7 until it gets a response.
8
9 diff -Naur inetutils-1.4.2.orig/ping/ping.c inetutils-1.4.2/ping/ping.c
10 --- inetutils-1.4.2.orig/ping/ping.c 2002-12-11 12:38:00.000000000 +0000
11 +++ inetutils-1.4.2/ping/ping.c 2003-09-10 16:13:14.000000000 +0000
12 @@ -338,7 +338,8 @@
13 struct timeval last, intvl, now;
14 struct timeval *t = NULL;
15 int finishing = 0;
16 -
17 + int nresp = 0;
18 +
19 signal (SIGINT, sig_int);
20
21 fdmax = ping->ping_fd+1;
22 @@ -387,23 +388,24 @@
23 if ((n = select (fdmax, &fdset, NULL, NULL, &timeout)) < 0)
24 {
25 if (errno != EINTR)
26 - perror ("ping: select");
27 + perror ("select");
28 continue;
29 }
30 else if (n == 1)
31 {
32 - len = ping_recv (ping);
33 + if (ping_recv (ping) == 0)
34 + nresp++;
35 if (t == 0)
36 {
37 gettimeofday (&now, NULL);
38 t = &now;
39 }
40 - if (ping->ping_count && ping->ping_num_recv >= ping->ping_count)
41 + if (ping->ping_count && nresp >= ping->ping_count)
42 break;
43 }
44 else
45 {
46 - if (!ping->ping_count || ping->ping_num_recv < ping->ping_count)
47 + if (!ping->ping_count || ping->ping_num_xmit < ping->ping_count)
48 {
49 send_echo (ping);
50 if (!(options & OPT_QUIET) && options & OPT_FLOOD)
51 @@ -414,7 +416,7 @@
52 else if (finishing)
53 break;
54 else
55 - {
56 + {
57 finishing = 1;
58
59 intvl.tv_sec = MAXWAIT;
60 diff -Naur inetutils-1.4.2.orig/ping/ping_echo.c inetutils-1.4.2/ping/ping_echo.c
61 --- inetutils-1.4.2.orig/ping/ping_echo.c 2002-06-26 03:15:06.000000000 +0000
62 +++ inetutils-1.4.2/ping/ping_echo.c 2003-09-10 16:19:11.000000000 +0000
63 @@ -43,7 +43,6 @@
64 #include <stdio.h>
65 #include <ctype.h>
66 #include <errno.h>
67 -#include <math.h>
68 #include <limits.h>
69
70 #include "getopt.h"
71 @@ -583,6 +582,31 @@
72 out->tv_sec -= in->tv_sec;
73 }
74
75 +double
76 +nabs (double a)
77 +{
78 + return (a < 0) ? -a : a;
79 +}
80 +
81 +double
82 +nsqrt (double a, double prec)
83 +{
84 + double x0, x1;
85 +
86 + if (a < 0)
87 + return 0;
88 + if (a < prec)
89 + return 0;
90 + x1 = a/2;
91 + do
92 + {
93 + x0 = x1;
94 + x1 = (x0 + a/x0) / 2;
95 + }
96 + while (nabs (x1 - x0) > prec);
97 +
98 + return x1;
99 +}
100
101 int
102 echo_finish ()
103 @@ -596,10 +620,10 @@
104 double vari = ping_stat->tsumsq / total - avg * avg;
105
106 printf ("round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f ms\n",
107 - ping_stat->tmin,
108 - avg,
109 - ping_stat->tmax,
110 - sqrt (vari));
111 + ping_stat->tmin,
112 + avg,
113 + ping_stat->tmax,
114 + nsqrt (vari, 0.0005));
115 }
116 exit (ping->ping_num_recv == 0);
117 }