Skip to content

Commit

Permalink
try flushing the output queue (if any) on close
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Guzzo committed Mar 11, 2015
1 parent c4cec02 commit 825e9e5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/iomux.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,10 +855,9 @@ iomux_close(iomux_t *iomux, int fd)
return 0;
}

/*
if (fcntl(fd, F_GETFD, 0) != -1 && conn->outlen) { // there is pending data
iomux_output_chunk_t *chunk = TAILQ_FIRST(&conn->output_queue);
if (fcntl(fd, F_GETFD, 0) != -1 && chunk) { // there is pending data
int retries = 0;
iomux_output_chunk_t *chunk = TAILQ_FIRST(&conn->output_queue);
iomux_output_chunk_t *last_chunk = NULL; // XXX - here to silence the static analyzer
while (chunk && chunk != last_chunk && retries <= IOMUX_FLUSH_MAXRETRIES) {
int wb = write(fd, chunk->data, chunk->len);
Expand All @@ -870,7 +869,7 @@ iomux_close(iomux_t *iomux, int fd)
break;
}
} else if (wb == 0) {
fprintf(stderr, "%s: closing filedescriptor %d with %db pending data\n", __FUNCTION__, fd, conn->outlen);
fprintf(stderr, "%s: closing filedescriptor %d with pending data\n", __FUNCTION__, fd);
break;
}
TAILQ_REMOVE(&conn->output_queue, chunk, next);
Expand All @@ -890,7 +889,6 @@ iomux_close(iomux_t *iomux, int fd)
chunk = TAILQ_FIRST(&conn->output_queue);
}
}
*/

void (*mux_eof)(iomux_t *, int, void *) = conn->cbs.mux_eof;
void *priv = conn->cbs.priv;
Expand Down

0 comments on commit 825e9e5

Please sign in to comment.