]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - http_recv.c
sched: Introduce sched_{read,write}_ok().
[paraslash.git] / http_recv.c
index d49cf2a853b3043edc09e5e419632b7cce2da6be..ac942b4f26e5012b3d92ecf655b6311ad2d9c489 100644 (file)
@@ -1,8 +1,4 @@
-/*
- * Copyright (C) 2005 Andre Noll <maan@tuebingen.mpg.de>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
+/* Copyright (C) 2005 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
 
 /** \file http_recv.c paraslash's http receiver */
 
@@ -30,7 +26,7 @@
 /**
  * the possible states of a http receiver node
  *
- * \sa receiver_node
+ * \sa \ref receiver_node.
  */
 enum http_recv_status {HTTP_CONNECTED, HTTP_SENT_GET_REQUEST, HTTP_STREAMING};
 
@@ -46,7 +42,7 @@ struct private_http_recv_data {
         * It gets initialized to \p HTTP_CONNECTED by the open function of the
         * http receiver.
         *
-        * \sa receiver::open, receiver_node.
+        * \sa \ref receiver::open, \ref receiver_node.
         */
        enum http_recv_status status;
 };
@@ -97,7 +93,7 @@ static int http_recv_post_select(struct sched *s, void *context)
                return 0;
        if (phd->status == HTTP_CONNECTED) {
                char *rq;
-               if (!FD_ISSET(rn->fd, &s->wfds))
+               if (!sched_write_ok(rn->fd, s))
                        return 0;
                rq = make_request_msg();
                PARA_INFO_LOG("sending http request\n");
@@ -109,9 +105,11 @@ static int http_recv_post_select(struct sched *s, void *context)
                return 0;
        }
        if (phd->status == HTTP_SENT_GET_REQUEST) {
-               ret = read_pattern(rn->fd, HTTP_OK_MSG, strlen(HTTP_OK_MSG), &s->rfds);
-               if (ret < 0)
+               ret = read_pattern(rn->fd, HTTP_OK_MSG, strlen(HTTP_OK_MSG));
+               if (ret < 0) {
+                       PARA_ERROR_LOG("did not receive HTTP OK message\n");
                        goto out;
+               }
                if (ret == 0)
                        return 0;
                PARA_INFO_LOG("received ok msg, streaming\n");
@@ -122,7 +120,7 @@ static int http_recv_post_select(struct sched *s, void *context)
        iovcnt = btr_pool_get_buffers(rn->btrp, iov);
        if (iovcnt == 0)
                goto out;
-       ret = readv_nonblock(rn->fd, iov, iovcnt, &s->rfds, &num_bytes);
+       ret = readv_nonblock(rn->fd, iov, iovcnt, &num_bytes);
        if (num_bytes == 0)
                goto out;
        if (num_bytes <= iov[0].iov_len) /* only the first buffer was filled */
@@ -132,8 +130,10 @@ static int http_recv_post_select(struct sched *s, void *context)
                btr_add_output_pool(rn->btrp, num_bytes - iov[0].iov_len, btrn);
        }
 out:
-       if (ret < 0)
+       if (ret < 0) {
+               PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
                btr_remove_node(&rn->btrn);
+       }
        return ret;
 }