[REFACTOR] Refactor host server socket creation
authorDmitry Bogatov <D.Bogatov@samsung.com>
Tue, 23 Jul 2013 10:33:48 +0000 (14:33 +0400)
committerNikita Kalyazin <n.kalyazin@samsung.com>
Tue, 23 Jul 2013 12:41:33 +0000 (16:41 +0400)
daemon/main.c

index eba5b9a..400ffc4 100644 (file)
@@ -271,12 +271,21 @@ static bool initialize_pthread_sigmask()
        return true;
 }
 
+static bool initialize_host_server_socket()
+{
+       int port = makeHostServerSocket();
+
+       if (port < 0) {
+               writeToPortfile(ERR_HOST_SERVER_SOCKET_CREATE_FAILED);
+               return false;
+       }
+       writeToPortfile(port);
+       return true;
+}
 
 // return 0 for normal case
 static int initializeManager()
 {
-       int i;
-
        if (init_buf() != 0) {
                LOGE("Cannot init buffer\n");
                return -1;
@@ -296,23 +305,11 @@ static int initializeManager()
                return -1;
        }
 
-       i = makeHostServerSocket();
-       if(i < 0)
-       {
-               writeToPortfile(ERR_HOST_SERVER_SOCKET_CREATE_FAILED);
-               return -1;
-       }
-       else    // host server socket creation succeed
-       {
-               writeToPortfile(i);
-       }
-
-
+       if (!initialize_host_server_socket())
+         return -1;
 
        LOGI("SUCCESS to write port\n");
 
-       // initialize target client sockets
-
        inititialize_manager_targets(&manager);
        if (!initialize_pthread_sigmask())
          return -1;