nat: Attempt to handle exceptions on the fd and trat them as connection loss
diff --git a/openbsc/src/bsc_msc.c b/openbsc/src/bsc_msc.c
index 94dc0ed..69da7c3 100644
--- a/openbsc/src/bsc_msc.c
+++ b/openbsc/src/bsc_msc.c
@@ -49,6 +49,20 @@
 	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 @@
 
 	/* 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 @@
 		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)
@@ -186,6 +200,7 @@
 	con->ip = ip;
 	con->port = port;
 	write_queue_init(&con->write_queue, 100);
+	con->write_queue.except_cb = bsc_msc_except;
 	return con;
 }