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
63d37f43
Commit
63d37f43
authored
Dec 31, 2015
by
Wandenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add some log messages to check memory allocation problems
parent
9cc9f7f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
ngx_http_push_stream_module_utils.c
src/ngx_http_push_stream_module_utils.c
+11
-2
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_utils.c
View file @
63d37f43
...
...
@@ -275,6 +275,7 @@ ngx_http_push_stream_convert_char_to_msg_on_shared(ngx_http_push_stream_main_con
int
i
=
0
;
if
((
msg
=
ngx_slab_alloc
(
shpool
,
sizeof
(
ngx_http_push_stream_msg_t
)))
==
NULL
)
{
ngx_log_error
(
NGX_LOG_ERR
,
ngx_cycle
->
log
,
0
,
"push stream module: unable to allocate root structure message in shared memory"
);
return
NULL
;
}
...
...
@@ -293,6 +294,7 @@ ngx_http_push_stream_convert_char_to_msg_on_shared(ngx_http_push_stream_main_con
ngx_queue_init
(
&
msg
->
queue
);
if
((
msg
->
raw
.
data
=
ngx_slab_alloc
(
shpool
,
len
+
1
))
==
NULL
)
{
ngx_log_error
(
NGX_LOG_ERR
,
ngx_cycle
->
log
,
0
,
"push stream module: unable to allocate raw data message in shared memory"
);
ngx_http_push_stream_free_message_memory
(
shpool
,
msg
);
return
NULL
;
}
...
...
@@ -304,16 +306,19 @@ ngx_http_push_stream_convert_char_to_msg_on_shared(ngx_http_push_stream_main_con
if
(
ngx_http_push_stream_apply_text_template
(
&
msg
->
event_id
,
&
msg
->
event_id_message
,
event_id
,
&
NGX_HTTP_PUSH_STREAM_EVENTSOURCE_ID_TEMPLATE
,
&
NGX_HTTP_PUSH_STREAM_TOKEN_MESSAGE_EVENT_ID
,
shpool
,
temp_pool
)
!=
NGX_OK
)
{
ngx_log_error
(
NGX_LOG_ERR
,
ngx_cycle
->
log
,
0
,
"push stream module: unable to allocate event id message in shared memory"
);
ngx_http_push_stream_free_message_memory
(
shpool
,
msg
);
return
NULL
;
}
if
(
ngx_http_push_stream_apply_text_template
(
&
msg
->
event_type
,
&
msg
->
event_type_message
,
event_type
,
&
NGX_HTTP_PUSH_STREAM_EVENTSOURCE_EVENT_TEMPLATE
,
&
NGX_HTTP_PUSH_STREAM_TOKEN_MESSAGE_EVENT_TYPE
,
shpool
,
temp_pool
)
!=
NGX_OK
)
{
ngx_log_error
(
NGX_LOG_ERR
,
ngx_cycle
->
log
,
0
,
"push stream module: unable to allocate event type message in shared memory"
);
ngx_http_push_stream_free_message_memory
(
shpool
,
msg
);
return
NULL
;
}
if
((
msg
->
formatted_messages
=
ngx_slab_alloc
(
shpool
,
sizeof
(
ngx_str_t
)
*
msg
->
qtd_templates
))
==
NULL
)
{
if
((
msg
->
formatted_messages
=
ngx_slab_calloc
(
shpool
,
sizeof
(
ngx_str_t
)
*
msg
->
qtd_templates
))
==
NULL
)
{
ngx_log_error
(
NGX_LOG_ERR
,
ngx_cycle
->
log
,
0
,
"push stream module: unable to allocate format_messages message in shared memory"
);
ngx_http_push_stream_free_message_memory
(
shpool
,
msg
);
return
NULL
;
}
...
...
@@ -358,6 +363,7 @@ ngx_http_push_stream_convert_char_to_msg_on_shared(ngx_http_push_stream_main_con
ngx_str_t
*
formmated
=
(
msg
->
formatted_messages
+
i
);
if
((
text
==
NULL
)
||
((
formmated
->
data
=
ngx_slab_alloc
(
shpool
,
text
->
len
))
==
NULL
))
{
ngx_log_error
(
NGX_LOG_ERR
,
ngx_cycle
->
log
,
0
,
"push stream module: unable to allocate full message %d in shared memory"
,
i
);
ngx_http_push_stream_free_message_memory
(
shpool
,
msg
);
return
NULL
;
}
...
...
@@ -1633,8 +1639,11 @@ ngx_http_push_stream_ntohll(uint64_t value) {
if
(
*
(
char
*
)
&
num
==
42
)
{
uint32_t
high_part
=
ntohl
((
uint32_t
)(
value
>>
32
));
uint32_t
low_part
=
ntohl
((
uint32_t
)(
value
&
0xFFFFFFFFLL
));
return
(((
uint64_t
)
low_part
)
<<
32
)
|
high_part
;
uint64_t
result
=
(((
uint64_t
)
low_part
)
<<
32
)
|
high_part
;
ngx_log_error
(
NGX_LOG_ERR
,
ngx_cycle
->
log
,
0
,
"push stream module: FRAME_SIZE = LITTLE payload_len received: %016XL / %ui, result: %016XL / %ui"
,
value
,
value
,
result
,
result
);
return
result
;
}
else
{
ngx_log_error
(
NGX_LOG_ERR
,
ngx_cycle
->
log
,
0
,
"push stream module: FRAME_SIZE = BIG payload_len received: %016XL / %ui"
,
value
,
value
);
return
value
;
}
}
...
...
src/ngx_http_push_stream_module_websocket.c
View file @
63d37f43
...
...
@@ -322,7 +322,7 @@ ngx_http_push_stream_websocket_reading(ngx_http_request_t *r)
if
(
ctx
->
frame
->
payload
==
NULL
)
{
if
((
ctx
->
frame
->
payload
=
ngx_pcalloc
(
ctx
->
temp_pool
,
ctx
->
frame
->
payload_len
))
==
NULL
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"push stream module: unable to allocate memory for payload
"
);
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"push stream module: unable to allocate memory for payload
for %ui bytes"
,
ctx
->
frame
->
payload_len
);
goto
finalize
;
}
...
...
@@ -373,6 +373,7 @@ ngx_http_push_stream_websocket_reading(ngx_http_request_t *r)
}
if
(
ngx_http_push_stream_add_msg_to_channel
(
mcf
,
r
->
connection
->
log
,
subscription
->
channel
,
ctx
->
frame
->
payload
,
ctx
->
frame
->
payload_len
,
NULL
,
NULL
,
cf
->
store_messages
,
ctx
->
temp_pool
)
!=
NGX_OK
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"push stream module: unable to allocate memory from websocket %ui bytes - msg: '%*s'"
,
ctx
->
frame
->
payload_len
,
ctx
->
frame
->
payload_len
,
ctx
->
frame
->
payload
);
goto
finalize
;
}
}
...
...
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