]> git.tue.mpg.de Git - paraslash.git/commitdiff
cleanup: remove redundant 'max length' argument
authorGerrit Renker <grenker@cscs.ch>
Sun, 23 May 2010 05:43:04 +0000 (07:43 +0200)
committerAndre Noll <maan@systemlinux.org>
Mon, 7 Jun 2010 21:24:53 +0000 (23:24 +0200)
This removes the redundant 'max_size_bytes' argument of
 * write_nonblocking(),
 * send_queued_chunks(), and
 * send_chunk(),
since it was set to 0 in all cases.

dccp_send.c
fd.c
fd.h
grab_client.c
http_send.c
oss_write.c
send.h
send_common.c
stdout.c
udp_send.c

index 77bee09783ad2cd46b7a55a70722b2dc5ffc4c93..9a2f6caf33a2982cc621de6d8cfe04f27fd25573 100644 (file)
@@ -102,7 +102,7 @@ static int dccp_init_fec(struct sender_client *sc)
 
 static int dccp_send_fec(struct sender_client *sc, char *buf, size_t len)
 {
-       int ret = write_nonblock(sc->fd, buf, len, 0);
+       int ret = write_nonblock(sc->fd, buf, len);
 
        if (ret < 0)
                dccp_shutdown_client(sc);
diff --git a/fd.c b/fd.c
index 7336bd51de6182c8b6899bbca82420db2fd32d08..978ada45de9211dc84363874682603d0d6d6e558 100644 (file)
--- a/fd.c
+++ b/fd.c
@@ -49,10 +49,6 @@ int write_all(int fd, const char *buf, size_t *len)
  * \param fd The file descriptor.
  * \param buf the buffer to write.
  * \param len the number of bytes of \a buf.
- * \param max_bytes_per_write Do not write more than that many bytes at once.
- *
- * If \a max_bytes_per_write is non-zero, do not send more than that many bytes
- * per write().
  *
  * EAGAIN is not considered an error condition.  For example CCID3 has a
  * sending wait queue which fills up and is emptied asynchronously. The EAGAIN
@@ -61,8 +57,7 @@ int write_all(int fd, const char *buf, size_t *len)
  *
  * \return Negative on errors, number of bytes written else.
  */
-int write_nonblock(int fd, const char *buf, size_t len,
-               size_t max_bytes_per_write)
+int write_nonblock(int fd, const char *buf, size_t len)
 {
        size_t written = 0;
        int ret = 0;
@@ -70,8 +65,6 @@ int write_nonblock(int fd, const char *buf, size_t len,
        while (written < len) {
                size_t num = len - written;
 
-               if (max_bytes_per_write && max_bytes_per_write < num)
-                       num = max_bytes_per_write;
                ret = write(fd, buf + written, num);
                if (ret < 0 && errno == EAGAIN)
                        return written;
diff --git a/fd.h b/fd.h
index c21a7d1480f32b6ef2bf30a5674d6005f8d2cb1c..00b02bef7a0e52819b2e4da35f7b79fc16145d93 100644 (file)
--- a/fd.h
+++ b/fd.h
@@ -30,7 +30,6 @@ int readv_nonblock(int fd, struct iovec *iov, int iovcnt, fd_set *rfds,
                size_t *num_bytes);
 int read_nonblock(int fd, void *buf, size_t sz, fd_set *rfds, size_t *num_bytes);
 int read_pattern(int fd, const char *pattern, size_t bufsize, fd_set *rfds);
-int write_nonblock(int fd, const char *buf, size_t len,
-               size_t max_bytes_per_write);
+int write_nonblock(int fd, const char *buf, size_t len);
 int for_each_file_in_dir(const char *dirname,
                int (*func)(const char *, void *), void *private_data);
index 9b4753168c8198681d58d2bc5547c6dcdde16e88..5971f115e7e11d077e825cc744d97abf2f6cbfd5 100644 (file)
@@ -78,7 +78,7 @@ static int gc_write(struct grab_client *gc, char *buf, size_t len)
                if (gc->mode == GM_SLOPPY)
                        return len;
        }
-       ret = write_nonblock(gc->fd, buf, len, 0);
+       ret = write_nonblock(gc->fd, buf, len);
        if (ret < 0)
                goto err;
        if (ret > 0)
index 2c918fc8a53ef56c85dd7ae77b04a1ed63953f64..a530a181e5bdc566d731adf4ef268a4fac17bd2f 100644 (file)
@@ -85,10 +85,10 @@ static void http_send(long unsigned current_chunk,
 
        list_for_each_entry_safe(sc, tmp, &hss->client_list, node) {
                struct private_http_sender_data *phsd = sc->private_data;
-               if (phsd->status != HTTP_STREAMING)
-                       continue;
-               send_chunk(sc, hss, 0, current_chunk, buf, len, header_buf,
-                       header_len);
+
+               if (phsd->status == HTTP_STREAMING)
+                       send_chunk(sc, hss, current_chunk, buf, len,
+                                  header_buf, header_len);
        }
 }
 
index d0cff0150bf9c7690ffe2eb37f0a55b46d142c00..da2539d157ff9f995ae36090d4d434a9b8aa82bc 100644 (file)
@@ -183,7 +183,7 @@ static void oss_post_select(__a_unused struct sched *s,
        ret = 0;
        if (!FD_ISSET(powd->fd, &s->wfds))
                goto out;
-       ret = write_nonblock(powd->fd, data, frames * powd->bytes_per_frame, 0);
+       ret = write_nonblock(powd->fd, data, frames * powd->bytes_per_frame);
        if (ret < 0)
                goto out;
        btr_consume(btrn, ret);
diff --git a/send.h b/send.h
index e606738bf8e2b7549ccfa10007aab1c006cff8c7..80a268bf3d824bf2a60e4de9426715629420d898 100644 (file)
--- a/send.h
+++ b/send.h
@@ -161,9 +161,8 @@ struct sender_status {
 void shutdown_client(struct sender_client *sc, struct sender_status *ss);
 void shutdown_clients(struct sender_status *ss);
 void send_chunk(struct sender_client *sc, struct sender_status *ss,
-               size_t max_bytes_per_write, long unsigned current_chunk,
-               const char *buf, size_t len, const char *header_buf,
-               size_t header_len);
+               long unsigned current_chunk, const char *buf, size_t len,
+               const char *header_buf, size_t header_len);
 void init_sender_status(struct sender_status *ss, char **access_arg, int num_access_args,
        int port, int max_clients, int default_deny);
 char *get_sender_info(struct sender_status *ss, const char *name);
@@ -176,6 +175,5 @@ int generic_com_on(struct sender_status *ss, unsigned protocol);
 void generic_com_off(struct sender_status *ss);
 char *generic_sender_help(void);
 struct sender_client *accept_sender_client(struct sender_status *ss, fd_set *rfds);
-int send_queued_chunks(int fd, struct chunk_queue *cq,
-               size_t max_bytes_per_write);
+int send_queued_chunks(int fd, struct chunk_queue *cq);
 int parse_fec_url(const char *arg, struct sender_command_data *scd);
index 3b238014b526d311e4cb6871ea2aecf5cabe8e5b..cf1cd37b7863ec438af70e246ca41538d4638408 100644 (file)
@@ -110,20 +110,19 @@ static int queue_chunk_or_shutdown(struct sender_client *sc,
  *
  * \param fd The file descriptor.
  * \param cq The list of queued chunks.
- * \param max_bytes_per_write Do not send more than this in one go.
  *
  * \return Negative on errors, zero if not everything was sent, one otherwise.
  */
-int send_queued_chunks(int fd, struct chunk_queue *cq,
-               size_t max_bytes_per_write)
+int send_queued_chunks(int fd, struct chunk_queue *cq)
 {
        struct queued_chunk *qc;
        while ((qc = cq_peek(cq))) {
                const char *buf;
                size_t len;
                int ret;
+
                cq_get(qc, &buf, &len);
-               ret = write_nonblock(fd, buf, len, max_bytes_per_write);
+               ret = write_nonblock(fd, buf, len);
                if (ret < 0)
                        return ret;
                cq_update(cq, ret);
@@ -139,7 +138,6 @@ int send_queued_chunks(int fd, struct chunk_queue *cq,
  *
  * \param sc The client.
  * \param ss The sender.
- * \param max_bytes_per_write Split writes to chunks of at most that many bytes.
  * \param current_chunk The number of the chunk to write.
  * \param buf The data to write.
  * \param len The number of bytes of \a buf.
@@ -150,9 +148,8 @@ int send_queued_chunks(int fd, struct chunk_queue *cq,
  * written, the remainder is put into the chunk queue for that client.
  */
 void send_chunk(struct sender_client *sc, struct sender_status *ss,
-               size_t max_bytes_per_write, long unsigned current_chunk,
-               const char *buf, size_t len, const char *header_buf,
-               size_t header_len)
+               long unsigned current_chunk, const char *buf, size_t len,
+               const char *header_buf, size_t header_len)
 {
        int ret;
 
@@ -164,7 +161,7 @@ void send_chunk(struct sender_client *sc, struct sender_status *ss,
                }
        }
        sc->header_sent = 1;
-       ret = send_queued_chunks(sc->fd, sc->cq, max_bytes_per_write);
+       ret = send_queued_chunks(sc->fd, sc->cq);
        if (ret < 0) {
                shutdown_client(sc, ss);
                goto out;
@@ -175,7 +172,7 @@ void send_chunk(struct sender_client *sc, struct sender_status *ss,
                ret = queue_chunk_or_shutdown(sc, ss, buf, len);
                goto out;
        }
-       ret = write_nonblock(sc->fd, buf, len, max_bytes_per_write);
+       ret = write_nonblock(sc->fd, buf, len);
        if (ret < 0) {
                shutdown_client(sc, ss);
                goto out;
index eaf0f99f070ae0de81c4f34c9f8cd0a373654c3d..775f0649875278935b9da1df065d4307f292bbf6 100644 (file)
--- a/stdout.c
+++ b/stdout.c
@@ -70,7 +70,7 @@ static void stdout_post_select(struct sched *s, struct task *t)
                sz = btr_next_buffer(btrn, &buf);
                if (sz == 0)
                        break;
-               ret = write_nonblock(STDOUT_FILENO, buf, sz, 0);
+               ret = write_nonblock(STDOUT_FILENO, buf, sz);
                if (ret <= 0)
                        break;
                btr_consume(btrn, ret);
index a7d696efd93c88e3ef3aabd257943b5db6380945..70373c99d4fbbd8526837179dd8f24a0c68153e6 100644 (file)
@@ -253,10 +253,7 @@ static int udp_send_fec(struct sender_client *sc, char *buf, size_t len)
 
        if (sender_status == SENDER_OFF)
                return 0;
-       ret = udp_init_session(sc);
-       if (ret < 0)
-               goto fail;
-       ret = send_queued_chunks(sc->fd, sc->cq, 0);
+       ret = send_queued_chunks(sc->fd, sc->cq);
        if (ret == -ERRNO_TO_PARA_ERROR(ECONNREFUSED))
                ret = 0;
        if (ret < 0)
@@ -267,7 +264,7 @@ static int udp_send_fec(struct sender_client *sc, char *buf, size_t len)
                ret = cq_force_enqueue(sc->cq, buf, len);
                assert(ret >= 0);
        }
-       ret = write_nonblock(sc->fd, buf, len, 0);
+       ret = write_nonblock(sc->fd, buf, len);
        if (ret == -ERRNO_TO_PARA_ERROR(ECONNREFUSED))
                ret = 0;
        if (ret < 0)