Permalink
Browse files

fix: reused subscriber connections sometimes failed to receive messages

  • Loading branch information...
slact committed Nov 17, 2009
1 parent 25b602f commit 560f54f84d3f78b27457443526042505ba28cfe2
Showing with 8 additions and 23 deletions.
  1. +1 −0 changelog.txt
  2. +7 −23 src/ngx_http_push_module.c
View
@@ -1,3 +1,4 @@
+ fix: reused subscriber connections sometimes failed to receive messages
unfeature: no more nginx 0.6 support. not worth the hassle.
0.683 (Nov. 10 2009)
change: default max. reserved memory size changed form 16MB to 32 MB
View
@@ -279,7 +279,6 @@ static ngx_int_t ngx_http_push_subscriber_handler(ngx_http_request_t *r) {
ngx_chain_t *chain;
time_t last_modified;
size_t content_type_len;
- ngx_http_postponed_request_t *pr, *p;
case NGX_HTTP_PUSH_MESSAGE_EXPECTED:
// ♫ It's gonna be the future soon ♫
@@ -324,21 +323,6 @@ static ngx_int_t ngx_http_push_subscriber_handler(ngx_http_request_t *r) {
if((subscriber = ngx_palloc(ngx_http_push_pool, sizeof(*subscriber)))==NULL) { //unable to allocate request queue element
return NGX_ERROR;
}
-
- //postpone the request. this seems to be magical.
- pr = ngx_palloc(r->pool, sizeof(ngx_http_postponed_request_t));
- if (pr == NULL) {
- return NGX_ERROR;
- }
- pr->request = r; //really?
- pr->out = NULL;
- pr->next = NULL;
- if (r->postponed) {
- for (p = r->postponed; p->next; p = p->next) { /* void */ }
- p->next = pr;
- } else {
- r->postponed = pr;
- }
//attach a cleaner to remove the request from the channel.
if ((cln=ngx_pool_cleanup_add(r->pool, sizeof(*clndata))) == NULL) { //make sure we can.
@@ -369,11 +353,12 @@ static ngx_int_t ngx_http_push_subscriber_handler(ngx_http_request_t *r) {
ngx_queue_insert_tail(&subscriber_sentinel->queue, &subscriber->queue);
-#if defined(nginx_version) && nginx_version >= 7000
- return NGX_OK; //do recall that the request was postponed
-#else
- return NGX_DONE; //oldschool
-#endif
+ r->read_event_handler = ngx_http_test_reading;
+ r->write_event_handler = ngx_http_request_empty_handler;
+ r->discard_body = 1;
+ r->keepalive=1; //stayin' alive!!
+ return NGX_DONE;
+
case NGX_HTTP_PUSH_MECHANISM_INTERVALPOLL:
//interval-polling subscriber requests get a 304 with their entity tags preserved.
@@ -839,8 +824,7 @@ static ngx_int_t ngx_http_push_respond_to_subscribers(ngx_http_push_channel_t *c
((ngx_http_push_subscriber_t *)cur)->clndata->subscriber=NULL;
((ngx_http_push_subscriber_t *)cur)->clndata->channel=NULL;
- //unpostpone request
- r->postponed=NULL;
+ r->discard_body=0; //hacky hacky!
ngx_http_finalize_request(r, ngx_http_push_prepare_response_to_subscriber_request(r, chain, content_type, etag, last_modified_time)); //BAM!
responded_subscribers++;

0 comments on commit 560f54f

Please sign in to comment.