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);
* \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
*
* \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;
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;
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);
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)
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);
}
}
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);
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);
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);
*
* \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);
*
* \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.
* 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;
}
}
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;
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;
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);
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)
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)