Fix: SIGPIPE issue while querying softap enabled status
Before downloading commands to driver through softap SDK we are checking if SoftAP is enabled are not by running ps in popen. This sometime throws SIGPIPE error (signal) which is not handled, due to this we were facing application crash. To fix this we modify to check the operation mode of the driver through ioctl. Change-Id: Ia0703ff343d401801655d3b666ade66107a4789e CRs-Fixed: 535340
This commit is contained in:
committed by
Gerrit Code Review
parent
fe07ff9ee2
commit
52fd77178b
@@ -434,26 +434,22 @@ s32 wifi_qsap_stop_bss(void)
|
||||
|
||||
s32 is_softap_enabled(void)
|
||||
{
|
||||
FILE *fp;
|
||||
char buf[1024];
|
||||
s32 mode = 0;
|
||||
int ret;
|
||||
|
||||
fp = popen("ps", "r");
|
||||
if (fp == NULL) {
|
||||
ALOGE("Failed to open file");
|
||||
ret = qsap_get_mode(&mode);
|
||||
if (eSUCCESS != ret) {
|
||||
ALOGD("Failed to get the mode of operation\n");
|
||||
return eERR_UNKNOWN;
|
||||
}
|
||||
|
||||
while (fgets(buf, sizeof(buf)-1, fp) != NULL) {
|
||||
if(NULL !=(strstr(buf,"hostapd")))
|
||||
{
|
||||
pclose(fp);
|
||||
ALOGD("HOSTAPD enabled\n");
|
||||
return ENABLE;
|
||||
}
|
||||
if (mode == IW_MODE_MASTER) {
|
||||
ALOGD("HOSTAPD Enabled\n");
|
||||
return ENABLE;
|
||||
}
|
||||
|
||||
ALOGD("HOSTAPD disabled\n");
|
||||
pclose(fp);
|
||||
ALOGD("HOSTAPD Disabled\n");
|
||||
|
||||
return DISABLE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1256,6 +1256,57 @@ error:
|
||||
return eERR_GET_AUTO_CHAN;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the mode of operation.
|
||||
*/
|
||||
int qsap_get_mode(s32 *pmode)
|
||||
{
|
||||
int sock;
|
||||
struct iwreq wrq;
|
||||
s8 interface[MAX_CONF_LINE_LEN];
|
||||
u32 len = MAX_CONF_LINE_LEN;
|
||||
s8 *pif;
|
||||
int ret;
|
||||
sap_auto_channel_info sap_autochan_info;
|
||||
s32 *pchan;
|
||||
|
||||
*pmode = -1;
|
||||
if(NULL == (pif = qsap_get_config_value(pconffile,
|
||||
&qsap_str[STR_INTERFACE], interface, &len))) {
|
||||
ALOGD("%s :interface error \n", __func__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
interface[len] = '\0';
|
||||
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if(sock < 0) {
|
||||
ALOGD("%s :socket error \n", __func__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
memset(&wrq, 0, sizeof(wrq));
|
||||
strlcpy(wrq.ifr_name, pif, sizeof(wrq.ifr_name));
|
||||
|
||||
ret = ioctl(sock, SIOCGIWMODE, &wrq);
|
||||
if(ret < 0) {
|
||||
ALOGE("%s: ioctl failure \n",__func__);
|
||||
close(sock);
|
||||
goto error;
|
||||
}
|
||||
|
||||
*pmode = *(s32 *)(&wrq.u.mode);
|
||||
ALOGE("%s: ioctl Get Mode = %d \n",__func__, *pmode);
|
||||
close(sock);
|
||||
return eSUCCESS;
|
||||
|
||||
error:
|
||||
*pmode = -1;
|
||||
ALOGE("%s: (Failure) ioctl Get Mode = %d \n",__func__, *pmode);
|
||||
return eERR_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the channel Range for soft AP.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user