Skip to content

Commit

Permalink
applied riccardo's fix for sendfile
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto@oneiric64 committed Nov 29, 2011
1 parent a44879e commit 1db3426
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sendfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ ssize_t uwsgi_do_sendfile(int sockfd, int filefd, size_t filesize, size_t chunk,
#else
static size_t nosf_buf_size = 0;
static char *nosf_buf;
char *nosf_buf2;

ssize_t jlen = 0;
ssize_t rlen = 0;
Expand All @@ -115,7 +116,16 @@ ssize_t uwsgi_do_sendfile(int sockfd, int filefd, size_t filesize, size_t chunk,
nosf_buf = malloc(chunk);
}
else if (chunk != nosf_buf_size) {
nosf_buf = realloc(nosf_buf, chunk);
nosf_buf2 = realloc(nosf_buf, chunk);
if (!nosf_buf2) {
free(nosf_buf);
}
nosf_buf = nosf_buf2;
}

if (!nosf_buf) {
uwsgi_error("sendfile malloc()/realloc()");
return 0;
}

nosf_buf_size = chunk;
Expand Down

0 comments on commit 1db3426

Please sign in to comment.