diff options
author | Jouni Malinen <j@w1.fi> | 2011-10-23 13:20:52 +0300 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2011-10-23 13:20:52 +0300 |
commit | 7756114f6aa56c70cc980e0575cac2d6ebfe0f69 (patch) | |
tree | 6bc16ab3827dead2a05650e3b5d00e82c56b161f /hostapd/main.c | |
parent | 3803bd331de647bb99a80db00cf19361b0b04be2 (diff) | |
download | external_wpa_supplicant_8_ti-7756114f6aa56c70cc980e0575cac2d6ebfe0f69.zip external_wpa_supplicant_8_ti-7756114f6aa56c70cc980e0575cac2d6ebfe0f69.tar.gz external_wpa_supplicant_8_ti-7756114f6aa56c70cc980e0575cac2d6ebfe0f69.tar.bz2 |
Postpone global_init() call until first driver instance is initialized
This avoids allocating global driver state for driver wrappers that
are built in but not used. This can save some resources and avoids
failures with driver_nl80211.c that is now initializing netlink
connections for nl80211 in global_init().
Diffstat (limited to 'hostapd/main.c')
-rw-r--r-- | hostapd/main.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/hostapd/main.c b/hostapd/main.c index d5a0fd7..99c137d 100644 --- a/hostapd/main.c +++ b/hostapd/main.c @@ -257,10 +257,22 @@ static int hostapd_driver_init(struct hostapd_iface *iface) os_memset(¶ms, 0, sizeof(params)); for (i = 0; wpa_drivers[i]; i++) { - if (wpa_drivers[i] == hapd->driver) { - params.global_priv = global.drv_priv[i]; - break; + if (wpa_drivers[i] != hapd->driver) + continue; + + if (global.drv_priv[i] == NULL && + wpa_drivers[i]->global_init) { + global.drv_priv[i] = wpa_drivers[i]->global_init(); + if (global.drv_priv[i] == NULL) { + wpa_printf(MSG_ERROR, "Failed to initialize " + "driver '%s'", + wpa_drivers[i]->name); + return -1; + } } + + params.global_priv = global.drv_priv[i]; + break; } params.bssid = b; params.ifname = hapd->conf->iface; @@ -425,16 +437,6 @@ static int hostapd_global_init(struct hapd_interfaces *interfaces, global.drv_priv = os_zalloc(global.drv_count * sizeof(void *)); if (global.drv_priv == NULL) return -1; - for (i = 0; wpa_drivers[i]; i++) { - if (!wpa_drivers[i]->global_init) - continue; - global.drv_priv[i] = wpa_drivers[i]->global_init(); - if (global.drv_priv[i] == NULL) { - wpa_printf(MSG_ERROR, "Failed to initialize driver " - "'%s'", wpa_drivers[i]->name); - return -1; - } - } return 0; } |