Update the error log consistently 15/171815/1 accepted/tizen/unified/20180312.145812 submit/tizen/20180308.033110
authorYoungHun Kim <yh8004.kim@samsung.com>
Wed, 7 Mar 2018 10:59:39 +0000 (19:59 +0900)
committerYoungHun Kim <yh8004.kim@samsung.com>
Wed, 7 Mar 2018 10:59:42 +0000 (19:59 +0900)
Change-Id: Ic6185b24091c04d29edbd9a6e7e352fa227b1bc1

client/src/muse_client.c
core/include/muse_core_internal.h
core/src/muse_core.c
packaging/mused.spec
server/src/muse_server.c

index 57b1547f5144cbdd6c328b537adb8fef9fe621a9..58d7040451de5c3040ee220a5a0e5695c1afd2bf 100644 (file)
@@ -152,7 +152,7 @@ static int _mc_new(muse_channel_e channel)
 
        if (fcntl(sock_fd, F_SETFD, FD_CLOEXEC) < 0) {
                strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
-               LOGE("unable to set on ctrls socket fd %d: %s", sock_fd, err_msg);
+               LOGE("unable to set on ctrl socket fd %d: %s", sock_fd, err_msg);
                close(sock_fd);
                return ret;
        }
index 8ecc109a090e8120226ee3c89b79dc3dad2055e9..3b692b1de58e0f4e867b71aa2b9815f6f6df0c5a 100644 (file)
@@ -65,6 +65,8 @@ extern "C" {
 #define PERSIST                                                0x10
 
 #define MUSE_ERR                                       -1
+#define SEND_FAIL                                      -1
+#define RECV_FAIL                                      -1
 #define MUSE_PARAM_MAX                         10
 
 #define PARSE_ERROR                                    -1
index 94e99547b2276ad8eb49ebf5df8e34bec944369f..4019d5741f285e552b2b1310ca154f1a04b5cca2 100644 (file)
@@ -27,6 +27,8 @@
 #define MUSE_WATCHDOG_CHECK_COUNT                      3
 #define MUSE_WATCHDOG_TIMER_PERIOD                     5
 
+const char *msg_type[] = { "normal type", "fds type" };
+
 static GMutex msg_lock;
 static GMutex msg_ipc_lock;
 
@@ -191,12 +193,12 @@ int muse_core_connection_close(int sock_fd)
 
        if (shutdown(sock_fd, SHUT_RDWR) == MUSE_ERR) {
                strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
-               LOGE("[%d] failed to shutdown %s", sock_fd, err_msg);
+               LOGE("[%d] failed to shutdown [error %s %d]", sock_fd, err_msg, errno);
        }
 
        if (close(sock_fd) == MUSE_ERR) {
                strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
-               LOGE("[%d] failed to close %s", sock_fd, err_msg);
+               LOGE("[%d] failed to close [error %s %d]", sock_fd, err_msg, errno);
        }
 
        LOGI("[%d] connection close", sock_fd);
@@ -213,7 +215,7 @@ int muse_core_set_nonblocking(int fd, bool value)
                flags = value ? (flags | O_NONBLOCK) : (flags & ~O_NONBLOCK);
                if (fcntl(fd, F_SETFL, flags) == -1) {
                        strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
-                       LOGE("fcntl (%d, F_SETFL, %d) %s", fd, flags, err_msg);
+                       LOGE("fcntl (%d, F_SETFL, %d) [error %s %d]", fd, flags, err_msg, errno);
                        return MM_ERROR_FILE_INTERNAL;
                } else {
                        LOGD("fcntl (%d, F_SETFL)", fd);
@@ -238,13 +240,13 @@ int muse_core_set_socket_timeout(int sock_fd, int timeout_sec)
 
        if (setsockopt(sock_fd, SOL_SOCKET, SO_SNDTIMEO, (void *)&tv, (socklen_t)sizeof(tv)) == MUSE_ERR) {
                strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
-               LOGE("[%d] Failed to set socket send timeout option (%s) %d", sock_fd, err_msg, errno);
+               LOGE("[%d] Failed to set socket send timeout option [error %s %d]", sock_fd, err_msg, errno);
                return MM_ERROR_UNKNOWN;
        }
 
        if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, (void *)&tv, (socklen_t)sizeof(tv)) == MUSE_ERR) {
                strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
-               LOGE("[%d] Failed to set socket recv timeout option (%s) %d", sock_fd, err_msg, errno);
+               LOGE("[%d] Failed to set socket recv timeout option [error %s %d]", sock_fd, err_msg, errno);
                return MM_ERROR_UNKNOWN;
        }
 
@@ -298,22 +300,22 @@ int muse_core_msg_send_fd(int sock_fd, int *fds, const char *buf)
        msg_info.marker = MUSE_MSG_HEAD;
        msg_info.size = strlen(buf);
 
