Use heap instead of stack, to aviod large stack usage issue in __process_contr_reply() 18/156018/1 accepted/tizen/unified/20171018.165230 submit/tizen/20171018.043426
authorNishant Chaprana <n.chaprana@samsung.com>
Tue, 17 Oct 2017 03:17:50 +0000 (08:47 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Tue, 17 Oct 2017 03:17:50 +0000 (08:47 +0530)
Change-Id: I447c0cca6658995f355693f0923c9395cabe0468
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
packaging/stc-manager.spec
src/monitor/stc-monitor.c

index d0d5348..c1914df 100644 (file)
@@ -1,6 +1,6 @@
 Name:       stc-manager
 Summary:    STC(Smart Traffic Control) manager
-Version:    0.0.38
+Version:    0.0.39
 Release:    0
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
index 2fde42c..8b18657 100755 (executable)
@@ -1123,12 +1123,11 @@ static gboolean __process_contr_reply(GIOChannel *source,
                                      gpointer user_data)
 {
        int sock = g_io_channel_unix_get_fd(source);
-       struct genl ans;
+       struct genl *ans;
        int ret;
        stc_s *stc = stc_get_manager();
 
-       if ((condition & G_IO_ERR) ||
-           (condition & G_IO_HUP) ||
+       if ((condition & G_IO_ERR) || (condition & G_IO_HUP) ||
            (condition & G_IO_NVAL)) {
                /* G_IO_ERR/G_IO_HUP/G_IO_NVAL received */
 
@@ -1140,23 +1139,29 @@ static gboolean __process_contr_reply(GIOChannel *source,
                return FALSE;
        }
 
+       ans = MALLOC0(struct genl, 1);
+       if (ans == NULL) {
+               STC_LOGE("Failed allocate memory to genl reply message");
+               return TRUE;
+       }
+
        if (stc == NULL) {
                STC_LOGE("Can't get stc data");
                goto out;
        }
 
-       ret = read_netlink(sock,
-                          &ans, sizeof(struct genl));
+       ret = read_netlink(sock, ans, sizeof(struct genl));
        /* STC_LOGD("Counter data received ret [%d]", ret); */
        if (ret == 0)
                goto out;
 
        stc->carg->ans_len = ret;
-       __process_network_counter(&ans, stc->carg);
+       __process_network_counter(ans, stc->carg);
 
        g_idle_add(__flush_apps_stats_to_database, NULL);
        g_idle_add(__flush_rstns_counter_to_database, NULL);
 out:
+       FREE(ans);
        return TRUE;
 }