diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-05-05 22:48:56 +0800 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-05-05 22:48:56 +0800 |
commit | eb3ab2f85bff9a80b60d8c3da5f427fddc9b0dfd (patch) | |
tree | 56da5d67cba15c65305edd718c1e628aa06d8da3 /openbsc | |
parent | ebc38e4f26a2c2220b51433062c92f35d5d8257c (diff) |
bsc_msc: Add a connection timeout for the MSC.
When no one is listening our connection would get stuck
in the SYN_SENT state and we would be there forever.
Diffstat (limited to 'openbsc')
-rw-r--r-- | openbsc/include/openbsc/bsc_msc.h | 1 | ||||
-rw-r--r-- | openbsc/src/bsc_msc.c | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/bsc_msc.h b/openbsc/include/openbsc/bsc_msc.h index ce21bfe43..041de256e 100644 --- a/openbsc/include/openbsc/bsc_msc.h +++ b/openbsc/include/openbsc/bsc_msc.h @@ -36,6 +36,7 @@ struct bsc_msc_connection { void (*connection_loss) (struct bsc_msc_connection *); void (*connected) (struct bsc_msc_connection *); struct timer_list reconnect_timer; + struct timer_list timeout_timer; }; struct bsc_msc_connection *bsc_msc_create(const char *ip, int port); diff --git a/openbsc/src/bsc_msc.c b/openbsc/src/bsc_msc.c index 0d45f9943..141609a6b 100644 --- a/openbsc/src/bsc_msc.c +++ b/openbsc/src/bsc_msc.c @@ -49,6 +49,14 @@ static void connection_loss(struct bsc_msc_connection *con) con->connection_loss(con); } +static void msc_con_timeout(void *_con) +{ + struct bsc_msc_connection *con = _con; + + LOGP(DMSC, LOGL_ERROR, "MSC Connection timeout.\n"); + bsc_msc_lost(con); +} + static int bsc_msc_except(struct bsc_fd *bfd) { struct write_queue *wrt; @@ -98,6 +106,7 @@ static int msc_connection_connect(struct bsc_fd *fd, unsigned int what) fd->when = BSC_FD_READ | BSC_FD_EXCEPT; con->is_connected = 1; + bsc_del_timer(&con->timeout_timer); LOGP(DMSC, LOGL_NOTICE, "(Re)Connected to the MSC.\n"); if (con->connected) con->connected(con); @@ -165,6 +174,9 @@ int bsc_msc_connect(struct bsc_msc_connection *con) LOGP(DMSC, LOGL_ERROR, "MSC Connection in progress\n"); fd->when = BSC_FD_WRITE; fd->cb = msc_connection_connect; + con->timeout_timer.cb = msc_con_timeout; + con->timeout_timer.data = con; + bsc_schedule_timer(&con->timeout_timer, 20, 0); } else if (ret < 0) { perror("Connection failed"); connection_loss(con); |