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
baed4ca7
Commit
baed4ca7
authored
Dec 05, 2012
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replacing unrecoverable_channels tree by a queue to be easier go through all channels on it
parent
57e0e153
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
128 additions
and
72 deletions
+128
-72
ngx_http_push_stream_module.h
include/ngx_http_push_stream_module.h
+2
-1
ngx_http_push_stream_module_setup.c
src/ngx_http_push_stream_module_setup.c
+2
-5
ngx_http_push_stream_module_utils.c
src/ngx_http_push_stream_module_utils.c
+58
-65
test_cleanup_memory.rb
test/test_cleanup_memory.rb
+66
-1
No files found.
include/ngx_http_push_stream_module.h
View file @
baed4ca7
...
...
@@ -136,6 +136,7 @@ typedef struct {
// our typecast-friendly rbtree node (channel)
typedef
struct
{
ngx_rbtree_node_t
node
;
// this MUST be first
ngx_queue_t
queue
;
ngx_str_t
id
;
ngx_uint_t
last_message_id
;
time_t
last_message_time
;
...
...
@@ -213,7 +214,7 @@ typedef struct {
ngx_uint_t
subscribers
;
// # of subscribers in all channels
ngx_http_push_stream_msg_t
messages_to_delete
;
ngx_rbtree_t
channels_to_delete
;
ngx_
rbtree_t
unrecoverable_channels
;
ngx_
queue_t
unrecoverable_channels
;
ngx_http_push_stream_worker_data_t
ipc
[
NGX_MAX_PROCESSES
];
// interprocess stuff
time_t
startup
;
time_t
last_message_time
;
...
...
src/ngx_http_push_stream_module_setup.c
View file @
baed4ca7
...
...
@@ -893,7 +893,7 @@ ngx_http_push_stream_init_shm_zone(ngx_shm_zone_t *shm_zone, void *data)
}
ngx_slab_pool_t
*
shpool
=
(
ngx_slab_pool_t
*
)
shm_zone
->
shm
.
addr
;
ngx_rbtree_node_t
*
sentinel
,
*
remove_sentinel
,
*
unrecoverable_sentinel
;
ngx_rbtree_node_t
*
sentinel
,
*
remove_sentinel
;
ngx_http_push_stream_shm_data_t
*
d
;
if
((
d
=
(
ngx_http_push_stream_shm_data_t
*
)
ngx_slab_alloc
(
shpool
,
sizeof
(
*
d
)))
==
NULL
)
{
//shm_data plus an array.
...
...
@@ -924,10 +924,7 @@ ngx_http_push_stream_init_shm_zone(ngx_shm_zone_t *shm_zone, void *data)
}
ngx_rbtree_init
(
&
d
->
channels_to_delete
,
remove_sentinel
,
ngx_http_push_stream_rbtree_insert
);
if
((
unrecoverable_sentinel
=
ngx_slab_alloc
(
shpool
,
sizeof
(
*
unrecoverable_sentinel
)))
==
NULL
)
{
return
NGX_ERROR
;
}
ngx_rbtree_init
(
&
d
->
unrecoverable_channels
,
unrecoverable_sentinel
,
ngx_http_push_stream_rbtree_insert
);
ngx_queue_init
(
&
d
->
unrecoverable_channels
);
// create ping message
if
((
ngx_http_push_stream_ping_msg
=
ngx_http_push_stream_convert_char_to_msg_on_shared_locked
(
ngx_http_push_stream_module_main_conf
->
ping_message_text
.
data
,
ngx_http_push_stream_module_main_conf
->
ping_message_text
.
len
,
NULL
,
NGX_HTTP_PUSH_STREAM_PING_MESSAGE_ID
,
NULL
,
NULL
,
ngx_cycle
->
pool
))
==
NULL
)
{
...
...
src/ngx_http_push_stream_module_utils.c
View file @
baed4ca7
This diff is collapsed.
Click to expand it.
test/test_cleanup_memory.rb
View file @
baed4ca7
...
...
@@ -47,7 +47,7 @@ class TestCleanupMemory < Test::Unit::TestCase
i
+=
1
end
EM
.
add_timer
(
55
)
do
EM
.
add_timer
(
40
)
do
i
=
0
fill_memory_timer
=
EventMachine
::
PeriodicTimer
.
new
(
0.001
)
do
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
+
i
.
to_s
).
post
:body
=>
body
,
:head
=>
headers
,
:timeout
=>
30
...
...
@@ -66,6 +66,71 @@ class TestCleanupMemory < Test::Unit::TestCase
i
+=
1
end
end
add_test_timeout
(
45
)
end
end
def
create_and_delete_channel
(
channel
,
body
,
headers
,
&
block
)
pub_1
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
post
:body
=>
body
,
:head
=>
headers
,
:timeout
=>
30
pub_1
.
callback
do
if
pub_1
.
response_header
.
status
==
200
pub
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/pub?id='
+
channel
.
to_s
).
delete
:head
=>
headers
,
:timeout
=>
30
pub
.
callback
do
block
.
call
((
pub
.
response_header
.
status
==
200
)
?
:
success
:
:error
)
end
else
block
.
call
(
:error
)
end
end
end
def
create_and_delete_channel_in_loop
(
channel
,
body
,
headers
)
create_and_delete_channel
(
channel
,
body
,
headers
)
do
|
status
|
create_and_delete_channel_in_loop
(
channel
,
body
,
headers
)
if
status
==
:success
end
end
def
config_test_channel_cleanup_after_delete_same_id
@memory_cleanup_timeout
=
'30s'
@max_reserved_memory
=
"129k"
@min_message_buffer_timeout
=
'10s'
@max_message_buffer_length
=
nil
@publisher_mode
=
'admin'
end
def
test_channel_cleanup_after_delete_same_id
channel
=
'ch_test_channel_cleanup'
headers
=
{
'accept'
=>
'text/html'
}
body
=
'message to create a channel'
published_messages_setp_1
=
0
EventMachine
.
run
do
create_and_delete_channel_in_loop
(
channel
,
body
,
headers
)
EM
.
add_timer
(
5
)
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_2
.
response
)
published_messages_setp_1
=
result
[
"published_messages"
].
to_i
fail
(
"Don't create any message"
)
if
published_messages_setp_1
==
0
end
end
EM
.
add_timer
(
50
)
do
create_and_delete_channel_in_loop
(
channel
,
body
,
headers
)
EM
.
add_timer
(
5
)
do
pub_2
=
EventMachine
::
HttpRequest
.
new
(
nginx_address
+
'/channels-stats'
).
get
:head
=>
headers
,
:timeout
=>
60
pub_2
.
callback
do
fail
(
"Don't received the stats"
)
if
(
pub_2
.
response_header
.
status
!=
200
)
||
(
pub_2
.
response_header
.
content_length
==
0
)
result
=
JSON
.
parse
(
pub_2
.
response
)
assert_equal
(
published_messages_setp_1
,
result
[
"published_messages"
].
to_i
/
2
,
"Don't cleaned all memory"
)
EventMachine
.
stop
end
end
end
add_test_timeout
(
60
)
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