[Bluetooth] Signal user-space for HIDP and BNEP socket errors
authorMarcel Holtmann <marcel@holtmann.org>
Mon, 14 Jul 2008 18:13:53 +0000 (20:13 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 14 Jul 2008 18:13:53 +0000 (20:13 +0200)
When using the HIDP or BNEP kernel support, the user-space needs to
know if the connection has been terminated for some reasons. Wake up
the application if that happens. Otherwise kernel and user-space are
no longer on the same page and weird behaviors can happen.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/bnep/core.c
net/bluetooth/hidp/core.c

index f85d94643aafd29939175f51a98cb9ff7b9d5182..24e91eb7f649f17d7136b59825c08503b62978eb 100644 (file)
@@ -507,6 +507,11 @@ static int bnep_session(void *arg)
        /* Delete network device */
        unregister_netdev(dev);
 
+       /* Wakeup user-space polling for socket errors */
+       s->sock->sk->sk_err = EUNATCH;
+
+       wake_up_interruptible(s->sock->sk->sk_sleep);
+
        /* Release the socket */
        fput(s->sock->file);
 
index 519cdb920f936bb7882d8400bccb8105c5d0d4f5..96434d774c842ff79b84e2d171cdd1e01dd03aaa 100644 (file)
@@ -581,6 +581,12 @@ static int hidp_session(void *arg)
                hid_free_device(session->hid);
        }
 
+       /* Wakeup user-space polling for socket errors */
+       session->intr_sock->sk->sk_err = EUNATCH;
+       session->ctrl_sock->sk->sk_err = EUNATCH;
+
+       hidp_schedule(session);
+
        fput(session->intr_sock->file);
 
        wait_event_timeout(*(ctrl_sk->sk_sleep),
@@ -879,6 +885,10 @@ int hidp_del_connection(struct hidp_conndel_req *req)
                        skb_queue_purge(&session->ctrl_transmit);
                        skb_queue_purge(&session->intr_transmit);
 
+                       /* Wakeup user-space polling for socket errors */
+                       session->intr_sock->sk->sk_err = EUNATCH;
+                       session->ctrl_sock->sk->sk_err = EUNATCH;
+
                        /* Kill session thread */
                        atomic_inc(&session->terminate);
                        hidp_schedule(session);