Merge cfd9df32172f299db16a2490791f256c568ddbf0 on remote branch
Change-Id: Iadcfaec459b28d8f53b3aeb96547e11a3a8f5786
diff --git a/cld80211-lib/cld80211_lib.c b/cld80211-lib/cld80211_lib.c
index bc082a9..1ca085a 100644
--- a/cld80211-lib/cld80211_lib.c
+++ b/cld80211-lib/cld80211_lib.c
@@ -450,6 +450,11 @@
ALOGI("%s: Exiting poll", getprogname());
break;
}
+ if (ctx->is_terminating) {
+ ALOGI("Exiting poll as program:%s is terminating",
+ getprogname());
+ break;
+ }
} while (1);
nl_cb_put(cb);
@@ -521,3 +526,13 @@
cleanup_exit_sockets(ctx);
free (ctx);
}
+
+void cld80211_stop_recv(struct cld80211_ctx *ctx, bool is_terminating)
+{
+ if (!ctx || !ctx->sock) {
+ ALOGE("%s: ctx/sock is NULL", getprogname());
+ return;
+ }
+ ALOGE("%s: Program is terminating:%d", getprogname(), is_terminating);
+ ctx->is_terminating = is_terminating;
+}
diff --git a/cld80211-lib/cld80211_lib.h b/cld80211-lib/cld80211_lib.h
index 2503f2a..c786361 100644
--- a/cld80211-lib/cld80211_lib.h
+++ b/cld80211-lib/cld80211_lib.h
@@ -47,6 +47,7 @@
int exit_sockets[2];
int sock_buf_size;
int nlctrl_familyid;
+ bool is_terminating;
};
/**
@@ -150,6 +151,12 @@
* first to exit gracefully.
*/
void exit_cld80211_recv(struct cld80211_ctx *ctx);
+
+/**
+ * Client has to inform to exit gracefully during polling and reset the flag
+ * accordingly.
+ */
+void cld80211_stop_recv(struct cld80211_ctx *ctx, bool is_terminating);
#ifdef __cplusplus
}
#endif