summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-08-08 00:30:24 +0200
committerMarcel Holtmann <marcel@holtmann.org>2008-08-08 00:30:24 +0200
commit087cd77cff3295f6bcb9d845a41fff7cae6e8ba6 (patch)
treeaa3ed60ffd98a5872fd4e39629a5756b9565fc24
parent6bf2e483a385c2761ba2bd5a0b4299bc0a67c0e6 (diff)
Add 30s timeout to setup connection phase
-rw-r--r--network/connection.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/network/connection.c b/network/connection.c
index 4bcc5b13..c61eb49c 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -172,6 +172,7 @@ static gboolean bnep_connect_cb(GIOChannel *chan, GIOCondition cond,
{
struct network_conn *nc = data;
struct bnep_control_rsp *rsp;
+ struct timeval timeo;
char pkt[BNEP_MTU];
gsize r;
int sk;
@@ -223,6 +224,11 @@ static gboolean bnep_connect_cb(GIOChannel *chan, GIOCondition cond,
sk = g_io_channel_unix_get_fd(chan);
+ memset(&timeo, 0, sizeof(timeo));
+ timeo.tv_sec = 0;
+
+ setsockopt(sk, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo));
+
if (bnep_connadd(sk, BNEP_SVC_PANU, nc->dev)) {
error("%s could not be added", nc->dev);
goto failed;
@@ -265,6 +271,7 @@ static int bnep_connect(struct network_conn *nc)
{
struct bnep_setup_conn_req *req;
struct __service_16 *s;
+ struct timeval timeo;
unsigned char pkt[BNEP_MTU];
GIOChannel *io;
int err = 0;
@@ -278,6 +285,11 @@ static int bnep_connect(struct network_conn *nc)
s->dst = htons(nc->id);
s->src = htons(BNEP_SVC_PANU);
+ memset(&timeo, 0, sizeof(timeo));
+ timeo.tv_sec = 30;
+
+ setsockopt(nc->sk, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo));
+
io = g_io_channel_unix_new(nc->sk);
g_io_channel_set_close_on_unref(io, FALSE);