summaryrefslogtreecommitdiffstats
path: root/input/manager.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-04-17 19:36:28 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-04-17 19:36:28 +0000
commitf9398eaf08b49c1e8af5bc87a4b19d862ab5a4de (patch)
tree295faf10fd56644eb7c7cdbfb17c25219037648b /input/manager.c
parented805ba6dc4ab8315e6fd83ecadbe57112dc93b5 (diff)
input: fixed io channel unref and socket close
Diffstat (limited to 'input/manager.c')
-rw-r--r--input/manager.c18
1 files changed, 6 insertions, 12 deletions
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;
}