osmo_bts_sock.c: Call osmo_fd_unregister() before closing and changing bfd->fd

Change-Id: Iec0faba781bcb2bc6de8710392655785790b9af4
diff --git a/src/osmobts_sock.c b/src/osmobts_sock.c
index 282e33f..6d46a84 100644
--- a/src/osmobts_sock.c
+++ b/src/osmobts_sock.c
@@ -96,9 +96,9 @@
 	LOGP(DL1IF, LOGL_NOTICE, "PCU socket has %s connection\n",
 		(lost) ? "LOST" : "closed");
 
+	osmo_fd_unregister(bfd);
 	close(bfd->fd);
 	bfd->fd = -1;
-	osmo_fd_unregister(bfd);
 
 	/* flush the queue */
 	while (!llist_empty(&pcu_sock_state.upqueue)) {