nat: Attempt to handle exceptions on the fd and trat them as connection loss
This commit is contained in:
parent
9e2e2e04d1
commit
339dfdb624
|
@ -49,6 +49,20 @@ static void connection_loss(struct bsc_msc_connection *con)
|
||||||
con->connection_loss(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 */
|
/* called in the case of a non blocking connect */
|
||||||
static int msc_connection_connect(struct bsc_fd *fd, unsigned int what)
|
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 */
|
/* go to full operation */
|
||||||
fd->cb = write_queue_bfd_cb;
|
fd->cb = write_queue_bfd_cb;
|
||||||
fd->when = BSC_FD_READ;
|
fd->when = BSC_FD_READ | BSC_FD_EXCEPT;
|
||||||
|
|
||||||
con->is_connected = 1;
|
con->is_connected = 1;
|
||||||
LOGP(DMSC, LOGL_NOTICE, "(Re)Connected to the MSC.\n");
|
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);
|
connection_loss(con);
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
fd->when = BSC_FD_READ;
|
fd->when = BSC_FD_READ | BSC_FD_EXCEPT;
|
||||||
fd->cb = write_queue_bfd_cb;
|
fd->cb = write_queue_bfd_cb;
|
||||||
con->is_connected = 1;
|
con->is_connected = 1;
|
||||||
if (con->connected)
|
if (con->connected)
|
||||||
|
@ -187,6 +201,7 @@ struct bsc_msc_connection *bsc_msc_create(const char *ip, int port)
|
||||||
con->ip = ip;
|
con->ip = ip;
|
||||||
con->port = port;
|
con->port = port;
|
||||||
write_queue_init(&con->write_queue, 100);
|
write_queue_init(&con->write_queue, 100);
|
||||||
|
con->write_queue.except_cb = bsc_msc_except;
|
||||||
return con;
|
return con;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue