Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r803 committed - Include richard sanger's fix for issue 71

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r803 committed - Include richard sanger's fix for issue 71


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r803 committed - Include richard sanger's fix for issue 71
  • Date: Tue, 09 Apr 2013 13:13:14 +0000
  • Authentication-results: sfpop-ironport03.merit.edu; dkim=neutral (message not signed) header.i=none

Revision: 803
Author:

Date: Tue Apr 9 06:13:00 2013
Log: Include richard sanger's fix for issue 71


http://code.google.com/p/ndt/source/detail?r=803

Modified:
/trunk/src/web100-pcap.c
/trunk/src/web100srv.c
/trunk/src/web100srv.h

=======================================
--- /trunk/src/web100-pcap.c Thu Nov 15 13:34:19 2012
+++ /trunk/src/web100-pcap.c Tue Apr 9 06:13:00 2013
@@ -89,6 +89,19 @@
if (alldevs != NULL)
pcap_freealldevs(alldevs);
}
+
+/**
+ * Force the pcap_loop to return, this is safe to call from a signal handler.
+ * Note this will break the loop without a packet being received if
+ * used from a signal handler due to the EINTR interrupting pcaps 'read'.
+ *
+ * This calls pcap_breakloop with the correct capture.
+ */
+void force_breakloop(){
+ if (pd != NULL) {
+ pcap_breakloop(pd);
+ }
+}

/** Check signal flags and process them accordingly.
* If signal indicates request to terminate data collection for the speed bins,
@@ -97,7 +110,7 @@
* @return 1 if data was successfully written
* 0 if no relevant signals were actually received
*/
-int check_signal_flags() {
+static int check_signal_flags() {
if ((sig1 == 1) || (sig2 == 1)) {
log_println(
5,
@@ -135,9 +148,6 @@
usleep(30000); /* wait here 30 msec, for parent to read this data */
print_bins(&rev, mon_pipe1);
usleep(30000); /* wait here 30 msec, for parent to read this data */
- if (pd != NULL) {
- pcap_breakloop(pd);
- }
if (dumptrace == 1)
pcap_dump_close(pdump);
sig1 = 2;
@@ -175,9 +185,6 @@
usleep(30000); /* wait here 30 msec, for parent to read this data */
print_bins(&rev, mon_pipe2);
usleep(30000); /* wait here 30 msec, for parent to read this data */
- if (pd != NULL) {
- pcap_breakloop(pd);
- }
if (dumptrace == 1)
pcap_dump_close(pdump);
sig2 = 2;
@@ -558,10 +565,6 @@
"!#!#!#!# Error, trying to process IF data, but pcap fd closed\n");
return;
}
-
- if (check_signal_flags()) {
- return;
- }

current.sec = h->ts.tv_sec;
current.usec = h->ts.tv_usec;
@@ -1045,6 +1048,11 @@
if (pcap_loop(pd, cnt, printer, pcap_userdata) < 0) {
log_println(5, "pcap_loop exited %s", pcap_geterr(pd));
}
+
+ /* Send back results to our parent */
+ if(check_signal_flags() == 0){
+ log_println(5, "Whatever happened, we should have a sig flag set");
+ }

pcap_close(pd);

=======================================
--- /trunk/src/web100srv.c Wed Mar 20 08:05:33 2013
+++ /trunk/src/web100srv.c Tue Apr 9 06:13:00 2013
@@ -468,17 +468,19 @@
}
exit(0);
case SIGUSR1:
+ /* SIGUSR1 is used exclusively by C2S, to interrupt the pcap capture*/
log_println(6,
- "DEBUG, caught SIGUSR1, setting sig1 flag to force exit");
+ "DEBUG, caught SIGUSR1, setting sig1 flag and calling force_breakloop");
+ force_breakloop();
sig1 = 1;
- /* check_signal_flags(); */
break;

case SIGUSR2:
+ /* SIGUSR2 is used exclusively by S2C, to interrupt the pcap capture*/
log_println(6,
- "DEBUG, caught SIGUSR2, setting sig2 flag to force exit");
+ "DEBUG, caught SIGUSR2, setting sig2 flag and calling force_breakloop");
+ force_breakloop();
sig2 = 1;
- /* check_signal_flags(); */
break;

case SIGALRM:
@@ -834,12 +836,6 @@
recv_msg(tmp_ptr->ctlsockfd, &msgType, buff, &msgLen);
tmp_ptr = tmp_ptr->next;
pre_ptr = pre_ptr->next;
- /*
- if ((sig1 > 0) || (sig2 > 0))
- check_signal_flags();
- if (sig17 > 0)
- child_sig(0);
- */
break;
case -1: // some error status
if (errno == EINTR) {
@@ -1923,11 +1919,6 @@
"zombie_check=%d",
head_ptr->pid, testing, waiting, mclients, zombie_check);

- // moved condition from interrupt handler to here
- /* if ((sig1 > 0) || (sig2 > 0))
- * check_signal_flags;
- */
-
if (sig13 == 1) {
log_println(5, "todo: Handle SIGPIPE signal, terminate child?");
child_sig(0);
=======================================
--- /trunk/src/web100srv.h Wed Mar 20 08:05:33 2013
+++ /trunk/src/web100srv.h Tue Apr 9 06:13:00 2013
@@ -199,7 +199,7 @@
void init_pkttrace(I2Addr srcAddr, struct sockaddr *sock_addr,
socklen_t saddrlen, int monitor_pipe[2], char *device,
PortPair* pair, char * direction, int compress);
-int check_signal_flags();
+void force_breakloop();
#endif

/* web100-util */


  • [ndt-dev] [ndt] r803 committed - Include richard sanger's fix for issue 71, ndt, 04/09/2013

Archive powered by MHonArc 2.6.16.

Top of Page