Add the condition of socket get data 59/27159/1
authorwu zheng <wu.zheng@intel.com>
Fri, 5 Sep 2014 09:43:25 +0000 (17:43 +0800)
committerwu zheng <wu.zheng@intel.com>
Fri, 5 Sep 2014 09:43:25 +0000 (17:43 +0800)
socket get data need the G_IO_IN condition.

BTW, remove some unuseful code.

Change-Id: I6bdabc21e86b22ae0799e86695c02332bc3b3180
Signed-off-by: Wu Zheng <wu.zheng@intel.com>
capi/bluetooth.c
test/bluez-capi-test.c

index cbac62c..295c6e8 100644 (file)
@@ -3895,6 +3895,9 @@ static gboolean received_data(GIOChannel *channel, GIOCondition con,
        GIOStatus status;
        gsize rbytes = 0;
 
+       if (!(con & G_IO_IN))
+               return FALSE;
+
        spp_ctx = user_data;
        if (spp_ctx == NULL) {
                WARN("no spp find");
@@ -4015,8 +4018,11 @@ static void handle_request_disconnection(gchar *device_path,
 
        notify_connection_state(device_path, BT_SOCKET_DISCONNECTED, spp_ctx);
 
-       g_io_channel_unref(spp_ctx->channel);
-       spp_ctx->channel = NULL;
+       if (spp_ctx->channel) {
+               g_io_channel_shutdown(spp_ctx->channel, TRUE, NULL);
+               g_io_channel_unref(spp_ctx->channel);
+               spp_ctx->channel = NULL;
+       }
 
        g_dbus_method_invocation_return_value(invocation, NULL);
 }
index f7ea831..c0e1117 100644 (file)
@@ -1676,11 +1676,6 @@ static int socket_destroy(const char *p1, const char *p2)
 
        DBG("");
 
-       if (p1 == NULL) {
-               ERROR("socket create must give the UUID");
-               return 0;
-       }
-
        ret = bt_socket_destroy_rfcomm(socket_fd);
        if (ret != BT_SUCCESS)
                DBG("destroy socket failed");
@@ -2707,7 +2702,7 @@ struct {
                "Usage: socket_create 00001101-0000-1000-8000-00805f9b34fb\n\tcreate socket with uuid"},
 
        {"socket_destroy", socket_destroy,
-               "Usage: socket_destroy\n\tdestory spp"},
+               "Usage: socket_destroy\n\tdestroy spp"},
 
        {"socket_set_connection_state_changed_cb", socket_set_connection_state_changed_cb,
                "Usage: socket_set_connection_state_changed_cb\n\tset connection state changed callback"},