Skip to content

Commit

Permalink
improved rack.input disk buffering (second part)
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto@centos6 committed Sep 17, 2012
1 parent 03c7391 commit 7d0d2b3
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions plugins/rack/rack_plugin.c
Expand Up @@ -129,29 +129,48 @@ VALUE rb_uwsgi_io_read(VALUE obj, VALUE args) {
If buffer is given, then the read data will be placed into buffer instead of a newly created String object.
*/

/*
// --- disk buffering ---

if (wsgi_req->async_post) {
// 0 size, read the whole body from the file...
if (RARRAY_LEN(args) == 0) {
char *tmp_chunk = uwsgi_malloc(wsgi_req->post_cl);
size_t rlen = fread(chunk, 1, wsgi_req->post_cl, (FILE *) wsgi_req->async_post);
size_t rlen = fread(tmp_chunk, 1, wsgi_req->post_cl, (FILE *) wsgi_req->async_post);
if (rlen == 0) {
free(tmp_chunk);
return rb_str_new("", 0);
}
// return a new string
chunk = rb_str_new(tmp_chunk, rlen);
free(tmp_chunk);
return chunk;
}
// size specified
else if (RARRAY_LEN(args) > 0) {
chunk_size = NUM2UINT(RARRAY_PTR(args)[0]);
char *tmp_chunk = uwsgi_malloc(chunk_size);
size_t rlen = fread(chunk, 1, chunk_size, tmp_chunk, (FILE *) wsgi_req->async_post);
if () {
size_t rlen = fread(tmp_chunk, 1, chunk_size, (FILE *) wsgi_req->async_post);
// error, return Qnil
if (rlen == 0) {
free(tmp_chunk);
return Qnil;
}
}
// push in the specified buffer
if (RARRAY_LEN(args) > 1) {
rb_str_cat(RARRAY_PTR(args)[1], tmp_chunk, rlen);
free(tmp_chunk);
return RARRAY_PTR(args)[1];
}
// return a new string
chunk = rb_str_new(tmp_chunk, rlen);
free(tmp_chunk);
return chunk;
}
// never happend...
return Qnil;
}
*/

// --- memory buffering ---

// first check for virtual EOF
if (!wsgi_req->post_cl || wsgi_req->buf_pos >= wsgi_req->post_cl) {
Expand Down

0 comments on commit 7d0d2b3

Please sign in to comment.