summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-12-08 22:50:56 -0800
committerGuy Harris <guy@alum.mit.edu>2011-12-08 22:51:23 -0800
commit8bee3c4aa0d902e7fd2e6a6040d6f79be8ccfb3e (patch)
tree5bfd37f4eec8f5b810b2a7e8a0400bf776981965
parent991ec881adc10b1692d417f9a572ba25f4beb20b (diff)
downloadlibpcap-8bee3c4aa0d902e7fd2e6a6040d6f79be8ccfb3e.tar.gz
Arrange to have pcap_close_all() earlier.
Do so before we put the adapter into monitor mode, so that if we can't arrange to clean up monitor mode on exit, we don't try to put the adapter into monitor mode.
-rw-r--r--pcap-linux.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index e0238142..d4f50b7d 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -862,6 +862,18 @@ added:
#endif
/*
+ * If we haven't already done so, arrange to have
+ * "pcap_close_all()" called when we exit.
+ */
+ if (!pcap_do_addexit(handle)) {
+ /*
+ * "atexit()" failed; don't put the interface
+ * in rfmon mode, just give up.
+ */
+ return PCAP_ERROR_RFMON_NOTSUP;
+ }
+
+ /*
* Now configure the monitor interface up.
*/
memset(&ifr, 0, sizeof(ifr));
@@ -902,18 +914,6 @@ added:
*/
pcap_add_to_pcaps_to_close(handle);
- /*
- * If we haven't already done so, arrange to have
- * "pcap_close_all()" called when we exit.
- */
- if (!pcap_do_addexit(handle)) {
- /*
- * "atexit()" failed; don't put the interface
- * in rfmon mode, just give up.
- */
- return PCAP_ERROR_RFMON_NOTSUP;
- }
-
return 1;
}
#endif /* HAVE_LIBNL */