socket: Make sure fd is ready to write before calling send()
diff --git a/common/socket.c b/common/socket.c
index cf6e9eb..a47de2a 100644
--- a/common/socket.c
+++ b/common/socket.c
@@ -690,6 +690,10 @@
 int socket_send(int fd, void *data, size_t length)
 {
 	int flags = 0;
+	int res = socket_check_fd(fd, FDM_WRITE, 1000);
+	if (res <= 0) {
+		return res;
+	}
 #ifdef MSG_NOSIGNAL
 	flags |= MSG_NOSIGNAL;
 #endif