Skip to content
Browse files

fix to send close connection immediately when an error happens writti…

…ng to socket, bug introduced on last commit of May 13, 2012 which sends NGX_OK for connections with NGX_AGAIN writing retturn code
  • Loading branch information...
1 parent ab5f178 commit 28d9df7ac5ae9631de8e96dd7fe255bec28adadc @wandenberg committed Jun 27, 2012
Showing with 11 additions and 7 deletions.
  1. +1 −1 include/ngx_http_push_stream_module_version.h
  2. +10 −6 src/ngx_http_push_stream_module_utils.c
View
2 include/ngx_http_push_stream_module_version.h
@@ -27,6 +27,6 @@
#define NGX_HTTP_PUSH_STREAM_MODULE_VERSION_H_
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TAG = ngx_string("0.3.4");
-static const ngx_str_t NGX_HTTP_PUSH_STREAM_COMMIT = ngx_string("7714fccdabe6174925c46f763a51321b5646aea2");
+static const ngx_str_t NGX_HTTP_PUSH_STREAM_COMMIT = ngx_string("ab5f17888393a57a3191f0f4ea631be717e6a30b");
#endif /* NGX_HTTP_PUSH_STREAM_MODULE_VERSION_H_ */
View
16 src/ngx_http_push_stream_module_utils.c
@@ -628,19 +628,23 @@ static void
ngx_http_push_stream_send_response_finalize(ngx_http_request_t *r)
{
ngx_http_push_stream_loc_conf_t *pslcf = ngx_http_get_module_loc_conf(r, ngx_http_push_stream_module);
+ ngx_int_t rc = NGX_OK;
ngx_http_push_stream_run_cleanup_pool_handler(r->pool, (ngx_pool_cleanup_pt) ngx_http_push_stream_cleanup_request_context);
if (pslcf->footer_template.len > 0) {
- ngx_http_push_stream_send_response_text(r, pslcf->footer_template.data, pslcf->footer_template.len, 0);
+ rc = ngx_http_push_stream_send_response_text(r, pslcf->footer_template.data, pslcf->footer_template.len, 0);
}
- if (pslcf->location_type == NGX_HTTP_PUSH_STREAM_WEBSOCKET_MODE) {
- ngx_http_push_stream_send_response_text(r, NGX_HTTP_PUSH_STREAM_WEBSOCKET_CLOSE_LAST_FRAME_BYTE, sizeof(NGX_HTTP_PUSH_STREAM_WEBSOCKET_CLOSE_LAST_FRAME_BYTE), 1);
- } else {
- ngx_http_push_stream_send_response_text(r, NGX_HTTP_PUSH_STREAM_LAST_CHUNK.data, NGX_HTTP_PUSH_STREAM_LAST_CHUNK.len, 1);
+ if (rc == NGX_OK) {
+ if (pslcf->location_type == NGX_HTTP_PUSH_STREAM_WEBSOCKET_MODE) {
+ rc = ngx_http_push_stream_send_response_text(r, NGX_HTTP_PUSH_STREAM_WEBSOCKET_CLOSE_LAST_FRAME_BYTE, sizeof(NGX_HTTP_PUSH_STREAM_WEBSOCKET_CLOSE_LAST_FRAME_BYTE), 1);
+ } else {
+ rc = ngx_http_push_stream_send_response_text(r, NGX_HTTP_PUSH_STREAM_LAST_CHUNK.data, NGX_HTTP_PUSH_STREAM_LAST_CHUNK.len, 1);
+ }
}
- ngx_http_finalize_request(r, NGX_OK);
+
+ ngx_http_finalize_request(r, (rc == NGX_ERROR) ? NGX_DONE : NGX_OK);
}
static void

0 comments on commit 28d9df7

Please sign in to comment.
Something went wrong with that request. Please try again.