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
d44dc189
Commit
d44dc189
authored
Sep 26, 2011
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clear cleanup messages when only use max_messages_stored_per_channel directive
parent
211464e8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
1 deletion
+90
-1
ngx_http_push_stream_module_utils.c
src/ngx_http_push_stream_module_utils.c
+1
-1
test_cleanup_memory.rb
test/test_cleanup_memory.rb
+89
-0
No files found.
src/ngx_http_push_stream_module_utils.c
View file @
d44dc189
...
...
@@ -42,7 +42,7 @@ ngx_http_push_stream_ensure_qtd_of_messages_locked(ngx_http_push_stream_channel_
while
(
!
ngx_queue_empty
(
&
sentinel
->
queue
)
&&
((
channel
->
stored_messages
>
max_messages
)
||
expired
))
{
msg
=
(
ngx_http_push_stream_msg_t
*
)
ngx_queue_next
(
&
sentinel
->
queue
);
if
(
expired
&&
msg
->
expires
>
ngx_time
(
))
{
if
(
expired
&&
((
msg
->
expires
==
0
)
||
(
msg
->
expires
>
ngx_time
())
))
{
break
;
}
...
...
test/test_cleanup_memory.rb
View file @
d44dc189
...
...
@@ -63,6 +63,95 @@ class TestCreateManyChannels < Test::Unit::TestCase
}
end
def
config_test_message_cleanup_without_set_message_ttl
@store_messages
=
'on'
@min_message_buffer_timeout
=
nil
@max_message_buffer_length
=
5
@memory_cleanup_timeout
=
'30s'
end
def
test_message_cleanup_without_set_message_ttl
channel
=
'ch_test_message_cleanup_without_set_message_ttl'
headers
=
{
'accept'
=>
'text/html'
}
body
=
'message to create a channel'
EventMachine
.
run
{
10
.
times
do
|
i
|
publish_message_inline
(
channel
,
headers
,
body
)
if
i
==
9
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_1
.
callback
{
assert_equal
(
200
,
pub_1
.
response_header
.
status
,
"Don't get channels statistics"
)
assert_not_equal
(
0
,
pub_1
.
response_header
.
content_length
,
"Don't received channels statistics"
)
assert_equal
(
@max_message_buffer_length
,
JSON
.
parse
(
pub_1
.
response
)[
"stored_messages"
].
to_i
,
"Don't store messages"
)
sleep
(
15
)
# wait cleanup timer to be executed one time
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
.
callback
{
assert_equal
(
200
,
pub_2
.
response_header
.
status
,
"Don't get channels statistics"
)
assert_not_equal
(
0
,
pub_2
.
response_header
.
content_length
,
"Don't received channels statistics"
)
assert_equal
(
@max_message_buffer_length
,
JSON
.
parse
(
pub_2
.
response
)[
"stored_messages"
].
to_i
,
"Don't store messages"
)
EventMachine
.
stop
}
}
end
end
add_test_timeout
(
20
)
}
end
def
config_test_message_cleanup_without_max_messages_stored_per_channel
@store_messages
=
'on'
@min_message_buffer_timeout
=
'10s'
@max_message_buffer_length
=
nil
@memory_cleanup_timeout
=
'30s'
end
def
test_message_cleanup_without_max_messages_stored_per_channel
channel
=
'ch_test_message_cleanup_without_max_messages_stored_per_channel'
headers
=
{
'accept'
=>
'text/html'
}
body
=
'message to create a channel'
messages_to_publish
=
10
count
=
0
stored_messages_setp_1
=
0
EventMachine
.
run
{
EM
.
add_periodic_timer
(
messages_to_publish
/
12
.
to_f
)
do
# publish messages before cleanup timer be executed
if
(
count
<
messages_to_publish
)
publish_message_inline
(
channel
,
headers
,
body
)
elsif
(
count
==
messages_to_publish
)
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_1
.
callback
{
assert_equal
(
200
,
pub_1
.
response_header
.
status
,
"Don't get channels statistics"
)
assert_not_equal
(
0
,
pub_1
.
response_header
.
content_length
,
"Don't received channels statistics"
)
stored_messages_setp_1
=
JSON
.
parse
(
pub_1
.
response
)[
"stored_messages"
].
to_i
assert_equal
(
messages_to_publish
,
stored_messages_setp_1
,
"Don't store messages"
)
}
end
count
+=
1
end
EM
.
add_timer
(
15
)
do
# wait cleanup timer to be executed one time
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats?id='
+
channel
.
to_s
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
.
callback
{
assert_equal
(
200
,
pub_2
.
response_header
.
status
,
"Don't get channels statistics"
)
assert_not_equal
(
0
,
pub_2
.
response_header
.
content_length
,
"Don't received channels statistics"
)
stored_messages_setp_2
=
JSON
.
parse
(
pub_2
.
response
)[
"stored_messages"
].
to_i
assert
(
stored_messages_setp_1
>
stored_messages_setp_2
,
"Don't clear messages"
)
assert
(
stored_messages_setp_2
>=
(
messages_to_publish
/
2
),
"Cleared all messages"
)
EventMachine
.
stop
}
end
add_test_timeout
(
20
)
}
end
def
config_test_channel_cleanup
@min_message_buffer_timeout
=
'10s'
@max_reserved_memory
=
"65k"
...
...
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