summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-01-23 17:48:40 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-01-23 17:48:40 +0000
commit64b9c9c1a2c57a7b602b8d7fb9d5cf6c4df923d5 (patch)
tree78aabc9228bfdd83d3626a03892dad422e70feb5 /input
parent706b8b6df5e924d72caac5d477ca1fa4a6b1d794 (diff)
Code cleanup: missing HID control socket close and fixed code standard
Diffstat (limited to 'input')
-rw-r--r--input/input-service.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/input/input-service.c b/input/input-service.c
index 11572c03..6ba68b0b 100644
--- a/input/input-service.c
+++ b/input/input-service.c
@@ -509,15 +509,18 @@ static gboolean interrupt_connect_cb(GIOChannel *chan, GIOCondition cond,
struct pending_connect *pc)
{
struct input_device *idev;
- int ctl, ret, err = EHOSTDOWN, isk = -1;
+ int ctl, isk, ret, err;
socklen_t len;
const char *path;
path = dbus_message_get_path(pc->msg);
dbus_connection_get_object_path_data(pc->conn, path, (void *) &idev);
- if (cond & G_IO_NVAL)
+ if (cond & G_IO_NVAL) {
+ err = EHOSTDOWN;
+ isk = -1;
goto failed;
+ }
isk = g_io_channel_unix_get_fd(chan);
idev->hidp.intr_sock = isk;
@@ -569,14 +572,22 @@ static gboolean control_connect_cb(GIOChannel *chan, GIOCondition cond,
struct pending_connect *pc)
{
struct input_device *idev;
- int csk, ret, err = EHOSTDOWN;
+ int ret, csk, err;
socklen_t len;
const char *path;
- if (cond & G_IO_NVAL)
+ path = dbus_message_get_path(pc->msg);
+ dbus_connection_get_object_path_data(pc->conn, path, (void *) &idev);
+
+ if (cond & G_IO_NVAL) {
+ err = EHOSTDOWN;
+ csk = -1;
goto failed;
+ }
csk = g_io_channel_unix_get_fd(chan);
+ /* Set HID control channel */
+ idev->hidp.ctrl_sock = csk;
len = sizeof(ret);
if (getsockopt(csk, SOL_SOCKET, SO_ERROR, &ret, &len) < 0) {
@@ -590,28 +601,23 @@ static gboolean control_connect_cb(GIOChannel *chan, GIOCondition cond,
error("connect(): %s (%d)", strerror(ret), ret);
goto failed;
}
-
- path = dbus_message_get_path(pc->msg);
- dbus_connection_get_object_path_data(pc->conn, path, (void *) &idev);
-
- /* Set HID control channel */
- idev->hidp.ctrl_sock = csk;
-
/* Connect to the HID interrupt channel */
if (l2cap_connect(pc, L2CAP_PSM_HIDP_INTR,
(GIOFunc) interrupt_connect_cb) < 0) {
- error("L2CAP connect failed:%s (%d)", strerror(errno), errno);
err = errno;
- close(csk);
- idev->hidp.ctrl_sock = -1;
+ error("L2CAP connect failed:%s (%d)", strerror(errno), errno);
goto failed;
}
+ pending_connect_free(pc);
return FALSE;
failed:
+ if (csk > 0)
+ close(csk);
+ idev->hidp.ctrl_sock = -1;
err_connection_failed(pc->conn, pc->msg, strerror(err));
pending_connect_free(pc);