From c7ff83efffd73e9ca82aa29990faaa38c90bd826 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Wed, 9 May 2007 21:28:22 +0000 Subject: serial: handle socket errors properly - timeout waiting linkkey or other errors can happen --- serial/manager.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/serial/manager.c b/serial/manager.c index f4480404..90637123 100644 --- a/serial/manager.c +++ b/serial/manager.c @@ -404,6 +404,12 @@ static gboolean rfcomm_connect_cb(GIOChannel *chan, int sk, ret, err, fd; socklen_t len; + if (cond & (G_IO_ERR | G_IO_HUP)) { + error("Hangup or error on rfcomm socket"); + err_connection_canceled(pc->conn, pc->msg); + goto fail; + } + if (pc->canceled) { err_connection_canceled(pc->conn, pc->msg); goto fail; @@ -512,7 +518,8 @@ static int rfcomm_connect(struct pending_connect *pc) } debug("Connect in progress"); - g_io_add_watch(io, G_IO_OUT, (GIOFunc) rfcomm_connect_cb, pc); + g_io_add_watch(io, G_IO_OUT | G_IO_ERR | G_IO_HUP, + (GIOFunc) rfcomm_connect_cb, pc); } else { debug("Connect succeeded with first try"); (void) rfcomm_connect_cb(io, G_IO_OUT, pc); -- cgit