From: Mayank Haarit Date: Tue, 22 May 2018 11:59:45 +0000 (+0530) Subject: Set netlink scan handle in non-blocking state X-Git-Tag: accepted/tizen/unified/20180612.044202~6 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fconnectivity%2Fnet-config.git;a=commitdiff_plain;h=20a35902233a1fc5f7188c7374af7afc4cd7f390 Set netlink scan handle in non-blocking state This patch is to set nl socket handle in non-blocking state. Change-Id: I7bb6b295445d9967a3d9cb725d76e01b7c2a08ca Signed-off-by: Mayank Haarit --- diff --git a/src/wifi-netlink-scan.c b/src/wifi-netlink-scan.c index 5fb87f7..f4fb530 100755 --- a/src/wifi-netlink-scan.c +++ b/src/wifi-netlink-scan.c @@ -111,6 +111,7 @@ static int ack_handler(struct nl_msg *msg, void *user_data) { int *err = user_data; *err = 0; + DBG(""); return NL_STOP; } @@ -680,9 +681,12 @@ static int __netconfig_request_netlink_scan(struct nl_sock *socket, nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err); nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err); nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL); + ret = nl_socket_set_nonblocking(socket); + DBG("Set the non-blocking mode [%d]", ret); /** Send NL80211_CMD_TRIGGER_SCAN to start the scan. */ ret = nl_send_auto_complete(socket, msg); + if (ret < 0) { DBG("nl_send_auto_complete() error: (%s)", nl_geterror(-ret)); goto out; @@ -691,19 +695,26 @@ static int __netconfig_request_netlink_scan(struct nl_sock *socket, DBG("Sent %d bytes to the kernel", ret); ssid_found = FALSE; - while (err > 0) + while (err > 0) { ret = nl_recvmsgs(socket, cb); - - if (ret < 0) { - DBG("nl_recvmsgs() ret: %d (%s)", ret, nl_geterror(-ret)); - goto out; + if (ret < 0) { + DBG("nl_recvmsgs() ret: %d (%s)", ret, nl_geterror(-ret)); + goto out; + } } - while (!results.done) - nl_recvmsgs(socket, cb); + while (!results.done) { + ret = nl_recvmsgs(socket, cb); + if (ret < 0 || err < 0) { + DBG("scan failed"); + ret = -1; + goto out; + } + } if (results.aborted) { DBG("scan aborted"); + ret = -1; goto out; }