Thread (4 messages) 4 messages, 3 authors, 2012-07-29
STALE5113d

[PATCH BlueZ v0 2/2] btio: Connect callback errors handling cleanup

From: Claudio Takahasi <hidden>
Date: 2012-07-26 14:11:09
Subsystem: the rest · Maintainer: Linus Torvalds

Condition verification is not required for this watch since the
condition to watch for was previously informed when it was added
in the mainloop.
---
 btio/btio.c |   26 +++++++-------------------
 1 files changed, 7 insertions(+), 19 deletions(-)
diff --git a/btio/btio.c b/btio/btio.c
index 792123f..730bdb3 100644
--- a/btio/btio.c
+++ b/btio/btio.c
@@ -162,27 +162,15 @@ static gboolean connect_cb(GIOChannel *io, GIOCondition cond,
 	if ((cond & G_IO_NVAL) || check_nval(io))
 		return FALSE;
 
-	if (cond & G_IO_OUT) {
-		sock = g_io_channel_unix_get_fd(io);
-
-		if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0)
-			err = -errno;
-		else
-			err = -sk_err;
-
-		if (err < 0)
-			ERROR_FAILED(&gerr, "connect", -err);
-	} else if (cond & (G_IO_HUP | G_IO_ERR)) {
-		sock = g_io_channel_unix_get_fd(io);
+	sock = g_io_channel_unix_get_fd(io);
 
-		if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0)
-			err = -errno;
-		else
-			err = -sk_err;
+	if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0)
+		err = -errno;
+	else
+		err = -sk_err;
 
-		if (err < 0)
-			ERROR_FAILED(&gerr, "HUP or ERR on socket", -err);
-	}
+	if (err < 0)
+		ERROR_FAILED(&gerr, "connect error", -err);
 
 	conn->connect(io, gerr, conn->user_data);
 
-- 
1.7.8.6
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help