refactoring: removed unused socket & code
authorJinhyung Choi <jinhyung2.choi@samsung.com>
Wed, 17 Sep 2014 07:49:53 +0000 (16:49 +0900)
committerJinhyung Choi <jinhyung2.choi@samsung.com>
Wed, 17 Sep 2014 07:49:53 +0000 (16:49 +0900)
Change-Id: Icd394a400fc2737c97c60fe3eb6892c9193ec1c5
Signed-off-by: Jinhyung Choi <jinhyung2.choi@samsung.com>
include/emuld.h
src/common_dev.cpp
src/emuld.cpp
src/mobile.cpp
src/wearable.cpp

index d687f676c10bfa61ae6b57e67d5a4c71f1864e25..8fb182d782f020aec31aa25d7acf4fe2c35ad120 100644 (file)
@@ -43,7 +43,6 @@
 
 enum
 {
-    fdtype_server     = 0,
     fdtype_device     = 1,
     fdtype_ij         = 4,
     fdtype_max        = FDTYPE_MAX
@@ -53,7 +52,6 @@ enum
 #define MAX_CLIENT          10000
 #define MAX_EVENTS          10000
 #define MAX_GETCNT          10
-#define DEFAULT_PORT        3577
 #define ID_SIZE             10
 #define HEADER_SIZE         4
 
index 7b258467e855a1e4d8f5dcc87471d7dea840e7af..c507eab6da2bb79a9df7debaf6f56b8317c4fa64 100644 (file)
@@ -187,7 +187,6 @@ void* mount_sdcard(void* data)
         else
         {
             LOGERR( "%s is not exist", file_name);
-            sleep(1);
         }
     }
 
index 07375ca49346848e93ee43dfb909ea9b1735da49..4fc79deaaf832913410c65e3767b14cc27bed7ae 100644 (file)
@@ -74,66 +74,6 @@ bool epoll_ctl_add(const int fd)
     return true;
 }
 
-static bool init_server(int svr_port, int* ret_fd)
-{
-    struct sockaddr_in serv_addr;
-    int fd;
-
-    *ret_fd = -1;
-
-    /* Open TCP Socket */
-    if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
-    {
-        LOGERR("Server Start Fails. : Can't open stream socket");
-        return false;
-    }
-
-    /* Address Setting */
-    memset(&serv_addr , 0 , sizeof(serv_addr)) ;
-
-    serv_addr.sin_family = AF_INET;
-    serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
-    serv_addr.sin_port = htons(svr_port);
-
-    /* Set Socket Option  */
-    int nSocketOpt = 1;
-    if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &nSocketOpt, sizeof(nSocketOpt)) < 0)
-    {
-        LOGERR("Server Start Fails. : Can't set reuse address");
-        goto fail;
-    }
-
-    /* Bind Socket */
-    if (bind(fd,(struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
-    {
-        LOGERR("Server Start Fails. : Can't bind local address");
-        goto fail;
-    }
-
-    /* Listening */
-    if (listen(fd, 15) < 0) /* connection queue is 15. */
-    {
-        LOGERR("Server Start Fails. : listen failure");
-        goto fail;
-    }
-
-       LOGINFO("[START] Now Server listening on port %d, EMdsockfd: %d"
-            ,svr_port, fd);
-
-    if (!epoll_ctl_add(fd))
-    {
-        LOGERR("Epoll control fails.");
-        goto fail;
-    }
-
-    *ret_fd = fd;
-
-    return true;
-fail:
-    close(fd);
-    return false;
-}
-
 static bool epoll_init(void)
 {
     g_epoll_fd = epoll_create(MAX_EVENTS); // create event pool
@@ -321,44 +261,8 @@ void recv_from_evdi(evdi_fd fd)
     process_evdi_command(&ijcmd);
 }
 
-bool accept_proc(const int server_fd)
-{
-    struct sockaddr_in cli_addr;
-    int cli_sockfd;
-    int cli_len = sizeof(cli_addr);
-
-    cli_sockfd = accept(server_fd, (struct sockaddr *)&cli_addr,(socklen_t *)&cli_len);
-    if(cli_sockfd < 0)
-    {
-        LOGERR("accept error");
-        return false;
-    }
-    else
-    {
-        LOGINFO("[Accept] New client connected. fd:%d, port:%d"
-                ,cli_sockfd, cli_addr.sin_port);
-
-        clipool_add(cli_sockfd, cli_addr.sin_port, fdtype_ij);
-        epoll_ctl_add(cli_sockfd);
-    }
-    return true;
-}
-
 int main( int argc , char *argv[])
 {
-       int g_svr_port = DEFAULT_PORT;
-
-    LOGINFO("emuld start");
-
-       /* entry , argument check and process */
-    if(argc >= 3 && strcmp("-port", argv[1]) ==  0 ) {
-        g_svr_port = atoi(argv[2]);
-        if(g_svr_port < 1024) {
-            LOGERR("[STOP] port number invalid : %d",g_svr_port);
-            exit(0);
-        }
-    }
-
     init_fd();
 
     if (!epoll_init())
@@ -366,19 +270,13 @@ int main( int argc , char *argv[])
         exit(0);
     }
 
-    if (!init_server(g_svr_port, &g_fd[fdtype_server]))
-    {
-        close(g_epoll_fd);
-        exit(0);
-    }
-
     if (!init_device(&g_fd[fdtype_device]))
     {
         close(g_epoll_fd);
         exit(0);
     }
 
-    LOGINFO("[START] epoll events set success for server");
+    LOGINFO("[START] epoll & device init success");
 
        init_profile();
 
@@ -393,9 +291,6 @@ int main( int argc , char *argv[])
 
     stop_listen();
 
-    if (g_fd[fdtype_server])
-        close(g_fd[fdtype_server]);
-
     LOGINFO("emuld exit");
 
     return 0;
index 6363855fa7d0440f3579ceaa5135c845b8bea454..197b7c90434c2e3a47355a978838d387e8b23daf 100644 (file)
@@ -82,11 +82,7 @@ bool server_process(void)
     for( i = 0 ; i < nfds ; i++ )
     {
         fd_tmp = g_events[i].data.fd;
-        if (fd_tmp == g_fd[fdtype_server])
-        {
-            accept_proc(fd_tmp);
-        }
-        else if (fd_tmp == g_fd[fdtype_device])
+        if (fd_tmp == g_fd[fdtype_device])
         {
             recv_from_evdi(fd_tmp);
         }
index 674c77bd8342fb0a7b14919181e710e48453cafd..0a3e25e76d690b62c95716f10f6fdd026854e915 100644 (file)
@@ -61,7 +61,6 @@ bool is_pedometer_connected(void)
 bool msgproc_pedometer(const int sockfd, ijcommand* ijcmd)
 {
     int sent = 0;
-    const char* data = NULL;
 
     LOGINFO("msgproc_pedometer");
     if (!is_pedometer_connected() || !ijcmd->data)
@@ -216,11 +215,7 @@ bool server_process(void)
     for( i = 0 ; i < nfds ; i++ )
     {
         fd_tmp = g_events[i].data.fd;
-        if (fd_tmp == g_fd[fdtype_server])
-        {
-            accept_proc(fd_tmp);
-        }
-        else if (fd_tmp == g_fd[fdtype_device])
+        if (fd_tmp == g_fd[fdtype_device])
         {
             recv_from_evdi(fd_tmp);
         }