Fix RFCOMM server cleanup 53/134053/1
authorAtul Rai <a.rai@samsung.com>
Tue, 13 Jun 2017 10:28:48 +0000 (15:58 +0530)
committerAtul Rai <a.rai@samsung.com>
Tue, 13 Jun 2017 10:47:15 +0000 (16:17 +0530)
Change-Id: I2c5708fd3d08c66d5c7b05a0ce7cd0d03c563271
Signed-off-by: Atul Rai <a.rai@samsung.com>
bt-api/bt-rfcomm-server.c

index 4b457ac..16f0fa4 100644 (file)
@@ -653,8 +653,10 @@ static void __remove_remote_client_info(rfcomm_remote_client_info_t *rem_client)
        if (rem_client == NULL)
                return;
 
-       if (0 < rem_client->sock_fd)
+       if (0 < rem_client->sock_fd) {
+               shutdown(rem_client->sock_fd, SHUT_RDWR);
                close(rem_client->sock_fd);
+       }
 
        if (rem_client->watch_id > 0)
                g_source_remove(rem_client->watch_id);
@@ -685,8 +687,10 @@ static void __remove_rfcomm_server(rfcomm_server_info_t *info)
                } while(info->conn_list);
        }
 
-       if (info->server_fd)
+       if (info->server_fd) {
+               shutdown(info->server_fd, SHUT_RDWR);
                close(info->server_fd);
+       }
 
        if (info->watch_id)
                g_source_remove(info->watch_id);
@@ -1150,8 +1154,7 @@ BT_EXPORT_API int bluetooth_rfcomm_remove_socket(int socket_fd)
                return BLUETOOTH_ERROR_INVALID_PARAM;
        }
 
-       close(server_info->server_fd);
-       server_info->server_fd = -1;
+       __remove_rfcomm_server(server_info);
 
        return BLUETOOTH_ERROR_NONE;
 #endif
@@ -1245,6 +1248,7 @@ BT_EXPORT_API int bluetooth_rfcomm_server_disconnect(int socket_fd)
        }
 
        if (client_info->sock_fd) {
+               shutdown(client_info->sock_fd, SHUT_RDWR);
                close(client_info->sock_fd);
                client_info->sock_fd = -1;
        }