diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-04-17 19:36:28 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-04-17 19:36:28 +0000 |
commit | f9398eaf08b49c1e8af5bc87a4b19d862ab5a4de (patch) | |
tree | 295faf10fd56644eb7c7cdbfb17c25219037648b /input | |
parent | ed805ba6dc4ab8315e6fd83ecadbe57112dc93b5 (diff) |
input: fixed io channel unref and socket close
Diffstat (limited to 'input')
-rw-r--r-- | input/device.c | 18 | ||||
-rw-r--r-- | input/manager.c | 18 |
2 files changed, 14 insertions, 22 deletions
diff --git a/input/device.c b/input/device.c index 76049ec4..24540ca1 100644 --- a/input/device.c +++ b/input/device.c @@ -520,6 +520,8 @@ static gboolean interrupt_connect_cb(GIOChannel *chan, const char *path; socklen_t len; + isk = g_io_channel_unix_get_fd(chan); + if (cond & G_IO_NVAL) { err = EHOSTDOWN; isk = -1; @@ -527,14 +529,12 @@ static gboolean interrupt_connect_cb(GIOChannel *chan, } if (cond & (G_IO_HUP | G_IO_ERR)) { - err = EINTR; - isk = -1; + err = EHOSTDOWN; error("Hangup or error on HIDP interrupt socket"); goto failed; } - isk = g_io_channel_unix_get_fd(chan); idev->hidp.intr_sock = isk; idev->hidp.idle_to = 30 * 60; /* 30 minutes */ @@ -601,7 +601,6 @@ cleanup: pending_connect_free(idev->pending_connect); idev->pending_connect = NULL; - g_io_channel_unref(chan); return FALSE; } @@ -612,6 +611,8 @@ static gboolean control_connect_cb(GIOChannel *chan, int ret, csk, err; socklen_t len; + csk = g_io_channel_unix_get_fd(chan); + if (cond & G_IO_NVAL) { err = EHOSTDOWN; csk = -1; @@ -619,14 +620,11 @@ static gboolean control_connect_cb(GIOChannel *chan, } if (cond & (G_IO_HUP | G_IO_ERR)) { - err = EINTR; - csk = -1; + err = EHOSTDOWN; error("Hangup or error on HIDP control socket"); goto failed; - } - csk = g_io_channel_unix_get_fd(chan); /* Set HID control channel */ idev->hidp.ctrl_sock = csk; @@ -652,7 +650,6 @@ static gboolean control_connect_cb(GIOChannel *chan, goto failed; } - g_io_channel_unref(chan); return FALSE; failed: @@ -664,7 +661,6 @@ failed: idev->pending_connect->msg, strerror(err)); pending_connect_free(idev->pending_connect); idev->pending_connect = NULL; - g_io_channel_unref(chan); return FALSE; } @@ -1143,6 +1139,8 @@ int l2cap_connect(bdaddr_t *src, bdaddr_t *dst, unsigned short psm, GIOFunc cb, cb(io, G_IO_OUT, data); } + g_io_channel_unref(io); + return 0; failed: diff --git a/input/manager.c b/input/manager.c index d339c007..b7cfc117 100644 --- a/input/manager.c +++ b/input/manager.c @@ -257,6 +257,8 @@ static gboolean interrupt_connect_cb(GIOChannel *chan, int isk, ret, err; socklen_t len; + isk = g_io_channel_unix_get_fd(chan); + if (cond & G_IO_NVAL) { err = EHOSTDOWN; isk = -1; @@ -264,15 +266,12 @@ static gboolean interrupt_connect_cb(GIOChannel *chan, } if (cond & (G_IO_HUP | G_IO_ERR)) { - err = EINTR; - isk = -1; + err = EHOSTDOWN; error("Hangup or error on HIDP interrupt socket"); goto failed; } - isk = g_io_channel_unix_get_fd(chan); - len = sizeof(ret); if (getsockopt(isk, SOL_SOCKET, SO_ERROR, &ret, &len) < 0) { err = errno; @@ -286,7 +285,6 @@ static gboolean interrupt_connect_cb(GIOChannel *chan, goto failed; } - memset(&hidp, 0, sizeof(struct hidp_connadd_req)); extract_hid_record(pr->hid_rec, &hidp); if (pr->pnp_rec) @@ -321,7 +319,6 @@ cleanup: close(pr->ctrl_sock); pending_req_free(pr); - g_io_channel_unref(chan); return FALSE; } @@ -332,6 +329,8 @@ static gboolean control_connect_cb(GIOChannel *chan, int ret, csk, err; socklen_t len; + csk = g_io_channel_unix_get_fd(chan); + if (cond & G_IO_NVAL) { err = EHOSTDOWN; csk = -1; @@ -339,14 +338,12 @@ static gboolean control_connect_cb(GIOChannel *chan, } if (cond & (G_IO_HUP | G_IO_ERR)) { - err = EINTR; - csk = -1; + err = EHOSTDOWN; error("Hangup or error on HIDP control socket"); goto failed; } - csk = g_io_channel_unix_get_fd(chan); /* Set HID control channel */ pr->ctrl_sock = csk; @@ -372,7 +369,6 @@ static gboolean control_connect_cb(GIOChannel *chan, goto failed; } - g_io_channel_unref(chan); return FALSE; failed: @@ -382,8 +378,6 @@ failed: err_connection_failed(pr->conn, pr->msg, strerror(err)); pending_req_free(pr); - g_io_channel_unref(chan); - return FALSE; } |