iwcap: fix handling kill signal during dump
authorFelix Fietkau <nbd@nbd.name>
Thu, 9 Mar 2017 07:53:52 +0000 (08:53 +0100)
committerJo-Philipp Wich <jo@mein.io>
Wed, 13 Dec 2017 13:44:05 +0000 (14:44 +0100)
Do not run another loop iteration before checking the stop flag

Signed-off-by: Felix Fietkau <nbd@nbd.name>
(cherry picked from commit 2f09a1e3c950c9b2993ae52d1b0e78317c344470)

package/network/utils/iwcap/src/iwcap.c

index 6bf25c57ddfe7d8becfb3c6090888f7688675459..bc69550ef38dc675bdfc5e8a7790223c8c42e327 100644 (file)
@@ -490,19 +490,7 @@ int main(int argc, char **argv)
        /* capture loop */
        while (1)
        {
-               if (run_stop)
-               {
-                       msg("Shutting down ...\n");
-
-                       if (promisc)
-                               set_promisc(0);
-
-                       if (ring)
-                               ringbuf_free(ring);
-
-                       return 0;
-               }
-               else if (run_dump)
+               if (run_dump)
                {
                        msg("Dumping ring to %s ...\n", output);
 
@@ -535,6 +523,18 @@ int main(int argc, char **argv)
 
                        run_dump = 0;
                }
+               if (run_stop)
+               {
+                       msg("Shutting down ...\n");
+
+                       if (promisc)
+                               set_promisc(0);
+
+                       if (ring)
+                               ringbuf_free(ring);
+
+                       return 0;
+               }
 
                pktlen = recvfrom(capture_sock, pktbuf, sizeof(pktbuf), 0, NULL, 0);
                frames_captured++;