obexapp handling clean disconnect

Iain Hibbert plunky at rya-online.net
Tue Oct 19 09:28:54 UTC 2010


Hi

I was just cleaning up a minor annoyance (on NetBSD), that sdpd would
complain of an error rather than notice a disconnect when a remote device
closed the L2CAP socket. eg I would see

 "Could not receive SDP request on L2CAP socket. Connection reset by peer (54)"

rather than

 "Client on L2CAP socket has disconnected"

in my log. Interestingly, sdpd always reported this properly for the
control socket and I traced this to my L2CAP code which unnecessarily set
the socket error to ECONNRESET when a disconnect request was received.

So, all is well..  then I looked to the RFCOMM code because I did the same
thing there, but when I changed it I found that obexapp dives into a loop
in obexapp_transport_handle_input() when the remote side ends the
connection normally as read() now returns 0 for EOF.

The OBEX_HandleInput() function normally returns -1 for this case, and
updating the obexapp_transport_handle_input() function to do the same
fixes it for me, patch attached.

regards,
iain
-------------- next part --------------
$NetBSD$

--- transport.c.orig	2010-10-19 08:50:11.000000000 +0000
+++ transport.c
@@ -358,6 +358,10 @@ again:
 
 		return (n);
 	}
+	if (n == 0) {
+		log_info("%s(): Connection closed.", __func__);
+		return (-1);
+	}
 
 	log_debug("%s(): Got %d bytes", __func__, n);
 


More information about the freebsd-bluetooth mailing list