hostapd: correctly handle macfile uci option
[openwrt.git] / package / network / services / hostapd / patches / 620-scan_wait.patch
1 --- a/hostapd/main.c
2 +++ b/hostapd/main.c
3 @@ -33,6 +33,8 @@
4  extern int wpa_debug_level;
5  extern int wpa_debug_show_keys;
6  extern int wpa_debug_timestamp;
7 +static int daemonize = 0;
8 +static char *pid_file = NULL;
9  
10  extern struct wpa_driver_ops *wpa_drivers[];
11  
12 @@ -147,6 +149,14 @@ static void hostapd_logger_cb(void *ctx,
13  }
14  #endif /* CONFIG_NO_HOSTAPD_LOGGER */
15  
16 +static void hostapd_setup_complete_cb(void *ctx)
17 +{
18 +       if (daemonize && os_daemonize(pid_file)) {
19 +               perror("daemon");
20 +               return;
21 +       }
22 +       daemonize = 0;
23 +}
24  
25  /**
26   * hostapd_init - Allocate and initialize per-interface data
27 @@ -190,6 +200,7 @@ static struct hostapd_iface * hostapd_in
28                 if (hapd == NULL)
29                         goto fail;
30                 hapd->msg_ctx = hapd;
31 +               hapd->setup_complete_cb = hostapd_setup_complete_cb;
32         }
33  
34         return hapd_iface;
35 @@ -429,8 +440,6 @@ static void hostapd_global_deinit(const 
36  #endif /* CONFIG_NATIVE_WINDOWS */
37  
38         eap_server_unregister_methods();
39 -
40 -       os_daemonize_terminate(pid_file);
41  }
42  
43  
44 @@ -456,11 +465,6 @@ static int hostapd_global_run(struct hap
45         }
46  #endif /* EAP_SERVER_TNC */
47  
48 -       if (daemonize && os_daemonize(pid_file)) {
49 -               perror("daemon");
50 -               return -1;
51 -       }
52 -
53         eloop_run();
54  
55         return 0;
56 @@ -564,8 +568,7 @@ int main(int argc, char *argv[])
57         struct hapd_interfaces interfaces;
58         int ret = 1;
59         size_t i;
60 -       int c, debug = 0, daemonize = 0;
61 -       char *pid_file = NULL;
62 +       int c, debug = 0;
63         const char *log_file = NULL;
64         const char *entropy_file = NULL;
65