tethering: fix connection failure case. 67/25567/1
authorKitae Kim <kt920.kim@samsung.com>
Thu, 31 Jul 2014 02:40:15 +0000 (11:40 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 7 Aug 2014 05:45:10 +0000 (14:45 +0900)
when connection is failure, it will escape the while loop.

Change-Id: I134976425971f6552b7787d8357424de4b40737d
Signed-off-by: Kitae Kim <kt920.kim@samsung.com>
tizen/src/tethering/common.c

index 9f368b6..408d919 100644 (file)
@@ -196,7 +196,6 @@ bool send_msg_to_controller(void *msg)
         if (sent_size < 0) {
             perror("failed to send a packet");
             if (errno == EAGAIN) {
-                //sleep(1);
                 fd_set writefds;
                 struct timeval timeout;
 
@@ -640,9 +639,9 @@ static int start_tethering_socket(const char *ipaddress, int port)
     set_tethering_connection_status(CONNECTING);
 
     while (1) {
-       ret = connect(sock, (struct sockaddr *)&addr, sizeof(addr));
+        ret = connect(sock, (struct sockaddr *)&addr, sizeof(addr));
 
-       if (ret == 0) {
+        if (ret == 0) {
             LOG_INFO("tethering socket is connected.\n");
             break;
         } else {
@@ -675,16 +674,17 @@ static int start_tethering_socket(const char *ipaddress, int port)
                 }
                 continue;
             } else if (connection_errno == EALREADY) {
-                ret = 0;
                 LOG_INFO("a previous connection has not yet been completed\n");
+                ret = 0;
                 continue;
             } else if (connection_errno == EISCONN) {
-                ret = 0;
                 LOG_INFO("connection is already connected\n");
+                ret = 0;
                 break;
             } else {
                 perror("connect failure");
                 ret = -connection_errno;
+                break;
             }
         }
     }