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
32d59def
Commit
32d59def
authored
Sep 08, 2013
by
Wandenberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move some code to utils to be reused
parent
ce06ce97
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
59 deletions
+59
-59
ngx_http_push_stream_module.h
include/ngx_http_push_stream_module.h
+6
-0
ngx_http_push_stream_module_subscriber.h
include/ngx_http_push_stream_module_subscriber.h
+0
-7
ngx_http_push_stream_module_utils.h
include/ngx_http_push_stream_module_utils.h
+1
-0
ngx_http_push_stream_module_subscriber.c
src/ngx_http_push_stream_module_subscriber.c
+0
-52
ngx_http_push_stream_module_utils.c
src/ngx_http_push_stream_module_utils.c
+52
-0
No files found.
include/ngx_http_push_stream_module.h
View file @
32d59def
...
...
@@ -163,6 +163,12 @@ struct ngx_http_push_stream_subscriber_s {
ngx_queue_t
worker_queue
;
};
typedef
struct
{
ngx_queue_t
queue
;
// this MUST be first
ngx_str_t
*
id
;
ngx_uint_t
backtrack_messages
;
}
ngx_http_push_stream_requested_channel_t
;
typedef
struct
{
ngx_event_t
*
disconnect_timer
;
ngx_event_t
*
ping_timer
;
...
...
include/ngx_http_push_stream_module_subscriber.h
View file @
32d59def
...
...
@@ -26,14 +26,7 @@
#ifndef NGX_HTTP_PUSH_STREAM_MODULE_SUBSCRIBER_H_
#define NGX_HTTP_PUSH_STREAM_MODULE_SUBSCRIBER_H_
typedef
struct
{
ngx_queue_t
queue
;
// this MUST be first
ngx_str_t
*
id
;
ngx_uint_t
backtrack_messages
;
}
ngx_http_push_stream_requested_channel_t
;
static
ngx_int_t
ngx_http_push_stream_subscriber_handler
(
ngx_http_request_t
*
r
);
ngx_http_push_stream_requested_channel_t
*
ngx_http_push_stream_parse_channels_ids_from_path
(
ngx_http_request_t
*
r
,
ngx_pool_t
*
pool
);
static
ngx_int_t
ngx_http_push_stream_validate_channels
(
ngx_http_request_t
*
r
,
ngx_http_push_stream_requested_channel_t
*
channels_ids
,
ngx_int_t
*
status_code
,
ngx_str_t
**
explain_error_message
);
#endif
/* NGX_HTTP_PUSH_STREAM_MODULE_SUBSCRIBER_H_ */
include/ngx_http_push_stream_module_utils.h
View file @
32d59def
...
...
@@ -295,5 +295,6 @@ uint64_t ngx_http_push_stream_ntohll(uint64_t value);
static
ngx_int_t
ngx_http_push_stream_set_expires
(
ngx_http_request_t
*
r
,
ngx_http_push_stream_expires_t
expires
,
time_t
expires_time
);
ngx_http_push_stream_requested_channel_t
*
ngx_http_push_stream_parse_channels_ids_from_path
(
ngx_http_request_t
*
r
,
ngx_pool_t
*
pool
);
#endif
/* NGX_HTTP_PUSH_STREAM_MODULE_UTILS_H_ */
src/ngx_http_push_stream_module_subscriber.c
View file @
32d59def
...
...
@@ -311,58 +311,6 @@ ngx_http_push_stream_subscriber_assign_channel(ngx_slab_pool_t *shpool, ngx_http
}
ngx_http_push_stream_requested_channel_t
*
ngx_http_push_stream_parse_channels_ids_from_path
(
ngx_http_request_t
*
r
,
ngx_pool_t
*
pool
)
{
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
*
cf
=
ngx_http_get_module_loc_conf
(
r
,
ngx_http_push_stream_module
);
ngx_str_t
vv_channels_path
=
ngx_null_string
;
ngx_http_push_stream_requested_channel_t
*
channels_ids
,
*
cur
;
ngx_str_t
aux
;
int
captures
[
15
];
ngx_int_t
n
;
ngx_http_push_stream_complex_value
(
r
,
cf
->
channels_path
,
&
vv_channels_path
);
if
(
vv_channels_path
.
len
==
0
)
{
return
NULL
;
}
if
((
channels_ids
=
ngx_pcalloc
(
pool
,
sizeof
(
ngx_http_push_stream_requested_channel_t
)))
==
NULL
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"push stream module: unable to allocate memory for channels_ids queue"
);
return
NULL
;
}
ngx_queue_init
(
&
channels_ids
->
queue
);
// doing the parser of given channel path
aux
.
data
=
vv_channels_path
.
data
;
do
{
aux
.
len
=
vv_channels_path
.
len
-
(
aux
.
data
-
vv_channels_path
.
data
);
if
((
n
=
ngx_regex_exec
(
mcf
->
backtrack_parser_regex
,
&
aux
,
captures
,
15
))
>=
0
)
{
if
((
cur
=
ngx_pcalloc
(
pool
,
sizeof
(
ngx_http_push_stream_requested_channel_t
)))
==
NULL
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"push stream module: unable to allocate memory for channel_id item"
);
return
NULL
;
}
if
((
cur
->
id
=
ngx_http_push_stream_create_str
(
pool
,
captures
[
0
]))
==
NULL
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"push stream module: unable to allocate memory for channel_id string"
);
return
NULL
;
}
ngx_memcpy
(
cur
->
id
->
data
,
aux
.
data
,
captures
[
0
]);
cur
->
backtrack_messages
=
0
;
if
(
captures
[
7
]
>
captures
[
6
])
{
cur
->
backtrack_messages
=
ngx_atoi
(
aux
.
data
+
captures
[
6
],
captures
[
7
]
-
captures
[
6
]);
}
ngx_queue_insert_tail
(
&
channels_ids
->
queue
,
&
cur
->
queue
);
aux
.
data
=
aux
.
data
+
captures
[
1
];
}
}
while
((
n
!=
NGX_REGEX_NO_MATCHED
)
&&
(
aux
.
data
<
(
vv_channels_path
.
data
+
vv_channels_path
.
len
)));
return
channels_ids
;
}
static
ngx_int_t
ngx_http_push_stream_validate_channels
(
ngx_http_request_t
*
r
,
ngx_http_push_stream_requested_channel_t
*
channels_ids
,
ngx_int_t
*
status_code
,
ngx_str_t
**
explain_error_message
)
{
...
...
src/ngx_http_push_stream_module_utils.c
View file @
32d59def
...
...
@@ -1879,3 +1879,55 @@ ngx_http_push_stream_set_expires(ngx_http_request_t *r, ngx_http_push_stream_exp
return
NGX_OK
;
}
ngx_http_push_stream_requested_channel_t
*
ngx_http_push_stream_parse_channels_ids_from_path
(
ngx_http_request_t
*
r
,
ngx_pool_t
*
pool
)
{
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
*
cf
=
ngx_http_get_module_loc_conf
(
r
,
ngx_http_push_stream_module
);
ngx_str_t
vv_channels_path
=
ngx_null_string
;
ngx_http_push_stream_requested_channel_t
*
channels_ids
,
*
cur
;
ngx_str_t
aux
;
int
captures
[
15
];
ngx_int_t
n
;
ngx_http_push_stream_complex_value
(
r
,
cf
->
channels_path
,
&
vv_channels_path
);
if
(
vv_channels_path
.
len
==
0
)
{
return
NULL
;
}
if
((
channels_ids
=
ngx_pcalloc
(
pool
,
sizeof
(
ngx_http_push_stream_requested_channel_t
)))
==
NULL
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"push stream module: unable to allocate memory for channels_ids queue"
);
return
NULL
;
}
ngx_queue_init
(
&
channels_ids
->
queue
);
// doing the parser of given channel path
aux
.
data
=
vv_channels_path
.
data
;
do
{
aux
.
len
=
vv_channels_path
.
len
-
(
aux
.
data
-
vv_channels_path
.
data
);
if
((
n
=
ngx_regex_exec
(
mcf
->
backtrack_parser_regex
,
&
aux
,
captures
,
15
))
>=
0
)
{
if
((
cur
=
ngx_pcalloc
(
pool
,
sizeof
(
ngx_http_push_stream_requested_channel_t
)))
==
NULL
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"push stream module: unable to allocate memory for channel_id item"
);
return
NULL
;
}
if
((
cur
->
id
=
ngx_http_push_stream_create_str
(
pool
,
captures
[
0
]))
==
NULL
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"push stream module: unable to allocate memory for channel_id string"
);
return
NULL
;
}
ngx_memcpy
(
cur
->
id
->
data
,
aux
.
data
,
captures
[
0
]);
cur
->
backtrack_messages
=
0
;
if
(
captures
[
7
]
>
captures
[
6
])
{
cur
->
backtrack_messages
=
ngx_atoi
(
aux
.
data
+
captures
[
6
],
captures
[
7
]
-
captures
[
6
]);
}
ngx_queue_insert_tail
(
&
channels_ids
->
queue
,
&
cur
->
queue
);
aux
.
data
=
aux
.
data
+
captures
[
1
];
}
}
while
((
n
!=
NGX_REGEX_NO_MATCHED
)
&&
(
aux
.
data
<
(
vv_channels_path
.
data
+
vv_channels_path
.
len
)));
return
channels_ids
;
}
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