SET(BUILD_SOURCE
src/main.c
- src/util.c
src/pkgmgr.c
src/shortcut_service.c
src/badge_service.c
src/notification_service.c
src/service_common.c
- src/critical_log.c
)
STRING(REPLACE "-L-l" "-l" pkg_fixed_LDFLAGS ${pkg_LDFLAGS})
+++ /dev/null
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * 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.
- */
-
-extern int critical_log(const char *func, int line, const char *fmt, ...);
-extern int critical_log_init(const char *tag);
-extern void critical_log_fini(void);
-
-#define CRITICAL_LOG(args...) critical_log(__func__, __LINE__, args)
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * 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.
- */
-
-extern double util_timestamp(void);
-extern void util_setup_log_disk(void);
-extern const char *util_basename(const char *name);
-
-#define SCHEMA_FILE "file://"
-#define SCHEMA_PIXMAP "pixmap://"
-#define SCHEMA_SHM "shm://"
-
-#define CRITICAL_SECTION_BEGIN(handle) \
-do { \
- int ret; \
- ret = pthread_mutex_lock(handle); \
- if (ret != 0) \
- ERR("pthread_mutex_lock: %d", ret); \
-} while (0)
-
-#define CRITICAL_SECTION_END(handle) \
-do { \
- int ret; \
- ret = pthread_mutex_unlock(handle); \
- if (ret != 0) \
- ERR("pthread_mutex_unlock: %d", ret); \
-} while (0)
-
-#define CANCEL_SECTION_BEGIN() do { \
- int ret; \
- ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); \
- if (ret != 0) \
- ERR("Unable to set cancelate state: %d", ret); \
-} while (0)
-
-#define CANCEL_SECTION_END() do { \
- int ret; \
- ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); \
- if (ret != 0) \
- ERR("Unable to set cancelate state: %d", ret); \
-} while (0)
-
-#define CLOSE_PIPE(p) do { \
- int status; \
- status = close(p[PIPE_READ]); \
- if (status < 0) \
- ERR("close: %d", errno); \
- status = close(p[PIPE_WRITE]); \
- if (status < 0) \
- ERR("close: %d", errno); \
-} while (0)
-
-#define PIPE_READ 0
-#define PIPE_WRITE 1
-#define PIPE_MAX 2
-
-/* End of a file */
+++ /dev/null
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * 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.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <string.h>
-#include <libgen.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <pthread.h>
-
-#include <dlog.h>
-#include <Eina.h>
-
-#include "conf.h"
-#include "debug.h"
-#include "util.h"
-#include "service_common.h"
-#include "critical_log.h"
-
-static struct {
- FILE *fp;
- int file_id;
- int nr_of_lines;
- char *filename;
- pthread_mutex_t cri_lock;
-} s_info = {
- .fp = NULL,
- .file_id = 0,
- .nr_of_lines = 0,
- .filename = NULL,
- .cri_lock = PTHREAD_MUTEX_INITIALIZER,
-};
-
-static inline void rotate_log(void)
-{
- char *filename;
- int namelen;
-
- if (s_info.nr_of_lines < CONF_MAX_LOG_LINE)
- return;
-
- s_info.file_id = (s_info.file_id + 1) % CONF_MAX_LOG_FILE;
-
- namelen = strlen(s_info.filename) + strlen(CONF_LOG_PATH) + 30;
- filename = malloc(namelen);
- if (filename) {
- snprintf(filename, namelen, "%s/%d_%s.%d", CONF_LOG_PATH, s_info.file_id, s_info.filename, getpid());
- if (s_info.fp) {
- if (fclose(s_info.fp) != 0)
- ERR("fclose [%d]", errno);
- }
-
- if (access(filename, F_OK) == 0)
- unlink(filename);
-
- s_info.fp = fopen(filename, "w+x");
- if (!s_info.fp)
- ERR("Failed to open a file [%s][%d]", filename, errno);
-
- free(filename);
- }
-
- s_info.nr_of_lines = 0;
-}
-
-HAPI int critical_log(const char *func, int line, const char *fmt, ...)
-{
- va_list ap;
- int ret;
-
- if (!s_info.fp)
- return SERVICE_COMMON_ERROR_IO_ERROR;
-
- CRITICAL_SECTION_BEGIN(&s_info.cri_lock);
-
- fprintf(s_info.fp, "%lf [%s:%d] ", util_timestamp(), util_basename((char *)func), line);
-
- va_start(ap, fmt);
- ret = vfprintf(s_info.fp, fmt, ap);
- va_end(ap);
-
- fflush(s_info.fp);
-
- s_info.nr_of_lines++;
- rotate_log();
-
- CRITICAL_SECTION_END(&s_info.cri_lock);
- return ret;
-}
-
-HAPI int critical_log_init(const char *name)
-{
- int namelen;
- int ret = SERVICE_COMMON_ERROR_NONE;
- char *filename;
-
- if (s_info.fp)
- return SERVICE_COMMON_ERROR_NONE;
-
- s_info.filename = strdup(name);
- if (!s_info.filename) {
- ERR("Failed to create a log file");
- return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
- }
-
- namelen = strlen(name) + strlen(CONF_LOG_PATH) + 30;
-
- filename = malloc(namelen);
- if (!filename) {
- ERR("Failed to create a log file");
- ret = SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
- goto out;
- }
-
- snprintf(filename, namelen, "%s/%d_%s.%d", CONF_LOG_PATH, s_info.file_id, name, getpid());
-
- if (access(filename, F_OK) == 0)
- unlink(filename);
-
- s_info.fp = fopen(filename, "w+x");
- if (!s_info.fp) {
- ERR("fopen [%s][%d]", filename, errno);
- ret = SERVICE_COMMON_ERROR_IO_ERROR;
- }
-
-out:
- if (s_info.filename) {
- free(s_info.filename);
- s_info.filename = NULL;
- }
-
- if (filename)
- free(filename);
-
- return ret;
-}
-
-HAPI void critical_log_fini(void)
-{
- if (s_info.filename) {
- free(s_info.filename);
- s_info.filename = NULL;
- }
-
- if (s_info.fp) {
- if (fclose(s_info.fp) != 0)
- ERR("fclose [%d]", errno);
- s_info.fp = NULL;
- }
-}
-
-/* End of a file */
#include <locale.h>
#include "debug.h"
-#include "util.h"
-#include "critical_log.h"
#include "service_common.h"
#include "shortcut_service.h"
#include "notification_service.h"
struct signalfd_siginfo fdsi;
ssize_t size;
int sfd;
- int cfd;
sfd = g_io_channel_unix_get_fd(channel);
}
if (fdsi.ssi_signo == SIGTERM) {
- CRITICAL_LOG("Terminated(SIGTERM)");
- cfd = creat("/tmp/.stop.provider", 0644);
- if (cfd < 0 || close(cfd) < 0)
- ERR("stop.provider [%d]", errno);
+ ERR("Terminated(SIGTERM)");
g_main_loop_quit(main_loop);
} else {
- CRITICAL_LOG("Unknown SIG[%d] received", fdsi.ssi_signo);
+ ERR("Unknown SIG[%d] received", fdsi.ssi_signo);
}
return TRUE;
ret = sigemptyset(&mask);
if (ret < 0) {
- CRITICAL_LOG("sigemptyset : %d", errno);
+ ERR("sigemptyset : %d", errno);
return -1;
}
ret = sigaddset(&mask, SIGTERM);
if (ret < 0) {
- CRITICAL_LOG("sigaddset: %d", errno);
+ ERR("sigaddset: %d", errno);
return -1;
}
ret = sigprocmask(SIG_BLOCK, &mask, NULL);
if (ret < 0) {
- CRITICAL_LOG("sigprocmask: %d", errno);
+ ERR("sigprocmask: %d", errno);
return -1;
}
sfd = signalfd(-1, &mask, SFD_NONBLOCK);
if (sfd < 0) {
- CRITICAL_LOG("signalfd: %d", errno);
+ ERR("signalfd: %d", errno);
return -1;
}
g_io_channel_unref(channel);
app_terminate();
- critical_log_fini();
}
int main(int argc, char *argv[])
{
- int ret;
int restart_count = 0;
main_loop = g_main_loop_new(NULL, FALSE);
#endif
vconf_get_int(VCONFKEY_MASTER_RESTART_COUNT, &restart_count);
- util_setup_log_disk();
-
- /*!
- * How could we care this return values?
- * Is there any way to print something on the screen?
- */
- ret = critical_log_init(util_basename(argv[0]));
- if (ret < 0)
- ERR("Failed to init the critical log");
app_create();
sd_notify(0, "READY=1");
#include <Ecore.h>
#include "service_common.h"
-#include "util.h"
#include "debug.h"
#include "pkgmgr.h"
#include "conf.h"
+++ /dev/null
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * 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.
- */
-
-#include <stdio.h>
-#include <sys/time.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/vfs.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <ctype.h>
-#include <sys/statvfs.h>
-#include <sys/mount.h>
-#include <strings.h>
-
-#include <sys/smack.h>
-#include <dlog.h>
-#include <Eina.h>
-#include <Ecore.h>
-
-#include "util.h"
-#include "debug.h"
-#include "conf.h"
-
-#define DELIM ';'
-
-int errno;
-
-HAPI double util_timestamp(void)
-{
-#if defined(_USE_ECORE_TIME_GET)
- return ecore_time_get();
-#else
- struct timeval tv;
- if (gettimeofday(&tv, NULL) < 0) {
- static unsigned long internal_count = 0;
- ERR("gettimeofday [%d]", errno);
- tv.tv_sec = internal_count++;
- tv.tv_usec = 0;
- }
-
- return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f;
-#endif
-}
-
-HAPI void util_setup_log_disk(void)
-{
- if (access(CONF_LOG_PATH, R_OK | W_OK | X_OK) == 0) {
- DBG("[%s] is already accessible", CONF_LOG_PATH);
- return;
- }
-
- DBG("Initiate the critical log folder [%s]", CONF_LOG_PATH);
- if (mkdir(CONF_LOG_PATH, 0755) < 0)
- ERR("mkdir: %d", errno);
-}
-
-HAPI const char *util_basename(const char *name)
-{
- int length;
- length = name ? strlen(name) : 0;
- if (!length)
- return ".";
-
- while (--length > 0 && name[length] != '/')
- ;
-
- return length <= 0 ? name : (name + length + (name[length] == '/'));
-}
-
-/* End of a file */