The datausage module is used for network traffic statistics.
This commit adds parts of code of datausage module,
used in resourced module.
Change-Id: Idc695eeaf0f1e50dbdc83a9b7274f1b7d7fb950f
Signed-off-by: Przemyslaw Kedzierski <p.kedzierski@samsung.com>
SET(fw_name "resourced")
-SET(RESOURCED resourced)
SET(RESOURCED resourced)
INCLUDE_DIRECTORIES(${RESOURCED_INCLUDEDIR}
+ ${DATAUSAGE_SOURCE_DIR}/include
${APP-STAT_SOURCE_DIR}/include
- ${RESOURCED_SOURCE_DIR})
+ ${RESOURCED_SOURCE_DIR}
+ ${NETWORK_SOURCE_DIR}/include
+ )
INCLUDE(FindPkgConfig)
${MEMORY_SOURCE_DIR}
${PROC-STAT_SOURCE_DIR}/include
${APP-STAT_SOURCE_DIR}/include
+ ${DATAUSAGE_SOURCE_DIR}/include
${NETWORK_SOURCE_DIR}/include)
CONFIGURE_FILE(${INCLUDE_COMMON_DIR}/config.h.in
${INCLUDE_COMMON_DIR}/config.h)
SET (HEADERS
+ ${DATAUSAGE_SOURCE_DIR}/include/daemon-options.h
+ ${DATAUSAGE_SOURCE_DIR}/include/datausage-vconf-callbacks.h
${INCLUDE_COMMON_DIR}/config.h
${INCLUDE_COMMON_DIR}/config-parser.h
${INCLUDE_COMMON_DIR}/const.h
${COMMON_SOURCE_DIR}/file-helper.c
${COMMON_SOURCE_DIR}/module-data.c
${COMMON_SOURCE_DIR}/module.c
- ${RESOURCED_SOURCE_DIR}/daemon-options.c
+ ${DATAUSAGE_SOURCE_DIR}/counter.c
+ ${DATAUSAGE_SOURCE_DIR}/daemon-options.c
+ ${DATAUSAGE_SOURCE_DIR}/join-local.c
${COMMON_SOURCE_DIR}/lowmem-common.c
${COMMON_SOURCE_DIR}/swap-common.c
${COMMON_SOURCE_DIR}/cpu-common.c
--- /dev/null
+/*
+ * resourced
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file: counter.c
+ * @desc Entity for working with datausage counter.
+ *
+ */
+
+#include "app-stat.h"
+#include "counter.h"
+#include "macro.h"
+#include "trace.h"
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+
+struct counter_arg *init_counter_arg(struct daemon_opts *opts)
+{
+ struct counter_arg *result =
+ (struct counter_arg *)calloc(1, sizeof(struct counter_arg));
+
+ ret_value_msg_if(result == NULL, NULL, "Not enough memory\n");
+ result->pid = getpid();
+ result->opts = opts;
+ return result;
+}
+
+void finalize_carg(struct counter_arg *carg)
+{
+ free(carg);
+}
+
+void reschedule_count_timer(const struct counter_arg *carg, const double delay)
+{
+ ret_value_msg_if(!carg || !carg->ecore_timer, ,
+ "Invalid counter argument or carg_timer is null\n");
+ ecore_timer_delay(carg->ecore_timer,
+ delay - ecore_timer_pending_get(carg->ecore_timer));
+}
--- /dev/null
+/*
+ * resourced
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @file join.c
+ * @desc Implement Performance API. Joining performance control.
+ * Entity for creation cgroup
+ */
+
+#include "datausage-common.h"
+#include "macro.h"
+#include "module.h"
+#include "trace.h"
+
+resourced_ret_c join_net_cls(const char *app_id, const pid_t pid)
+{
+ struct netstat_data_type net_data;
+ int ret = RESOURCED_ERROR_NONE;
+ uint32_t args[2];
+ static const struct module_ops *net_stat;
+
+ if (net_stat == NULL) {
+ net_stat = find_module("datausage");
+ ret_value_msg_if(net_stat == NULL, ret,
+ "Can't find datausage module!");
+ }
+
+ args[0] = (uint32_t)app_id;
+ args[1] = (uint32_t)pid;
+
+ net_data.op_type = JOIN_NET_CLS;
+ net_data.args = args;
+
+ if (net_stat->control)
+ ret = net_stat->control(&net_data);
+ return ret;
+}
+
+
#include <Ecore_File.h>
#include "classid-helper.h"
+#include "datausage-common.h"
#include "proc-process.h"
#include "proc-main.h"
+#include "cgroup.h"
#include "proc-noti.h"
#include "trace.h"
#include "proc-winstate.h"
}
_SD("launch request %s, %d", app_name, pid);
- raise_update_classid();
+ /* init oom score adj value for preventing killing application during launching */
+ ret = join_net_cls(app_name, pid);
+ if (ret != RESOURCED_ERROR_NONE)
+ _E("Failed to start network counting.");
+ else
+ /* update_classid function is called
+ only in datausage modules */
+ raise_update_classid();
break;
case PROC_CGROUP_SET_RESUME_REQUEST:
if (ret != 0)
break;
+ proc_add_visibiliry(pid);
break;
case PROC_CGROUP_SET_INACTIVE:
ret = proc_set_inactive(pid, oom_score_adj);
return RESOURCED_ERROR_NONE;
}
-void reschedule_count_timer(const struct counter_arg *carg, const double delay)
-{
- ecore_timer_delay(carg->ecore_timer,
- delay - ecore_timer_pending_get(carg->ecore_timer));
-}
static void sig_term_handler(int sig)
{