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
49ac6540
Commit
49ac6540
authored
Mar 11, 2011
by
Wandenberg Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formatting hostname before generate channels statistics
parent
33151e43
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
6 deletions
+28
-6
ngx_http_push_stream_module_utils.h
include/ngx_http_push_stream_module_utils.h
+1
-0
ngx_http_push_stream_module.c
src/ngx_http_push_stream_module.c
+10
-6
ngx_http_push_stream_module_utils.c
src/ngx_http_push_stream_module_utils.c
+17
-0
No files found.
include/ngx_http_push_stream_module_utils.h
View file @
49ac6540
...
@@ -175,5 +175,6 @@ static ngx_inline void ngx_http_push_stream_ensure_qtd_of_messages_locked(n
...
@@ -175,5 +175,6 @@ static ngx_inline void ngx_http_push_stream_ensure_qtd_of_messages_locked(n
static
ngx_http_push_stream_content_subtype_t
*
ngx_http_push_stream_match_channel_info_format_and_content_type
(
ngx_http_request_t
*
r
,
ngx_uint_t
default_subtype
);
static
ngx_http_push_stream_content_subtype_t
*
ngx_http_push_stream_match_channel_info_format_and_content_type
(
ngx_http_request_t
*
r
,
ngx_uint_t
default_subtype
);
static
ngx_str_t
*
ngx_http_push_stream_get_formatted_current_time
(
ngx_pool_t
*
pool
);
static
ngx_str_t
*
ngx_http_push_stream_get_formatted_current_time
(
ngx_pool_t
*
pool
);
static
ngx_str_t
*
ngx_http_push_stream_get_formatted_hostname
(
ngx_pool_t
*
pool
);
#endif
/* NGX_HTTP_PUSH_STREAM_MODULE_UTILS_H_ */
#endif
/* NGX_HTTP_PUSH_STREAM_MODULE_UTILS_H_ */
src/ngx_http_push_stream_module.c
View file @
49ac6540
...
@@ -120,16 +120,17 @@ ngx_http_push_stream_send_response_all_channels_info_summarized(ngx_http_request
...
@@ -120,16 +120,17 @@ ngx_http_push_stream_send_response_all_channels_info_summarized(ngx_http_request
ngx_buf_t
*
b
;
ngx_buf_t
*
b
;
ngx_uint_t
len
;
ngx_uint_t
len
;
ngx_str_t
*
currenttime
;
ngx_str_t
*
currenttime
,
*
hostname
;
ngx_http_push_stream_shm_data_t
*
shm_data
;
ngx_http_push_stream_shm_data_t
*
shm_data
;
ngx_http_push_stream_content_subtype_t
*
subtype
;
ngx_http_push_stream_content_subtype_t
*
subtype
;
subtype
=
ngx_http_push_stream_match_channel_info_format_and_content_type
(
r
,
1
);
subtype
=
ngx_http_push_stream_match_channel_info_format_and_content_type
(
r
,
1
);
currenttime
=
ngx_http_push_stream_get_formatted_current_time
(
r
->
pool
);
currenttime
=
ngx_http_push_stream_get_formatted_current_time
(
r
->
pool
);
hostname
=
ngx_http_push_stream_get_formatted_hostname
(
r
->
pool
);
shm_data
=
(
ngx_http_push_stream_shm_data_t
*
)
ngx_http_push_stream_shm_zone
->
data
;
shm_data
=
(
ngx_http_push_stream_shm_data_t
*
)
ngx_http_push_stream_shm_zone
->
data
;
len
=
3
*
NGX_INT_T_LEN
+
subtype
->
format_summarized
->
len
+
ngx_cycle
->
hostname
.
len
+
currenttime
->
len
-
16
;
// minus 16 sprintf
len
=
3
*
NGX_INT_T_LEN
+
subtype
->
format_summarized
->
len
+
hostname
->
len
+
currenttime
->
len
-
16
;
// minus 16 sprintf
if
((
b
=
ngx_create_temp_buf
(
r
->
pool
,
len
))
==
NULL
)
{
if
((
b
=
ngx_create_temp_buf
(
r
->
pool
,
len
))
==
NULL
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"Failed to allocate response buffer."
);
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"Failed to allocate response buffer."
);
...
@@ -137,7 +138,7 @@ ngx_http_push_stream_send_response_all_channels_info_summarized(ngx_http_request
...
@@ -137,7 +138,7 @@ ngx_http_push_stream_send_response_all_channels_info_summarized(ngx_http_request
}
}
ngx_memset
(
b
->
start
,
'\0'
,
len
);
ngx_memset
(
b
->
start
,
'\0'
,
len
);
b
->
last
=
ngx_sprintf
(
b
->
start
,
(
char
*
)
subtype
->
format_summarized
->
data
,
ngx_cycle
->
hostname
.
data
,
currenttime
->
data
,
shm_data
->
channels
,
shm_data
->
broadcast_channels
,
shm_data
->
published_messages
,
shm_data
->
subscribers
);
b
->
last
=
ngx_sprintf
(
b
->
start
,
(
char
*
)
subtype
->
format_summarized
->
data
,
hostname
->
data
,
currenttime
->
data
,
shm_data
->
channels
,
shm_data
->
broadcast_channels
,
shm_data
->
published_messages
,
shm_data
->
subscribers
);
return
ngx_http_push_stream_send_buf_response
(
r
,
b
,
subtype
->
content_type
,
NGX_HTTP_OK
);
return
ngx_http_push_stream_send_buf_response
(
r
,
b
,
subtype
->
content_type
,
NGX_HTTP_OK
);
}
}
...
@@ -178,7 +179,7 @@ static ngx_int_t
...
@@ -178,7 +179,7 @@ static ngx_int_t
ngx_http_push_stream_send_response_all_channels_info_detailed
(
ngx_http_request_t
*
r
)
{
ngx_http_push_stream_send_response_all_channels_info_detailed
(
ngx_http_request_t
*
r
)
{
ngx_int_t
rc
;
ngx_int_t
rc
;
ngx_chain_t
*
chain
;
ngx_chain_t
*
chain
;
ngx_str_t
*
currenttime
;
ngx_str_t
*
currenttime
,
*
hostname
;
ngx_str_t
header_response
;
ngx_str_t
header_response
;
ngx_queue_t
queue_channel_info
;
ngx_queue_t
queue_channel_info
;
ngx_queue_t
*
cur
,
*
next
;
ngx_queue_t
*
cur
,
*
next
;
...
@@ -220,13 +221,16 @@ ngx_http_push_stream_send_response_all_channels_info_detailed(ngx_http_request_t
...
@@ -220,13 +221,16 @@ ngx_http_push_stream_send_response_all_channels_info_detailed(ngx_http_request_t
// get formatted current time
// get formatted current time
currenttime
=
ngx_http_push_stream_get_formatted_current_time
(
r
->
pool
);
currenttime
=
ngx_http_push_stream_get_formatted_current_time
(
r
->
pool
);
// get formatted hostname
hostname
=
ngx_http_push_stream_get_formatted_hostname
(
r
->
pool
);
// send content header
// send content header
if
((
header_response
.
data
=
ngx_pcalloc
(
r
->
pool
,
head
->
len
+
ngx_cycle
->
hostname
.
len
+
currenttime
->
len
+
1
))
==
NULL
)
{
if
((
header_response
.
data
=
ngx_pcalloc
(
r
->
pool
,
head
->
len
+
hostname
->
len
+
currenttime
->
len
+
1
))
==
NULL
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"push stream module: unable to allocate memory for response channels info"
);
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"push stream module: unable to allocate memory for response channels info"
);
return
NGX_HTTP_INTERNAL_SERVER_ERROR
;
return
NGX_HTTP_INTERNAL_SERVER_ERROR
;
}
}
ngx_sprintf
(
header_response
.
data
,
(
char
*
)
head
->
data
,
ngx_cycle
->
hostname
.
data
,
currenttime
->
data
,
shm_data
->
channels
,
shm_data
->
broadcast_channels
);
ngx_sprintf
(
header_response
.
data
,
(
char
*
)
head
->
data
,
hostname
->
data
,
currenttime
->
data
,
shm_data
->
channels
,
shm_data
->
broadcast_channels
);
header_response
.
len
=
ngx_strlen
(
header_response
.
data
);
header_response
.
len
=
ngx_strlen
(
header_response
.
data
);
ngx_http_push_stream_send_response_chunk
(
r
,
&
header_response
,
0
);
ngx_http_push_stream_send_response_chunk
(
r
,
&
header_response
,
0
);
...
...
src/ngx_http_push_stream_module_utils.c
View file @
49ac6540
...
@@ -541,3 +541,20 @@ ngx_http_push_stream_get_formatted_current_time(ngx_pool_t *pool)
...
@@ -541,3 +541,20 @@ ngx_http_push_stream_get_formatted_current_time(ngx_pool_t *pool)
return
currenttime
;
return
currenttime
;
}
}
static
ngx_str_t
*
ngx_http_push_stream_get_formatted_hostname
(
ngx_pool_t
*
pool
)
{
ngx_str_t
*
hostname
;
hostname
=
(
ngx_str_t
*
)
ngx_pcalloc
(
pool
,
sizeof
(
ngx_str_t
)
+
ngx_cycle
->
hostname
.
len
+
1
);
//hostname length plus 1
if
(
hostname
!=
NULL
)
{
hostname
->
data
=
(
u_char
*
)
hostname
+
sizeof
(
ngx_str_t
);
ngx_memcpy
(
hostname
->
data
,
ngx_cycle
->
hostname
.
data
,
ngx_cycle
->
hostname
.
len
);
hostname
->
len
=
ngx_strlen
(
hostname
->
data
);
}
else
{
hostname
=
&
NGX_HTTP_PUSH_STREAM_EMPTY
;
}
return
hostname
;
}
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