From 0e29d5acbaa9b310f5b5a91b96da5b513132abed Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 10 Jun 2014 23:09:03 +0200 Subject: [PATCH] httpc: use poll to check for the EINPROGRESS state --- src/httpc.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/httpc.c b/src/httpc.c index 7e2f188a..2c6d34ac 100644 --- a/src/httpc.c +++ b/src/httpc.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -468,13 +469,13 @@ http_client_send_partial( http_client_t *hc ) hc->hc_cmd = wcmd->wcmd; hc->hc_rcseq = wcmd->wcseq; if (hc->hc_einprogress) { - /* this seems like OSX specific issue */ - /* send() in the EINPROGRESS state closes the file-descriptor */ - int err = 0; - socklen_t errlen = sizeof(err); - getsockopt(hc->hc_fd, SOL_SOCKET, SO_ERROR, (void *)&err, &errlen); - if (err == EINPROGRESS) { - r = err; + struct pollfd fds; + memset(&fds, 0, sizeof(fds)); + fds.fd = hc->hc_fd; + fds.events = POLLOUT; + if (poll(&fds, 1, 0) == 0) { + r = -1; + errno = EINPROGRESS; goto skip; } hc->hc_einprogress = 0;