Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nginx-push-stream-module
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
nginx-push-stream-module
Commits
c634d747
Commit
c634d747
authored
Nov 11, 2011
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix delete channel with long polling subscribers
parent
0cf6b62c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
ngx_http_push_stream_module_utils.c
src/ngx_http_push_stream_module_utils.c
+8
-1
test_subscriber_long_polling.rb
test/test_subscriber_long_polling.rb
+32
-0
No files found.
src/ngx_http_push_stream_module_utils.c
View file @
c634d747
...
...
@@ -101,6 +101,13 @@ ngx_http_push_stream_delete_unrecoverable_channels(ngx_http_push_stream_shm_data
ngx_queue_remove
(
&
cur
->
queue
);
ngx_shmtx_unlock
(
&
shpool
->
mutex
);
if
(
subscriber
->
longpolling
)
{
ngx_http_push_stream_add_polling_headers
(
subscriber
->
request
,
ngx_time
(),
0
,
subscriber
->
request
->
pool
);
ngx_http_send_header
(
subscriber
->
request
);
ngx_http_push_stream_send_response_content_header
(
subscriber
->
request
,
ngx_http_get_module_loc_conf
(
subscriber
->
request
,
ngx_http_push_stream_module
));
}
ngx_http_push_stream_send_response_message
(
subscriber
->
request
,
channel
,
channel
->
channel_deleted_message
);
break
;
...
...
@@ -108,7 +115,7 @@ ngx_http_push_stream_delete_unrecoverable_channels(ngx_http_push_stream_shm_data
}
// subscriber does not have any other subscription, the connection may be closed
if
(
ngx_queue_empty
(
&
subscriber
->
subscriptions_sentinel
.
queue
))
{
if
(
subscriber
->
longpolling
||
ngx_queue_empty
(
&
subscriber
->
subscriptions_sentinel
.
queue
))
{
ngx_http_push_stream_send_response_finalize
(
subscriber
->
request
);
}
}
...
...
test/test_subscriber_long_polling.rb
View file @
c634d747
...
...
@@ -500,4 +500,36 @@ class TestSubscriberLongPolling < Test::Unit::TestCase
add_test_timeout
}
end
def
config_test_delete_channel_with_long_polling_subscriber
@publisher_mode
=
'admin'
@message_template
=
'{\"id\":\"~id~\", \"message\":\"~text~\", \"channel\":\"~channel~\"}'
end
def
test_delete_channel_with_long_polling_subscriber
headers
=
{
'accept'
=>
'application/json'
}
body
=
'published message'
channel
=
'ch_test_delete_channel_with_long_polling_subscriber'
resp
=
""
EventMachine
.
run
{
sub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/sub/'
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
30
sub_1
.
callback
{
assert_equal
(
200
,
sub_1
.
response_header
.
status
,
"Wrong status"
)
response
=
JSON
.
parse
(
sub_1
.
response
)
assert_equal
(
channel
,
response
[
"channel"
],
"Wrong channel"
)
assert_equal
(
-
2
,
response
[
"id"
].
to_i
,
"Wrong channel"
)
EventMachine
.
stop
}
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
,
:timeout
=>
30
pub
.
callback
{
assert_equal
(
200
,
pub
.
response_header
.
status
,
"Request was not received"
)
assert_equal
(
0
,
pub
.
response_header
.
content_length
,
"Should response only with headers"
)
assert_equal
(
"Channel deleted."
,
pub
.
response_header
[
'X_NGINX_PUSHSTREAM_EXPLAIN'
],
"Didn't receive the right error message"
)
}
add_test_timeout
}
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment