aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-04-08 11:12:32 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-04-08 11:16:43 +0200
commit339dfdb62470e4b98e1c91e9303ce85cf2c2f480 (patch)
tree8150a22a164e3579dd93068cc5882924af400f83
parent9e2e2e04d1dcb999fe60a0135e99f5e8bf24a59d (diff)
nat: Attempt to handle exceptions on the fd and trat them as connection loss
-rw-r--r--openbsc/src/bsc_msc.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/openbsc/src/bsc_msc.c b/openbsc/src/bsc_msc.c
index 3ebb1d1bd..0d45f9943 100644
--- a/openbsc/src/bsc_msc.c
+++ b/openbsc/src/bsc_msc.c
@@ -49,6 +49,20 @@ static void connection_loss(struct bsc_msc_connection *con)
con->connection_loss(con);
}
+static int bsc_msc_except(struct bsc_fd *bfd)
+{
+ struct write_queue *wrt;
+ struct bsc_msc_connection *con;
+
+ LOGP(DMSC, LOGL_ERROR, "Exception on the BFD. Closing down.\n");
+
+ wrt = container_of(bfd, struct write_queue, bfd);
+ con = container_of(wrt, struct bsc_msc_connection, write_queue);
+
+ connection_loss(con);
+ return 0;
+}
+
/* called in the case of a non blocking connect */
static int msc_connection_connect(struct bsc_fd *fd, unsigned int what)
{
@@ -81,7 +95,7 @@ static int msc_connection_connect(struct bsc_fd *fd, unsigned int what)
/* go to full operation */
fd->cb = write_queue_bfd_cb;
- fd->when = BSC_FD_READ;
+ fd->when = BSC_FD_READ | BSC_FD_EXCEPT;
con->is_connected = 1;
LOGP(DMSC, LOGL_NOTICE, "(Re)Connected to the MSC.\n");
@@ -156,7 +170,7 @@ int bsc_msc_connect(struct bsc_msc_connection *con)
connection_loss(con);
return ret;
} else {
- fd->when = BSC_FD_READ;
+ fd->when = BSC_FD_READ | BSC_FD_EXCEPT;
fd->cb = write_queue_bfd_cb;
con->is_connected = 1;
if (con->connected)
@@ -187,6 +201,7 @@ struct bsc_msc_connection *bsc_msc_create(const char *ip, int port)
con->ip = ip;
con->port = port;
write_queue_init(&con->write_queue, 100);
+ con->write_queue.except_cb = bsc_msc_except;
return con;
}