summaryrefslogtreecommitdiff
path: root/apinger-no_forked_receiver.patch
blob: 98ee39390f41fbb399c4fb03031334648363bf1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
diff -ur apinger-0.6.1.orig//config.h.in apinger-0.6.1/config.h.in
--- apinger-0.6.1.orig//config.h.in	2003-03-26 11:37:48.000000000 +0000
+++ apinger-0.6.1/config.h.in	2012-07-25 17:40:42.232252511 +0000
@@ -1,8 +1,5 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
-/* Define to enable receiver subprocess */
-#undef FORKED_RECEIVER
-
 /* Define to 1 if you have the `access' function. */
 #undef HAVE_ACCESS
 
diff -ur apinger-0.6.1.orig//configure apinger-0.6.1/configure
--- apinger-0.6.1.orig//configure	2003-03-26 11:37:37.000000000 +0000
+++ apinger-0.6.1/configure	2012-07-25 17:40:42.235252628 +0000
@@ -851,8 +851,6 @@
   --disable-dependency-tracking Speeds up one-time builds
   --enable-dependency-tracking  Do not reject slow dependency extractors
   --disable-ipv6          Disable IPv6 support.
-  --enable-forked-receiver
-                          Create subprocess for receiving pings.
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -7132,23 +7130,6 @@
 done
 
 
-# Check whether --enable-forked-receiver or --disable-forked-receiver was given.
-if test "${enable_forked_receiver+set}" = set; then
-  enableval="$enable_forked_receiver"
-
-else
-  enable_forked_receiver=no
-fi;
-
-if test "x$enable_forked_receiver" = "xyes" ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define FORKED_RECEIVER
-_ACEOF
-
-fi
-
-
 # Check whether --with-rrdtool or --without-rrdtool was given.
 if test "${with_rrdtool+set}" = set; then
   withval="$with_rrdtool"
diff -ur apinger-0.6.1.orig//configure.ac apinger-0.6.1/configure.ac
--- apinger-0.6.1.orig//configure.ac	2003-03-26 11:37:16.000000000 +0000
+++ apinger-0.6.1/configure.ac	2012-07-25 17:40:42.235252628 +0000
@@ -56,34 +56,6 @@
 
 AC_CHECK_FUNCS([sched_yield recvmsg])
 
-AC_ARG_ENABLE(forked-receiver,[AC_HELP_STRING([--enable-forked-receiver],
-	      			[Create subprocess for receiving pings.])],
-			      		[],[enable_forked_receiver=no])
-
-if test "x$enable_forked_receiver" = "xyes" ; then
-	AC_DEFINE(FORKED_RECEIVER,[],[Define to enable receiver subprocess])
-dnl else 
-dnl 	AC_MSG_CHECKING([if PIPE_BUF is big enough])
-dnl 	if test "x$enable_forked_receiver" != "xno" ; then
-dnl 		AC_TRY_RUN([
-dnl #ifdef HAVE_SYS_TYPES_H
-dnl # include <sys/types.h>
-dnl #endif
-dnl #ifdef HAVE_LIMITS_H
-dnl # include <limits.h>
-dnl #endif
-dnl 
-dnl int main(int argc,char **argv){
-dnl 	
-dnl 	if (PIPE_BUF<1024) return 1;
-dnl 	return 0;
-dnl }],
-dnl 		[AC_DEFINE(FORKED_RECEIVER,[1],[Define to enable receiver subprocess])
-dnl 		AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])
-dnl 					AC_MSG_WARN([Receiver subprocess will not be used.])])
-dnl 	fi
-fi
-
 AC_ARG_WITH(rrdtool,[AC_HELP_STRING([--with-rrdtool=path],[Location of rrdtool program])],
 	[ RRDTOOL="$withval" ],[ AC_PATH_PROG([RRDTOOL],[rrdtool],[rrdtool]) ])
 AC_ARG_WITH(rrdcgi,[AC_HELP_STRING([--with-rrdcgi=path],[Location of rrdcgi program])],
diff -ur apinger-0.6.1.orig//src/apinger.c apinger-0.6.1/src/apinger.c
--- apinger-0.6.1.orig//src/apinger.c	2012-07-25 17:39:57.000000000 +0000
+++ apinger-0.6.1/src/apinger.c	2012-07-25 17:40:42.236091113 +0000
@@ -862,51 +862,6 @@
 	fclose(f);
 }
 