-       /*LOGD("send [t:%d,s:%d] [%s]", msg_info.type, msg_info.size, buf);*/
-
        g_mutex_lock(&msg_ipc_lock);
 
        ret = send(sock_fd, &msg_info, sizeof(muse_msg_info_t), 0);
        if (ret != sizeof(muse_msg_info_t)) {
-               LOGE("msg info [t:%d,s:%d] send failed : %d, errno %d",
-                       msg_info.type, msg_info.size, ret, errno);
+               strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
+               LOGE("msg info [type : %s size : %d] send failed : %d [error %s %d]", msg_type[msg_info.type], msg_info.size, ret, err_msg, errno);
 
                goto _MSG_SEND_DONE;
        }
 
        if (msg_info.type == MUSE_MSG_TYPE_NORMAL) {
                ret = send(sock_fd, buf, msg_info.size, 0);
-               if (ret != (int)msg_info.size)
-                       LOGE("send failed : %d, [%s], errno %d", ret, buf, errno);
+               if (ret != (int)msg_info.size) {
+                       strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
+                       LOGE("[%s] send failed : %d [error %s %d]", buf, ret, err_msg, errno);
+               }
 
                goto _MSG_SEND_DONE;
        }
@@ -346,7 +348,7 @@ int muse_core_msg_send_fd(int sock_fd, int *fds, const char *buf)
                msg.msg_controllen = cptr->cmsg_len;
        }
 
-       if ((ret = sendmsg(sock_fd, &msg, 0)) == MUSE_ERR) {
+       if ((ret = sendmsg(sock_fd, &msg, 0)) == SEND_FAIL) {
                strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
                LOGE("[%d] fail to send msg - [error %s %d]", sock_fd, err_msg, errno);
        }
@@ -375,21 +377,21 @@ int muse_core_msg_recv_fd(int sock_fd, char *buf, int *out_fd)
 
        g_return_val_if_fail(buf, MM_ERROR_INVALID_ARGUMENT);
 
-       /* get msg type and length */
+       /* get the msg type and length */
        if (!muse_core_msg_recv_len(sock_fd, (char *)&msg_info, sizeof(muse_msg_info_t))) {
                LOGE("msg info receive failed");
-               return -1;
+               return RECV_FAIL;
        }
 
        if (msg_info.marker != MUSE_MSG_HEAD) {
                LOGE("invalid marker 0x%x", msg_info.marker);
-               return -1;
+               return RECV_FAIL;
        }
 
        if (msg_info.type == MUSE_MSG_TYPE_NORMAL) {
                if (!muse_core_msg_recv_len(sock_fd, buf, msg_info.size)) {
                        LOGE("msg receive failed");
-                       return -1;
+                       return RECV_FAIL;
                }
 
                ret = msg_info.size;
@@ -406,9 +408,9 @@ int muse_core_msg_recv_fd(int sock_fd, char *buf, int *out_fd)
                msg.msg_control = data;
                msg.msg_controllen = sizeof(data);
 
-               if ((ret = recvmsg(sock_fd, &msg, 0)) == MUSE_ERR) {
+               if ((ret = recvmsg(sock_fd, &msg, 0)) == RECV_FAIL) {
                        strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
-                       LOGE("fail to receive msg (%s)", err_msg);
+                       LOGE("fail to receive msg [error %s %d]", err_msg, errno);
                        return ret;
                }
 
@@ -421,8 +423,6 @@ int muse_core_msg_recv_fd(int sock_fd, char *buf, int *out_fd)
 
        buf[ret] = '\0';
 
-       /*LOGD("recv [t:%d,s:%d] [%s]", msg_info.type, msg_info.size, buf);*/
-
        return ret;
 }
 
@@ -632,7 +632,7 @@ bool muse_core_msg_recv_len(int fd, char *buf, int msg_len)
                recv_len = recv(fd, buf + offset, msg_len - offset, 0);
                if (recv_len < 0) {
                        strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
-                       LOGE("[fd %d] recv : %s (%d)", fd, err_msg, errno);
+                       LOGE("[fd %d] recv failed [error %s %d]", fd, err_msg, errno);
                        return false;
                } else if (recv_len == 0) {
                        LOGD("EOF");
@@ -657,7 +657,7 @@ void muse_core_fd_state_dump(int fd)
 
        if (fstat(fd, &sb) < 0) {
                strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
-               LOGE("[%d] failed to get file status %d %s", fd, errno, err_msg);
+               LOGE("[%d] failed to get file status [error %s %d]", fd, err_msg, errno);
                return;
        }
 
index 5acf88e9f859bcc4b1a06afe4e2660b912a8be58..d5cd10f3a0bfc3c613df396cdf54792fdb4b93ae 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mused
 Summary:    A multimedia daemon
-Version:    0.3.33
+Version:    0.3.34
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index e6a58bb22f294004285437b37e808bc5ab756810..f669728f92c8659a8e374e63b5bbd86da40812b1 100644 (file)
@@ -70,7 +70,7 @@ static pid_t _ms_daemonize(void)
        /* redirect fds to /dev/null */
        fd = open("/dev/null", O_RDWR);
        if (!muse_core_fd_is_valid(fd)) {
-               LOGE("Critial Error : %d is invalid", fd);
+               LOGE("Critical Error : %d is invalid", fd);
                exit(EXIT_SUCCESS);
        }