hostapd: add back the patch that waits for interface bringup in ht40, it got lost...
[openwrt.git] / package / network / services / hostapd / patches / 620-scan_wait.patch
1 --- a/hostapd/main.c
2 +++ b/hostapd/main.c
3 @@ -32,6 +32,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 @@ -279,6 +281,14 @@ static int hostapd_driver_init(struct ho
13         return 0;
14  }
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  static struct hostapd_iface *
26  hostapd_interface_init(struct hapd_interfaces *interfaces,
27 @@ -298,6 +308,7 @@ hostapd_interface_init(struct hapd_inter
28                         iface->bss[0]->conf->logger_stdout_level--;
29         }
30  
31 +       iface->bss[0]->setup_complete_cb = hostapd_setup_complete_cb;
32         if (iface->conf->bss[0].iface[0] != 0 ||
33             hostapd_drv_none(iface->bss[0])) {
34                 if (hostapd_driver_init(iface) ||
35 @@ -310,7 +321,6 @@ hostapd_interface_init(struct hapd_inter
36         return iface;
37  }
38  
39 -
40  /**
41   * handle_term - SIGINT and SIGTERM handler to terminate hostapd process
42   */
43 @@ -425,8 +435,6 @@ static void hostapd_global_deinit(const 
44  #endif /* CONFIG_NATIVE_WINDOWS */
45  
46         eap_server_unregister_methods();
47 -
48 -       os_daemonize_terminate(pid_file);
49  }
50  
51  
52 @@ -452,11 +460,6 @@ static int hostapd_global_run(struct hap
53         }
54  #endif /* EAP_SERVER_TNC */
55  
56 -       if (daemonize && os_daemonize(pid_file)) {
57 -               perror("daemon");
58 -               return -1;
59 -       }
60 -
61         eloop_run();
62  
63         return 0;
64 @@ -540,8 +543,7 @@ int main(int argc, char *argv[])
65         struct hapd_interfaces interfaces;
66         int ret = 1;
67         size_t i;
68 -       int c, debug = 0, daemonize = 0;
69 -       char *pid_file = NULL;
70 +       int c, debug = 0;
71         const char *log_file = NULL;
72         const char *entropy_file = NULL;
73