-#ifdef FORKED_RECEIVER
-int receiver_pipe=0;
-
-void pipe_reply(struct timeval time_recv,int icmp_seq,struct trace_info *ti){
-struct piped_info pi;
-
-	pi.recv_timestamp=time_recv;
-	pi.icmp_seq=icmp_seq;
-	pi.ti=*ti;
-	write(receiver_pipe,&pi,sizeof(pi));
-}
-
-void receiver_loop(void){
-struct pollfd pfd[2];
-int npfd=0;
-int i;
-
-	signal(SIGTERM,SIG_DFL);
-	signal(SIGINT,SIG_DFL);
-	signal(SIGHUP,SIG_DFL);
-	signal(SIGUSR1,SIG_DFL);
-	signal(SIGPIPE,SIG_DFL);
-	
-	if (icmp_sock){
-		pfd[npfd].events=POLLIN|POLLERR|POLLHUP|POLLNVAL;
-		pfd[npfd].revents=0;
-		pfd[npfd++].fd=icmp_sock;
-	}
-	if (icmp6_sock){
-		pfd[npfd].events=POLLIN|POLLERR|POLLHUP|POLLNVAL;
-		pfd[npfd++].fd=icmp6_sock;
-		pfd[npfd].revents=0;
-	}
-	while(1){
-		poll(pfd,npfd,-1);
-		for(i=0;i<npfd;i++){
-			if (!pfd[i].revents&POLLIN) continue;
-			if (pfd[i].fd==icmp_sock) recv_icmp();
-			else if (pfd[i].fd==icmp6_sock) recv_icmp6();
-			pfd[i].revents=0;
-		}
-	};
-}
-#endif
-
 void main_loop(void){
 struct target *t;
 struct timeval cur_time,next_status={0,0},tv,next_report={0,0},next_rrd_update={0,0};
@@ -919,35 +874,8 @@
 struct alarm_list *al,*nal;
 struct active_alarm_list *aal;
 struct alarm_cfg *a;
-#ifdef FORKED_RECEIVER
-int recv_pipe[2];
-int pid,r;
-struct piped_info pi;
-#endif
 
 	configure_targets();
-#ifdef FORKED_RECEIVER
-	r=pipe(recv_pipe);
-	if (r){
-		myperror("pipe");
-		exit(1);
-	}
-	pid=fork();
-	if (pid==-1){
-		myperror("pipe");
-		exit(1);
-	}
-	else if (pid==0){
-		close(recv_pipe[0]);
-		receiver_pipe=recv_pipe[1];
-		receiver_loop();
-		exit(0);
-	}
-	close(recv_pipe[1]);
-	pfd[npfd].events=POLLIN|POLLERR|POLLHUP|POLLNVAL;
-	pfd[npfd].revents=0;
-	pfd[npfd++].fd=recv_pipe[0];
-#else
 	if (icmp_sock){
 		pfd[npfd].events=POLLIN|POLLERR|POLLHUP|POLLNVAL;
 		pfd[npfd].revents=0;
@@ -958,7 +886,6 @@
 		pfd[npfd++].fd=icmp6_sock;
 		pfd[npfd].revents=0;
 	}
-#endif
 	if (config->status_interval){
 		gettimeofday(&cur_time,NULL);
 		tv.tv_sec=config->status_interval/1000;
@@ -1045,16 +972,8 @@
 		poll(pfd,npfd,timeout);
 		for(i=0;i<npfd;i++){
 			if (!pfd[i].revents&POLLIN) continue;
-#ifdef FORKED_RECEIVER
-			if (pfd[i].fd==recv_pipe[0]){
-				r=read(recv_pipe[0],&pi,sizeof(pi));
-				if (r==sizeof(pi))
-					analyze_reply(pi.recv_timestamp,pi.icmp_seq,&pi.ti);
-			}
-#else
 			if (pfd[i].fd==icmp_sock) recv_icmp();
 			else if (pfd[i].fd==icmp6_sock) recv_icmp6();
-#endif
 			pfd[i].revents=0;
 		}
 		if (status_request){
@@ -1070,9 +989,6 @@
 			reload_config();
 		}
 	}
-#ifdef FORKED_RECEIVER
-	kill(pid,SIGTERM);
-#endif
 	while(delayed_reports!=NULL) make_delayed_reports();
 	free_targets();
 	if (macros_buf!=NULL) free(macros_buf);
diff -ur apinger-0.6.1.orig//src/apinger.h apinger-0.6.1/src/apinger.h
--- apinger-0.6.1.orig//src/apinger.h	2002-12-20 09:19:57.000000000 +0000
+++ apinger-0.6.1/src/apinger.h	2012-07-25 17:40:42.236091113 +0000
@@ -104,14 +104,6 @@
 	void *target_id;
 };
 
