summaryrefslogtreecommitdiff
path: root/uclient-http.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2016-01-16 23:29:51 +0100
committerFelix Fietkau <nbd@openwrt.org>2016-01-16 23:29:51 +0100
commitfe0f1a36109384eaad8b3d0f1438d9321581e47c (patch)
tree92ad5fd4dc11cf01bc1de91ad62af6daf0f7db2a /uclient-http.c
parentcabb2e2641cea551d60b5b15f6cb1d092e6fbb03 (diff)
downloaduclient-fe0f1a36109384eaad8b3d0f1438d9321581e47c.tar.gz
uclient-http: use blocking connect, switch to non-blocking later. fixes ipv6 -> ipv4 fallback
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'uclient-http.c')
-rw-r--r--uclient-http.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/uclient-http.c b/uclient-http.c
index 574dc01..fa66f78 100644
--- a/uclient-http.c
+++ b/uclient-http.c
@@ -19,6 +19,7 @@
#include <ctype.h>
#include <unistd.h>
#include <stdint.h>
+#include <fcntl.h>
#include <libubox/ustream.h>
#include <libubox/ustream-ssl.h>
@@ -117,10 +118,11 @@ static int uclient_do_connect(struct uclient_http *uh, const char *port)
memset(&uh->uc.remote_addr, 0, sizeof(uh->uc.remote_addr));
- fd = usock_inet(USOCK_TCP | USOCK_NONBLOCK, uh->uc.url->host, port, &uh->uc.remote_addr);
+ fd = usock_inet(USOCK_TCP, uh->uc.url->host, port, &uh->uc.remote_addr);
if (fd < 0)
return -1;
+ fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
ustream_fd_init(&uh->ufd, fd);
sl = sizeof(uh->uc.local_addr);