From 72d73eb53316768a5a3527cf56afad7158d9ef4d Mon Sep 17 00:00:00 2001 From: Gerrit Renker Date: Sun, 23 May 2010 07:43:04 +0200 Subject: [PATCH] cleanup: remove redundant 'max length' argument 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 | 2 +- fd.c | 9 +-------- fd.h | 3 +-- grab_client.c | 2 +- http_send.c | 8 ++++---- oss_write.c | 2 +- send.h | 8 +++----- send_common.c | 17 +++++++---------- stdout.c | 2 +- udp_send.c | 7 ++----- 10 files changed, 22 insertions(+), 38 deletions(-) diff --git a/dccp_send.c b/dccp_send.c index 77bee097..9a2f6caf 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -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 7336bd51..978ada45 100644 --- 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 c21a7d14..00b02bef 100644 --- 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); diff --git a/grab_client.c b/grab_client.c index 9b475316..5971f115 100644 --- a/grab_client.c +++ b/grab_client.c @@ -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) diff --git a/http_send.c b/http_send.c index 2c918fc8..a530a181 100644 --- a/http_send.c +++ b/http_send.c @@ -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); } } diff --git a/oss_write.c b/oss_write.c index d0cff015..da2539d1 100644 --- a/oss_write.c +++ b/oss_write.c @@ -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 e606738b..80a268bf 100644 --- 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); diff --git a/send_common.c b/send_common.c index 3b238014..cf1cd37b 100644 --- a/send_common.c +++ b/send_common.c @@ -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; diff --git a/stdout.c b/stdout.c index eaf0f99f..775f0649 100644 --- 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); diff --git a/udp_send.c b/udp_send.c index a7d696ef..70373c99 100644 --- a/udp_send.c +++ b/udp_send.c @@ -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) -- 2.39.2