Always check the return value of mark_fd_nonblocking().
[paraslash.git] / http_recv.c
index 63b66d1..cb79b64 100644 (file)
@@ -168,16 +168,20 @@ static int http_recv_open(struct receiver_node *rn)
 {
        struct private_http_recv_data *phd;
        struct http_recv_args_info *conf = rn->conf;
-       int ret = makesock(AF_UNSPEC, IPPROTO_TCP, 0, conf->host_arg, conf->port_arg);
+       int fd, ret = makesock(AF_UNSPEC, IPPROTO_TCP, 0, conf->host_arg,
+               conf->port_arg);
 
        if (ret < 0)
                return ret;
-
+       fd = ret;
+       ret = mark_fd_nonblocking(fd);
+       if (ret < 0) {
+               close(fd);
+               return ret;
+       }
        rn->buf = para_calloc(BUFSIZE);
        rn->private_data = phd = para_calloc(sizeof(struct private_http_recv_data));
-
-       phd->fd = ret;
-       mark_fd_nonblocking(phd->fd);
+       phd->fd = fd;
        phd->status = HTTP_CONNECTED;
        return 1;
 }