1 diff -ur apinger-0.6.1.orig//config.h.in apinger-0.6.1/config.h.in
2 --- apinger-0.6.1.orig//config.h.in 2003-03-26 11:37:48.000000000 +0000
3 +++ apinger-0.6.1/config.h.in 2012-07-25 17:40:42.232252511 +0000
5 /* config.h.in. Generated from configure.ac by autoheader. */
7 -/* Define to enable receiver subprocess */
8 -#undef FORKED_RECEIVER
10 /* Define to 1 if you have the `access' function. */
13 diff -ur apinger-0.6.1.orig//configure apinger-0.6.1/configure
14 --- apinger-0.6.1.orig//configure 2003-03-26 11:37:37.000000000 +0000
15 +++ apinger-0.6.1/configure 2012-07-25 17:40:42.235252628 +0000
17 --disable-dependency-tracking Speeds up one-time builds
18 --enable-dependency-tracking Do not reject slow dependency extractors
19 --disable-ipv6 Disable IPv6 support.
20 - --enable-forked-receiver
21 - Create subprocess for receiving pings.
24 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
25 @@ -7132,23 +7130,6 @@
29 -# Check whether --enable-forked-receiver or --disable-forked-receiver was given.
30 -if test "${enable_forked_receiver+set}" = set; then
31 - enableval="$enable_forked_receiver"
34 - enable_forked_receiver=no
37 -if test "x$enable_forked_receiver" = "xyes" ; then
39 -cat >>confdefs.h <<\_ACEOF
40 -#define FORKED_RECEIVER
46 # Check whether --with-rrdtool or --without-rrdtool was given.
47 if test "${with_rrdtool+set}" = set; then
48 withval="$with_rrdtool"
49 diff -ur apinger-0.6.1.orig//configure.ac apinger-0.6.1/configure.ac
50 --- apinger-0.6.1.orig//configure.ac 2003-03-26 11:37:16.000000000 +0000
51 +++ apinger-0.6.1/configure.ac 2012-07-25 17:40:42.235252628 +0000
54 AC_CHECK_FUNCS([sched_yield recvmsg])
56 -AC_ARG_ENABLE(forked-receiver,[AC_HELP_STRING([--enable-forked-receiver],
57 - [Create subprocess for receiving pings.])],
58 - [],[enable_forked_receiver=no])
60 -if test "x$enable_forked_receiver" = "xyes" ; then
61 - AC_DEFINE(FORKED_RECEIVER,[],[Define to enable receiver subprocess])
63 -dnl AC_MSG_CHECKING([if PIPE_BUF is big enough])
64 -dnl if test "x$enable_forked_receiver" != "xno" ; then
66 -dnl #ifdef HAVE_SYS_TYPES_H
67 -dnl # include <sys/types.h>
69 -dnl #ifdef HAVE_LIMITS_H
70 -dnl # include <limits.h>
73 -dnl int main(int argc,char **argv){
75 -dnl if (PIPE_BUF<1024) return 1;
78 -dnl [AC_DEFINE(FORKED_RECEIVER,[1],[Define to enable receiver subprocess])
79 -dnl AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])
80 -dnl AC_MSG_WARN([Receiver subprocess will not be used.])])
84 AC_ARG_WITH(rrdtool,[AC_HELP_STRING([--with-rrdtool=path],[Location of rrdtool program])],
85 [ RRDTOOL="$withval" ],[ AC_PATH_PROG([RRDTOOL],[rrdtool],[rrdtool]) ])
86 AC_ARG_WITH(rrdcgi,[AC_HELP_STRING([--with-rrdcgi=path],[Location of rrdcgi program])],
87 diff -ur apinger-0.6.1.orig//src/apinger.c apinger-0.6.1/src/apinger.c
88 --- apinger-0.6.1.orig//src/apinger.c 2012-07-25 17:39:57.000000000 +0000
89 +++ apinger-0.6.1/src/apinger.c 2012-07-25 17:40:42.236091113 +0000
94 -#ifdef FORKED_RECEIVER
97 -void pipe_reply(struct timeval time_recv,int icmp_seq,struct trace_info *ti){
98 -struct piped_info pi;
100 - pi.recv_timestamp=time_recv;
101 - pi.icmp_seq=icmp_seq;
103 - write(receiver_pipe,&pi,sizeof(pi));
106 -void receiver_loop(void){
107 -struct pollfd pfd[2];
111 - signal(SIGTERM,SIG_DFL);
112 - signal(SIGINT,SIG_DFL);
113 - signal(SIGHUP,SIG_DFL);
114 - signal(SIGUSR1,SIG_DFL);
115 - signal(SIGPIPE,SIG_DFL);
118 - pfd[npfd].events=POLLIN|POLLERR|POLLHUP|POLLNVAL;
119 - pfd[npfd].revents=0;
120 - pfd[npfd++].fd=icmp_sock;
123 - pfd[npfd].events=POLLIN|POLLERR|POLLHUP|POLLNVAL;
124 - pfd[npfd++].fd=icmp6_sock;
125 - pfd[npfd].revents=0;
129 - for(i=0;i<npfd;i++){
130 - if (!pfd[i].revents&POLLIN) continue;
131 - if (pfd[i].fd==icmp_sock) recv_icmp();
132 - else if (pfd[i].fd==icmp6_sock) recv_icmp6();
139 void main_loop(void){
141 struct timeval cur_time,next_status={0,0},tv,next_report={0,0},next_rrd_update={0,0};
143 struct alarm_list *al,*nal;
144 struct active_alarm_list *aal;
146 -#ifdef FORKED_RECEIVER
149 -struct piped_info pi;
153 -#ifdef FORKED_RECEIVER
165 - close(recv_pipe[0]);
166 - receiver_pipe=recv_pipe[1];
170 - close(recv_pipe[1]);
171 - pfd[npfd].events=POLLIN|POLLERR|POLLHUP|POLLNVAL;
172 - pfd[npfd].revents=0;
173 - pfd[npfd++].fd=recv_pipe[0];
176 pfd[npfd].events=POLLIN|POLLERR|POLLHUP|POLLNVAL;
179 pfd[npfd++].fd=icmp6_sock;
183 if (config->status_interval){
184 gettimeofday(&cur_time,NULL);
185 tv.tv_sec=config->status_interval/1000;
186 @@ -1045,16 +972,8 @@
187 poll(pfd,npfd,timeout);
189 if (!pfd[i].revents&POLLIN) continue;
190 -#ifdef FORKED_RECEIVER
191 - if (pfd[i].fd==recv_pipe[0]){
192 - r=read(recv_pipe[0],&pi,sizeof(pi));
194 - analyze_reply(pi.recv_timestamp,pi.icmp_seq,&pi.ti);
197 if (pfd[i].fd==icmp_sock) recv_icmp();
198 else if (pfd[i].fd==icmp6_sock) recv_icmp6();
207 -#ifdef FORKED_RECEIVER
210 while(delayed_reports!=NULL) make_delayed_reports();
212 if (macros_buf!=NULL) free(macros_buf);
213 diff -ur apinger-0.6.1.orig//src/apinger.h apinger-0.6.1/src/apinger.h
214 --- apinger-0.6.1.orig//src/apinger.h 2002-12-20 09:19:57.000000000 +0000
215 +++ apinger-0.6.1/src/apinger.h 2012-07-25 17:40:42.236091113 +0000
220 -#ifdef FORKED_RECEIVER
222 - struct trace_info ti;
224 - struct timeval recv_timestamp;
228 struct target *targets;
230 extern int foreground;
232 void recv_icmp6(void);
233 void send_icmp6_probe(struct target *t,int seq);
235 -#ifdef FORKED_RECEIVER
236 -void pipe_reply(struct timeval time_recv,int seq,struct trace_info *ti);
238 void analyze_reply(struct timeval time_recv,int seq,struct trace_info *ti);
239 void main_loop(void);
241 diff -ur apinger-0.6.1.orig//src/icmp.c apinger-0.6.1/src/icmp.c
242 --- apinger-0.6.1.orig//src/icmp.c 2002-12-19 08:24:33.000000000 +0000
243 +++ apinger-0.6.1/src/icmp.c 2012-07-25 17:40:42.237251321 +0000
245 debug("Packet data truncated.");
248 -#ifdef FORKED_RECEIVER
249 - pipe_reply(*time_recvp,icmp->icmp_seq,(struct trace_info*)(icmp+1));
251 analyze_reply(*time_recvp,icmp->icmp_seq,(struct trace_info*)(icmp+1));
255 int make_icmp_socket(void){
256 diff -ur apinger-0.6.1.orig//src/icmp6.c apinger-0.6.1/src/icmp6.c
257 --- apinger-0.6.1.orig//src/icmp6.c 2002-12-19 08:34:16.000000000 +0000
258 +++ apinger-0.6.1/src/icmp6.c 2012-07-25 17:40:42.237251321 +0000
260 debug("Packet data truncated.");
263 -#ifdef FORKED_RECEIVER
264 - pipe_reply(*time_recvp,icmp->icmp6_seq,(struct trace_info*)(icmp+1));
266 analyze_reply(*time_recvp,icmp->icmp6_seq,(struct trace_info*)(icmp+1));
271 diff -ur apinger-0.6.1.orig//src/main.c apinger-0.6.1/src/main.c
272 --- apinger-0.6.1.orig//src/main.c 2003-03-26 11:27:47.000000000 +0000
273 +++ apinger-0.6.1/src/main.c 2012-07-25 17:40:42.237251321 +0000
278 -#ifdef FORKED_RECEIVER
279 -void sigchld_handler (int signum) {
280 -int pid, status, serrno;
284 - pid = waitpid (WAIT_ANY, &status, WNOHANG);
285 - if (pid <= 0) break;
291 void usage(const char *name){
292 fprintf(stderr,"Alarm Pinger " PACKAGE_VERSION " (c) 2002 Jacek Konieczny <jajcus@pld.org.pl>\n");
293 fprintf(stderr,"Usage:\n");
295 signal(SIGHUP,signal_handler);
296 signal(SIGUSR1,signal_handler);
297 signal(SIGPIPE,signal_handler);
298 -#ifdef FORKED_RECEIVER
299 - signal(SIGCHLD,sigchld_handler);
302 if (icmp_sock>=0) close(icmp_sock);
303 if (icmp6_sock>=0) close(icmp6_sock);