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
99243a4b
Commit
99243a4b
authored
Apr 18, 2015
by
Wandenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ensure that buffers content will not be changed and the allocated memory is clean
parent
8147b89e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
15 deletions
+29
-15
ngx_http_push_stream_module.c
src/ngx_http_push_stream_module.c
+1
-0
ngx_http_push_stream_module_publisher.c
src/ngx_http_push_stream_module_publisher.c
+2
-0
ngx_http_push_stream_module_setup.c
src/ngx_http_push_stream_module_setup.c
+2
-2
ngx_http_push_stream_module_subscriber.c
src/ngx_http_push_stream_module_subscriber.c
+1
-1
ngx_http_push_stream_module_utils.c
src/ngx_http_push_stream_module_utils.c
+21
-11
ngx_http_push_stream_module_websocket.c
src/ngx_http_push_stream_module_websocket.c
+2
-1
No files found.
src/ngx_http_push_stream_module.c
View file @
99243a4b
...
...
@@ -139,6 +139,7 @@ ngx_http_push_stream_send_response_channels_info(ngx_http_request_t *r, ngx_queu
chain
->
buf
->
last_buf
=
0
;
chain
->
buf
->
memory
=
1
;
chain
->
buf
->
temporary
=
0
;
chain
->
buf
->
pos
=
text
->
data
;
chain
->
buf
->
last
=
text
->
data
+
text
->
len
;
chain
->
buf
->
start
=
chain
->
buf
->
pos
;
...
...
src/ngx_http_push_stream_module_publisher.c
View file @
99243a4b
...
...
@@ -158,6 +158,8 @@ ngx_http_push_stream_read_request_body_to_buffer(ngx_http_request_t *r)
buf
=
ngx_create_temp_buf
(
r
->
pool
,
r
->
headers_in
.
content_length_n
+
1
);
if
(
buf
!=
NULL
)
{
buf
->
memory
=
1
;
buf
->
temporary
=
0
;
ngx_memset
(
buf
->
start
,
'\0'
,
r
->
headers_in
.
content_length_n
+
1
);
chain
=
r
->
request_body
->
bufs
;
...
...
src/ngx_http_push_stream_module_setup.c
View file @
99243a4b
...
...
@@ -362,7 +362,7 @@ ngx_http_push_stream_postconfig(ngx_conf_t *cf)
{
if
((
ngx_http_push_stream_padding_max_len
>
0
)
&&
(
ngx_http_push_stream_module_paddings_chunks
==
NULL
))
{
ngx_uint_t
steps
=
ngx_http_push_stream_padding_max_len
/
100
;
if
((
ngx_http_push_stream_module_paddings_chunks
=
ngx_palloc
(
cf
->
pool
,
sizeof
(
ngx_str_t
)
*
(
steps
+
1
)))
==
NULL
)
{
if
((
ngx_http_push_stream_module_paddings_chunks
=
ngx_p
c
alloc
(
cf
->
pool
,
sizeof
(
ngx_str_t
)
*
(
steps
+
1
)))
==
NULL
)
{
ngx_conf_log_error
(
NGX_LOG_ERR
,
cf
,
0
,
"push stream module: unable to allocate memory to create padding messages"
);
return
NGX_ERROR
;
}
...
...
@@ -394,7 +394,7 @@ ngx_http_push_stream_postconfig(ngx_conf_t *cf)
if
((
ngx_http_push_stream_padding_max_len
>
0
)
&&
(
ngx_http_push_stream_module_paddings_chunks_for_eventsource
==
NULL
))
{
ngx_uint_t
steps
=
ngx_http_push_stream_padding_max_len
/
100
;
if
((
ngx_http_push_stream_module_paddings_chunks_for_eventsource
=
ngx_palloc
(
cf
->
pool
,
sizeof
(
ngx_str_t
)
*
(
steps
+
1
)))
==
NULL
)
{
if
((
ngx_http_push_stream_module_paddings_chunks_for_eventsource
=
ngx_p
c
alloc
(
cf
->
pool
,
sizeof
(
ngx_str_t
)
*
(
steps
+
1
)))
==
NULL
)
{
ngx_conf_log_error
(
NGX_LOG_ERR
,
cf
,
0
,
"push stream module: unable to allocate memory to create padding messages for eventsource"
);
return
NGX_ERROR
;
}
...
...
src/ngx_http_push_stream_module_subscriber.c
View file @
99243a4b
...
...
@@ -602,7 +602,7 @@ ngx_http_push_stream_create_channel_subscription(ngx_http_request_t *r, ngx_http
{
ngx_http_push_stream_subscription_t
*
subscription
;
if
((
subscription
=
ngx_palloc
(
r
->
pool
,
sizeof
(
ngx_http_push_stream_subscription_t
)))
==
NULL
)
{
if
((
subscription
=
ngx_p
c
alloc
(
r
->
pool
,
sizeof
(
ngx_http_push_stream_subscription_t
)))
==
NULL
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"push stream module: unable to allocate subscribed channel reference"
);
return
NULL
;
}
...
...
src/ngx_http_push_stream_module_utils.c
View file @
99243a4b
...
...
@@ -748,6 +748,7 @@ ngx_http_push_stream_send_response_text(ngx_http_request_t *r, const u_char *tex
b
->
last_in_chain
=
1
;
b
->
flush
=
1
;
b
->
memory
=
1
;
b
->
temporary
=
0
;
b
->
pos
=
(
u_char
*
)
text
;
b
->
start
=
b
->
pos
;
b
->
end
=
b
->
pos
+
len
;
...
...
@@ -1177,7 +1178,7 @@ ngx_http_push_stream_timer_set(ngx_msec_t timer_interval, ngx_event_t *event, ng
static
void
ngx_http_push_stream_timer_reset
(
ngx_msec_t
timer_interval
,
ngx_event_t
*
timer_event
)
{
if
(
!
ngx_exiting
&&
(
timer_interval
!=
NGX_CONF_UNSET_MSEC
))
{
if
(
!
ngx_exiting
&&
(
timer_interval
!=
NGX_CONF_UNSET_MSEC
)
&&
(
timer_event
!=
NULL
)
)
{
if
(
timer_event
->
timedout
)
{
ngx_time_update
();
}
...
...
@@ -1192,12 +1193,17 @@ ngx_http_push_stream_ping_timer_wake_handler(ngx_event_t *ev)
ngx_http_request_t
*
r
=
(
ngx_http_request_t
*
)
ev
->
data
;
ngx_http_push_stream_main_conf_t
*
mcf
=
ngx_http_get_module_main_conf
(
r
,
ngx_http_push_stream_module
);
ngx_http_push_stream_loc_conf_t
*
pslcf
=
ngx_http_get_module_loc_conf
(
r
,
ngx_http_push_stream_module
);
ngx_http_push_stream_module_ctx_t
*
ctx
=
ngx_http_get_module_ctx
(
r
,
ngx_http_push_stream_module
);
ngx_int_t
rc
=
NGX_OK
;
if
((
ctx
==
NULL
)
||
(
ctx
->
ping_timer
==
NULL
))
{
return
;
}
if
(
pslcf
->
location_type
==
NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_EVENTSOURCE
)
{
rc
=
ngx_http_push_stream_send_response_text
(
r
,
NGX_HTTP_PUSH_STREAM_EVENTSOURCE_PING_MESSAGE_CHUNK
.
data
,
NGX_HTTP_PUSH_STREAM_EVENTSOURCE_PING_MESSAGE_CHUNK
.
len
,
0
);
}
else
if
(
pslcf
->
location_type
==
NGX_HTTP_PUSH_STREAM_SUBSCRIBER_MODE_WEBSOCKET
)
{
rc
=
ngx_http_push_stream_send_response_text
(
r
,
NGX_HTTP_PUSH_STREAM_WEBSOCKET_PING_LAST_FRAME_BYTE
,
sizeof
(
NGX_HTTP_PUSH_STREAM_WEBSOCKET_PING_LAST_FRAME_BYTE
),
1
);
rc
=
ngx_http_push_stream_send_response_text
(
r
,
NGX_HTTP_PUSH_STREAM_WEBSOCKET_PING_LAST_FRAME_BYTE
,
sizeof
(
NGX_HTTP_PUSH_STREAM_WEBSOCKET_PING_LAST_FRAME_BYTE
),
0
);
}
else
{
if
(
mcf
->
ping_msg
==
NULL
)
{
// create ping message
...
...
@@ -1214,7 +1220,6 @@ ngx_http_push_stream_ping_timer_wake_handler(ngx_event_t *ev)
if
(
rc
!=
NGX_OK
)
{
ngx_http_push_stream_send_response_finalize
(
r
);
}
else
{
ngx_http_push_stream_module_ctx_t
*
ctx
=
ngx_http_get_module_ctx
(
r
,
ngx_http_push_stream_module
);
ngx_http_push_stream_timer_reset
(
pslcf
->
ping_message_interval
,
ctx
->
ping_timer
);
}
}
...
...
@@ -1424,16 +1429,19 @@ ngx_http_push_stream_cleanup_request_context(ngx_http_request_t *r)
ngx_del_timer
(
ctx
->
ping_timer
);
}
if
(
ctx
->
subscriber
!=
NULL
)
{
ngx_http_push_stream_worker_subscriber_cleanup
(
ctx
->
subscriber
);
}
if
(
ctx
->
temp_pool
!=
NULL
)
{
ngx_destroy_pool
(
ctx
->
temp_pool
);
ctx
->
temp_pool
=
NULL
;
}
if
(
ctx
->
subscriber
!=
NULL
)
{
ngx_http_push_stream_worker_subscriber_cleanup
(
ctx
->
subscriber
);
ctx
->
temp_pool
=
NULL
;
ctx
->
disconnect_timer
=
NULL
;
ctx
->
ping_timer
=
NULL
;
ctx
->
subscriber
=
NULL
;
}
}
}
...
...
@@ -1900,6 +1908,8 @@ ngx_http_push_stream_send_only_added_headers(ngx_http_request_t *r)
out
.
buf
=
b
;
out
.
next
=
NULL
;
b
->
flush
=
1
;
b
->
memory
=
1
;
b
->
temporary
=
0
;
return
ngx_http_write_filter
(
r
,
&
out
);
}
...
...
@@ -1917,7 +1927,7 @@ ngx_http_push_stream_parse_paddings(ngx_conf_t *cf, ngx_str_t *paddings_by_user
ngx_str_t
aux
,
*
agent
;
if
((
paddings
=
ngx_palloc
(
cf
->
pool
,
sizeof
(
ngx_queue_t
)))
==
NULL
)
{
if
((
paddings
=
ngx_p
c
alloc
(
cf
->
pool
,
sizeof
(
ngx_queue_t
)))
==
NULL
)
{
ngx_conf_log_error
(
NGX_LOG_ERR
,
cf
,
0
,
"push stream module: unable to allocate memory to save padding info"
);
return
NULL
;
}
...
...
@@ -1976,7 +1986,7 @@ ngx_http_push_stream_parse_paddings(ngx_conf_t *cf, ngx_str_t *paddings_by_user
return
NULL
;
}
if
((
padding
=
ngx_palloc
(
cf
->
pool
,
sizeof
(
ngx_http_push_stream_padding_t
)))
==
NULL
)
{
if
((
padding
=
ngx_p
c
alloc
(
cf
->
pool
,
sizeof
(
ngx_http_push_stream_padding_t
)))
==
NULL
)
{
ngx_conf_log_error
(
NGX_LOG_ERR
,
cf
,
0
,
"push stream module: unable to allocate memory to save padding info"
);
return
NULL
;
}
...
...
src/ngx_http_push_stream_module_websocket.c
View file @
99243a4b
...
...
@@ -377,5 +377,6 @@ ngx_http_push_stream_set_buffer(ngx_buf_t *buf, u_char *start, u_char *last, ssi
buf
->
pos
=
buf
->
start
;
buf
->
last
=
(
last
!=
NULL
)
?
last
:
start
;
buf
->
end
=
buf
->
start
+
len
;
buf
->
temporary
=
1
;
buf
->
temporary
=
0
;
buf
->
memory
=
1
;
}
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