summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2020-05-18 20:10:50 +0200
committerGravatar Nikias Bassen2020-05-18 20:10:50 +0200
commit5364a1b45e79c605d5e5f02b2b57b5a7fe75636c (patch)
treeb7a60c8608d7a46ff67901a5b212d36f118c322a
parent5e3c6366de47ada84933c6dd82c28a4045dbdbec (diff)
downloadlibusbmuxd-5364a1b45e79c605d5e5f02b2b57b5a7fe75636c.tar.gz
libusbmuxd-5364a1b45e79c605d5e5f02b2b57b5a7fe75636c.tar.bz2
socket: Make sure fd is ready to write before calling send()
-rw-r--r--common/socket.c4
1 files changed, 4 insertions, 0 deletions
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_receive_timeout(int fd, void *data, size_t length, int flags,
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