tethering: fix connection failure case.
authorKitae Kim <kt920.kim@samsung.com>
Tue, 5 Aug 2014 04:33:59 +0000 (13:33 +0900)
committerKitae Kim <kt920.kim@samsung.com>
Tue, 5 Aug 2014 11:55:43 +0000 (20:55 +0900)
when connection is failure, it will escape the while loop.

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

index 201b9e4e1164a98d39dfd880537aeecb0d53e76f..045935c5ac4b6b38cd8ee2d8fcaf190723628816 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) {
             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;
                 INFO("a previous connection has not yet been completed\n");
+                ret = 0;
                 continue;
             } else if (connection_errno == EISCONN) {
-                ret = 0;
                 INFO("connection is already connected\n");
+                ret = 0;
                 break;
             } else {
                 perror("connect failure");
                 ret = -connection_errno;
+                break;
             }
         }
     }