]> The Tcpdump Group git mirrors - libpcap/commitdiff
Arrange to have pcap_close_all() earlier.
authorGuy Harris <[email protected]>
Fri, 9 Dec 2011 06:50:56 +0000 (22:50 -0800)
committerGuy Harris <[email protected]>
Fri, 9 Dec 2011 06:50:56 +0000 (22:50 -0800)
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.

pcap-linux.c

index e0238142427a394d7da324c5ead50dc37b3cf35b..d4f50b7d16e323df0e8afc438eb7a2f37482ece8 100644 (file)
@@ -861,6 +861,18 @@ added:
        nanosleep(&delay, NULL);
 #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.
         */
@@ -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 */