wlan: Updating wait condition in loggerApp thread.

Wait condition in logger thread is TRUE if gwlan_logging.filled_list
is not empty. So if gapp_pid is invalid then thread will be in
infinite loop.
Hence updating wait condition by removing dependence on
gwlan_logging.filled_list and adding new variable waitEvent, which
will be set before waking up the thread.

Change-Id: Idbcc04717a3d0531314ae3298b818fc1742ad3df
CRs-Fixed: 756467
diff --git a/CORE/SVC/src/logging/wlan_logging_sock_svc.c b/CORE/SVC/src/logging/wlan_logging_sock_svc.c
index 8b5c53a..16c0159 100644
--- a/CORE/SVC/src/logging/wlan_logging_sock_svc.c
+++ b/CORE/SVC/src/logging/wlan_logging_sock_svc.c
@@ -84,6 +84,8 @@
 	struct completion   shutdown_comp;
 	/* Indicates to logger thread to exit */
 	bool exit;
+	/* wakeup indication */
+	bool wakeEvent;
 	/* Holds number of dropped logs*/
 	unsigned int drop_count;
 	/* current logbuf to which the log will be filled to */
@@ -307,6 +309,11 @@
 		pr_err("%s\n", to_be_sent);
 	}
 
+	// wlan logging svc resources are not yet initialized
+	if (!gwlan_logging.pcur_node) {
+	    return -EIO;
+	}
+
 	/* Format the Log time [Secondselapsedinaday.microseconds] */
 	do_gettimeofday(&tv);
 	tlen = snprintf(tbuf, sizeof(tbuf), "[%s][%5lu.%06lu] ", current->comm,
@@ -317,11 +324,6 @@
 	total_log_len = length + tlen + 1 + 1;
 
 	spin_lock_irqsave(&gwlan_logging.spin_lock, flags);
-	// wlan logging svc resources are not yet initialized
-	if (!gwlan_logging.pcur_node) {
-		spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags);
-		return -EIO;
-	}
 
 	pfilled_length = &gwlan_logging.pcur_node->filled_length;
 
@@ -365,6 +367,7 @@
                  * register for the logs.
                  */
 		if ( (gapp_pid != INVALID_PID)) {
+			gwlan_logging.wakeEvent = TRUE;
 			wake_up_interruptible(&gwlan_logging.wait_queue);
 		}
 		else {
@@ -460,6 +463,7 @@
 			gapp_pid = INVALID_PID;
 			clear_default_logtoapp_log_level();
 			wlan_logging_srv_nl_ready_indication();
+			break;
 		} else {
 			skb = NULL;
 			ret = 0;
@@ -489,8 +493,9 @@
 	while (!gwlan_logging.exit) {
 		ret_wait_status = wait_event_interruptible(
 		    gwlan_logging.wait_queue,
-		    (!list_empty(&gwlan_logging.filled_list)
-		  || gwlan_logging.exit));
+		    (gwlan_logging.wakeEvent || gwlan_logging.exit));
+
+		gwlan_logging.wakeEvent = FALSE;
 
 		if (ret_wait_status == -ERESTARTSYS) {
 			pr_err("%s: wait_event_interruptible returned -ERESTARTSYS",
@@ -499,18 +504,18 @@
 		}
 
 		if (gwlan_logging.exit) {
-			pr_err("%s: Exiting the thread\n", __func__);
-			break;
+		    pr_err("%s: Exiting the thread\n", __func__);
+		    break;
 		}
 
 		if (INVALID_PID == gapp_pid) {
-			pr_err("%s: Invalid PID\n", __func__);
-			continue;
+		    pr_err("%s: Invalid PID\n", __func__);
+		    continue;
 		}
 
 		ret = send_filled_buffers_to_user();
 		if (-ENOMEM == ret) {
-			msleep(200);
+		    msleep(200);
 		}
 	}
 
@@ -552,6 +557,7 @@
 			wlan_queue_logmsg_for_app();
 		}
 		spin_unlock_bh(&gwlan_logging.spin_lock);
+		gwlan_logging.wakeEvent = TRUE;
 		wake_up_interruptible(&gwlan_logging.wait_queue);
 	} else {
 		/* This is to set the default levels (WLAN logging
@@ -609,6 +615,7 @@
 
 	init_waitqueue_head(&gwlan_logging.wait_queue);
 	gwlan_logging.exit = false;
+	gwlan_logging.wakeEvent = FALSE;
 	init_completion(&gwlan_logging.shutdown_comp);
 	gwlan_logging.thread = kthread_create(wlan_logging_thread, NULL,
 					"wlan_logging_thread");