Skip to content

Commit

Permalink
use an offset instead of moving the data (if a chunk has been partial…
Browse files Browse the repository at this point in the history
…ly written)
  • Loading branch information
xant committed May 22, 2014
1 parent 9b42546 commit 3937fc4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/iomux.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ typedef struct __iomux_output_chunk_s {
unsigned char *data;
int len;
int free;
int offset;
TAILQ_ENTRY(__iomux_output_chunk_s) next;
} iomux_output_chunk_t;

Expand Down Expand Up @@ -621,8 +622,8 @@ iomux_write_fd(iomux_t *iomux, int fd, void *priv)
return;
}

char *outbuf = chunk->data;
int outlen = chunk->len;
char *outbuf = chunk->data + chunk->offset;
int outlen = chunk->len - chunk->offset;

MUTEX_UNLOCK(iomux);

Expand All @@ -642,7 +643,7 @@ iomux_write_fd(iomux_t *iomux, int fd, void *priv)
free(chunk);
chunk = TAILQ_FIRST(&iomux->connections[fd]->output_queue);
} else {
memmove(chunk->data, chunk->data + wb, outlen);
chunk->offset += wb;
}
if (!chunk) {
#if defined(HAVE_EPOLL)
Expand Down

0 comments on commit 3937fc4

Please sign in to comment.