fix #36 - nginx reduces rquest_body->rest only on buffer recycling
Since nginx 1.3.9, the request body handler is able to decode chunked
encoding. This feature changed the behavior of the request body handler,
whereas before the request_body->rest was decremented on each call to
recv and the upload progress module was showing the correct rest
decrement. Now, request_body->rest is only decremented when the incoming
body buffer is reused. If this buffer is large (it's size depends on
client_body_buffer_size), then it can never be reused, thus the rest
field is never decremented until the end of the file.
This hasn't been detected and reproduced before, because I happen to
run the tests with small client_body_buffer_size (ie less than 10% from
the file uploaded).
The solution is to never use rest, but compute the correct rest by
tracking the current buffer size.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Nginx 1.1.15 removed the NGX_PARSE_LARGE_TIME error code.
The code checking this error is not used anymore, so let's remove
it.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Fix #7 - Error upload might be deleted from rbtree
Due to the done flag not being correctly set to 0 when the error
tracker triggers, it could happen that such upload could be mistakenly
removed from the the rbtree that contains all in-flight uploads.
Thanks to Theo Cushion for finding this issue.
Signed-off-by: Brice Figureau <brice@daysofwonder.com>
It could happen that when several keys produces the same hash that
find_node was not trying hard enough to traverse the rb tree.
Thanks to Markus Doppelbauer for his detailed bug report and test case.
Signed-off-by: Brice Figureau <brice@daysofwonder.com>
Support jsonp by storing the value of the callback parameter in $uploadprogress_callback.
Added an 'upload_progress_jsonp_output' directive that sets templates that work with jsonp.
Make jsonp parameter name configurable with the 'upload_progress_jsonp_parameter' directive.
Some uninitialized memory could lead to non array allocation in scripts,
leading to a segfault when reloading nginx.
Signed-off-by: Brice Figureau <brice@daysofwonder.com>
It was impossible to inherit the templates from an higher config level,
because the templates were overwritten when the config were merged.
Signed-off-by: Brice Figureau <brice@daysofwonder.com>
* global templates were not inited before their use
* relying on unpushed array made nelts == 0 and no array use
* code deduplication when initializing global templates
Signed-off-by: Brice Figureau <brice@daysofwonder.com>
Fix crash if a read event occur and the request args have been deleted
This could happen with the upload module if for a reason the upload
is aborted. In this case an internal redirect is done, but the request
still contains our read even handler.
Unfortunately the request args are nullified before calling this read
even handler. So we were crashing because we didn't check for id==null.
This patch fixes this issue.
Signed-off-by: Brice Figureau <brice@daysofwonder.com>
When we clean a node, we ask nginx to free the memory. On some
platform or no load there were great chance the memory wasn't
reused for something else.
With high load and on FreeBSD, the memory seems to be reused
immediatly and we jump in the middle of f*****g nowhere, and
we crash.
Thanks to Vladimir Getmanshchuk for his bug report.
Signed-off-by: Brice Figureau <brice@daysofwonder.com>
* Added a content handler that overrides the original handler (but calls it). It is
used to add our own read_event_handler.
* Implemented a read_event_handler that calls the original handler, and store the rest/content_length in our
own node.
* modified the different handlers to use the new node fields
* added new CHANGES
* support for lowercase or mixed case X-Progress-ID header or parameter (fixes IE lowercasing headers)
* report original HTTP error code in probe in case of upload error
* fix crash reported by Michal Drapiewski