-#ifdef FORKED_RECEIVER
-struct piped_info {
-	struct trace_info ti;
-	int icmp_seq;
-	struct timeval recv_timestamp;
-};
-#endif
-
 struct target *targets;
 
 extern int foreground;
@@ -131,9 +123,6 @@
 void recv_icmp6(void);
 void send_icmp6_probe(struct target *t,int seq);
 
-#ifdef FORKED_RECEIVER
-void pipe_reply(struct timeval time_recv,int seq,struct trace_info *ti);
-#endif
 void analyze_reply(struct timeval time_recv,int seq,struct trace_info *ti);
 void main_loop(void);
 
diff -ur apinger-0.6.1.orig//src/icmp.c apinger-0.6.1/src/icmp.c
--- apinger-0.6.1.orig//src/icmp.c	2002-12-19 08:24:33.000000000 +0000
+++ apinger-0.6.1/src/icmp.c	2012-07-25 17:40:42.237251321 +0000
@@ -236,11 +236,7 @@
 		debug("Packet data truncated.");
 		return;
 	}
-#ifdef FORKED_RECEIVER
-	pipe_reply(*time_recvp,icmp->icmp_seq,(struct trace_info*)(icmp+1));
-#else
 	analyze_reply(*time_recvp,icmp->icmp_seq,(struct trace_info*)(icmp+1));
-#endif
 }
 
 int make_icmp_socket(void){
diff -ur apinger-0.6.1.orig//src/icmp6.c apinger-0.6.1/src/icmp6.c
--- apinger-0.6.1.orig//src/icmp6.c	2002-12-19 08:34:16.000000000 +0000
+++ apinger-0.6.1/src/icmp6.c	2012-07-25 17:40:42.237251321 +0000
@@ -192,11 +192,7 @@
 		debug("Packet data truncated.");
 		return;
 	}
-#ifdef FORKED_RECEIVER
-	pipe_reply(*time_recvp,icmp->icmp6_seq,(struct trace_info*)(icmp+1));
-#else
 	analyze_reply(*time_recvp,icmp->icmp6_seq,(struct trace_info*)(icmp+1));
-#endif
 }
 
 
diff -ur apinger-0.6.1.orig//src/main.c apinger-0.6.1/src/main.c
--- apinger-0.6.1.orig//src/main.c	2003-03-26 11:27:47.000000000 +0000
+++ apinger-0.6.1/src/main.c	2012-07-25 17:40:42.237251321 +0000
@@ -125,19 +125,6 @@
 	}
 }
 
-#ifdef FORKED_RECEIVER
-void sigchld_handler (int signum) {
-int pid, status, serrno;
-
-	serrno = errno;
-	while (1) {
-		   pid = waitpid (WAIT_ANY, &status, WNOHANG);
-		   if (pid <= 0) break;
-	}
-	errno = serrno;
-}
-#endif
-
 void usage(const char *name){
 	fprintf(stderr,"Alarm Pinger " PACKAGE_VERSION " (c) 2002 Jacek Konieczny <jajcus@pld.org.pl>\n");
 	fprintf(stderr,"Usage:\n");
@@ -283,9 +270,6 @@
 	signal(SIGHUP,signal_handler);
 	signal(SIGUSR1,signal_handler);
 	signal(SIGPIPE,signal_handler);
-#ifdef FORKED_RECEIVER
-	signal(SIGCHLD,sigchld_handler);
-#endif
 	main_loop();
 	if (icmp_sock>=0) close(icmp_sock);
 	if (icmp6_sock>=0) close(icmp6_sock);