Don't call pcap_breakloop() if we're not capturing anything. Fixes a

crash found by Stig.

Add debugging output to capture_cleanup_handler() on non-Windows
systems.

svn path=/trunk/; revision=37417
This commit is contained in:
Gerald Combs 2011-05-26 22:12:27 +00:00
parent c1b210c23c
commit 093fce7576
1 changed files with 12 additions and 5 deletions

View File

@ -1365,7 +1365,7 @@ capture_cleanup_handler(DWORD dwCtrlType)
}
#else
static void
capture_cleanup_handler(int signum _U_)
capture_cleanup_handler(int signum)
{
/* On UN*X, we cleanly shut down the capture on SIGINT, SIGHUP, and
SIGTERM. We assume that if the user wanted it to keep running
@ -1376,6 +1376,11 @@ capture_cleanup_handler(int signum _U_)
* the "recursion" and abort.
*/
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_INFO,
"Console: Control signal");
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
"Console: Control signal %d", signum);
capture_loop_stop();
}
#endif
@ -3482,10 +3487,12 @@ static void capture_loop_stop(void)
guint i;
pcap_options *pcap_opts;
for (i = 0; i < global_ld.pcaps->len; i++) {
pcap_opts = g_array_index(global_ld.pcaps, pcap_options *, i);
if (pcap_opts->pcap_h != NULL)
pcap_breakloop(pcap_opts->pcap_h);
if (global_ld.pcaps) {
for (i = 0; i < global_ld.pcaps->len; i++) {
pcap_opts = g_array_index(global_ld.pcaps, pcap_options *, i);
if (pcap_opts->pcap_h != NULL)
pcap_breakloop(pcap_opts->pcap_h);
}
}
#endif
global_ld.go = FALSE;