Commit 93fe74e2 authored by Wandenberg's avatar Wandenberg

renamed broadcast feature to wildcard, more adequate with the way it works

parent 2391ddbc
h1(#changelog). Changelog
* Renamed broadcast feature to wildcard, more adequate with the way it works
** push_stream_broadcast_channel_prefix -> push_stream_wildcard_channel_prefix
** push_stream_broadcast_channel_max_qtd -> push_stream_wildcard_channel_max_qtd
** push_stream_max_number_of_broadcast_channels -> push_stream_max_number_of_wildcard_channels
* Removed push_stream_content_type directive, use default_type Nginx directive to set the value, except on JSONP and Event Source modes
* Removed push_stream_keepalive directive, let Nginx decide when to use keepalive and how many requests accept using keepalive_* directives
* Removed push_stream_shared_memory_cleanup_objects_ttl directive
......
......@@ -114,15 +114,15 @@ h1(#directives). Directives
| "push_stream_max_messages_stored_per_channel":push_stream_max_messages_stored_per_channel |   - |   x |   - |   - |   - |   - |
| "push_stream_max_channel_id_length":push_stream_max_channel_id_length |   - |   x |   - |   - |   - |   - |
| "push_stream_max_number_of_channels":push_stream_max_number_of_channels |   - |   x |   - |   - |   - |   - |
| "push_stream_max_number_of_broadcast_channels":push_stream_max_number_of_broadcast_channels |   - |   x |   - |   - |   - |   - |
| "push_stream_broadcast_channel_prefix":push_stream_broadcast_channel_prefix |   - |   x |   - |   - |   - |   - |
| "push_stream_max_number_of_wildcard_channels":push_stream_max_number_of_wildcard_channels |   - |   x |   - |   - |   - |   - |
| "push_stream_wildcard_channel_prefix":push_stream_wildcard_channel_prefix |   - |   x |   - |   - |   - |   - |
| "push_stream_channel_id":push_stream_channel_id |   - |   - |   - |   - |   - |   x |
| "push_stream_channels_path":push_stream_channels_path |   - |   - |   x |   x |   x |   - |
| "push_stream_authorized_channels_only":push_stream_authorized_channels_only |   - |   - |   x |   - |   - |   x |
| "push_stream_header_template":push_stream_header_template |   - |   - |   x |   - |   - |   x |
| "push_stream_message_template":push_stream_message_template |   - |   - |   x |   - |   - |   x |
| "push_stream_footer_template":push_stream_footer_template |   - |   - |   x |   - |   - |   x |
| "push_stream_broadcast_channel_max_qtd":push_stream_broadcast_channel_max_qtd |   - |   - |   x |   - |   - |   x |
| "push_stream_wildcard_channel_max_qtd":push_stream_wildcard_channel_max_qtd |   - |   - |   x |   - |   - |   x |
| "push_stream_ping_message_interval":push_stream_ping_message_interval |   - |   - |   x |   - |   - |   x |
| "push_stream_subscriber_connection_ttl":push_stream_subscriber_connection_ttl |   - |   - |   x |   - |   - |   x |
| "push_stream_longpolling_connection_ttl":push_stream_longpolling_connection_ttl |   - |   - |   x |   - |   - |   - |
......@@ -217,15 +217,15 @@ h1(#contributors). Contributors
[push_stream_max_messages_stored_per_channel]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_max_messages_stored_per_channel
[push_stream_max_channel_id_length]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_max_channel_id_length
[push_stream_max_number_of_channels]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_max_number_of_channels
[push_stream_max_number_of_broadcast_channels]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_max_number_of_broadcast_channels
[push_stream_broadcast_channel_prefix]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_broadcast_channel_prefix
[push_stream_max_number_of_wildcard_channels]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_max_number_of_wildcard_channels
[push_stream_wildcard_channel_prefix]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/main.textile#push_stream_wildcard_channel_prefix
[push_stream_channel_id]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/publishers.textile#push_stream_channel_id
[push_stream_channels_path]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_channels_path
[push_stream_authorized_channels_only]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_authorized_channels_only
[push_stream_header_template]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_header_template
[push_stream_message_template]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_message_template
[push_stream_footer_template]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_footer_template
[push_stream_broadcast_channel_max_qtd]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_broadcast_channel_max_qtd
[push_stream_wildcard_channel_max_qtd]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_wildcard_channel_max_qtd
[push_stream_ping_message_interval]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_ping_message_interval
[push_stream_subscriber_connection_ttl]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_subscriber_connection_ttl
[push_stream_longpolling_connection_ttl]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_longpolling_connection_ttl
......
......@@ -109,23 +109,27 @@ h2(#push_stream_max_number_of_channels). push_stream_max_number_of_channels <a n
The maximum number of concurrent channels on the server. If you do not want to limit the number of channels, just not set this directive.
h2(#push_stream_max_number_of_broadcast_channels). push_stream_max_number_of_broadcast_channels <a name="push_stream_max_number_of_broadcast_channels" href="#">&nbsp;</a>
h2(#push_stream_max_number_of_wildcard_channels). push_stream_max_number_of_wildcard_channels <a name="push_stream_max_number_of_wildcard_channels" href="#">&nbsp;</a>
*syntax:* _push_stream_max_number_of_broadcast_channels number_
*syntax:* _push_stream_max_number_of_wildcard_channels number_
*default:* _none_
*context:* _http_
The maximum number of concurrent broadcats channels on the server. If you do not want to limit the number of broadcast channels, just not set this directive.
The maximum number of concurrent wildcard channels on the server. If you do not want to limit the number of wildcard channels, just not set this directive.
h2(#push_stream_broadcast_channel_prefix). push_stream_broadcast_channel_prefix <a name="push_stream_broadcast_channel_prefix" href="#">&nbsp;</a>
h2(#push_stream_wildcard_channel_prefix). push_stream_wildcard_channel_prefix <a name="push_stream_wildcard_channel_prefix" href="#">&nbsp;</a>
*syntax:* _push_stream_broadcast_channel_prefix string_
*syntax:* _push_stream_wildcard_channel_prefix string_
*default:* _none_
*context:* _http_
The string prefix used to identify when a channel is a normal or broadcast channel, example: when you set this directive as "bd_", "bd_ch1" will be a broadcast channel
The string prefix used to identify a wildcard channel, example: when you set this directive as "bd_", "bd_ch1" will be a wildcard channel.
A wildcard channel is technically equals to a normal one. It is intended to be used when the "push_stream_authorized_channels_only":push_stream_authorized_channels_only is set to on.
[push_stream_authorized_channels_only]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_authorized_channels_only
......@@ -94,8 +94,9 @@ h2(#push_stream_authorized_channels_only). push_stream_authorized_channels_only
*context:* _location (push_stream_subscriber)_
Whether or not a subscriber may create a channel by making a request to a push_stream_subscriber location. If set to on, a publisher must send a POST request before a subscriber can request messages on the channel. Otherwise, all subscriber requests to nonexistent channels will get a 403 Forbidden response.
This restriction is not applied to broadcast channels, but to subscribe to a broadcast channel is necessary to subscribe at least to one normal channel, and if this directive is set to on this channel has to be created before.
When set to on, subscribers can connect only to a channel with at least one stored message.
All subscriber requests to nonexistent channels or channels without stored messages will get a 403 Forbidden response.
This restriction is not applied to wildcard channels, but to connect to a wildcard channel is necessary to connect to at least one normal channel on the same request.
h2(#push_stream_header_template). push_stream_header_template <a name="push_stream_header_template" href="#">&nbsp;</a>
......@@ -133,16 +134,16 @@ h2(#push_stream_footer_template). push_stream_footer_template <a name="push_stre
The text that will be sent to subscribers before connection is closed (channel deleted or subscriber timeout), except when long polling connections timed out.
h2(#push_stream_broadcast_channel_max_qtd). push_stream_broadcast_channel_max_qtd <a name="push_stream_broadcast_channel_max_qtd" href="#">&nbsp;</a>
h2(#push_stream_wildcard_channel_max_qtd). push_stream_wildcard_channel_max_qtd <a name="push_stream_wildcard_channel_max_qtd" href="#">&nbsp;</a>
*syntax:* _push_stream_broadcast_channel_max_qtd number_
*syntax:* _push_stream_wildcard_channel_max_qtd number_
*default:* _none_
*context:* _location (push_stream_subscriber)_
The maximum number of broadcast channels that a subscriber may sign on the request.
This directive works in conjunction with push_stream_authorized_channels_only to preserve the server from a kind of attack where a subscriber sign one normal channel and many nonexistent broadcast channels.
The maximum number of wildcard channels that a subscriber may sign on the request.
This directive works in conjunction with "push_stream_authorized_channels_only":push_stream_authorized_channels_only to preserve the server from a kind of attack where a subscriber sign one normal channel and many nonexistent wildcard channels.
h2(#push_stream_ping_message_interval). push_stream_ping_message_interval <a name="push_stream_ping_message_interval" href="#">&nbsp;</a>
......@@ -260,3 +261,4 @@ h2(#push_stream_allowed_origins). push_stream_allowed_origins <a name="push_stre
Set the value used on the Access-Control-Allow-Origin header to allow cross domain requests by javascript.
[eventsource_ref]http://dev.w3.org/html5/eventsource/
[push_stream_authorized_channels_only]https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/directives/subscribers.textile#push_stream_authorized_channels_only
......@@ -54,9 +54,9 @@ typedef struct {
time_t channel_inactivity_time;
ngx_str_t ping_message_text;
ngx_uint_t qtd_templates;
ngx_str_t broadcast_channel_prefix;
ngx_str_t wildcard_channel_prefix;
ngx_uint_t max_number_of_channels;
ngx_uint_t max_number_of_broadcast_channels;
ngx_uint_t max_number_of_wildcard_channels;
time_t message_ttl;
ngx_uint_t max_subscribers_per_channel;
ngx_uint_t max_messages_stored_per_channel;
......@@ -74,7 +74,7 @@ typedef struct {
ngx_str_t message_template;
ngx_int_t message_template_index;
ngx_str_t footer_template;
ngx_uint_t broadcast_channel_max_qtd;
ngx_uint_t wildcard_channel_max_qtd;
ngx_uint_t location_type;
ngx_msec_t ping_message_interval;
ngx_msec_t subscriber_connection_ttl;
......@@ -134,7 +134,7 @@ typedef struct {
time_t last_activity_time;
time_t expires;
ngx_flag_t deleted;
ngx_flag_t broadcast;
ngx_flag_t wildcard;
ngx_http_push_stream_msg_t *channel_deleted_message;
} ngx_http_push_stream_channel_t;
......@@ -195,7 +195,7 @@ typedef struct {
typedef struct {
ngx_rbtree_t tree;
ngx_uint_t channels; // # of channels being used
ngx_uint_t broadcast_channels; // # of broadcast channels being used
ngx_uint_t wildcard_channels; // # of wildcard channels being used
ngx_uint_t published_messages; // # of published messagens in all channels
ngx_uint_t stored_messages; // # of messages being stored
ngx_uint_t subscribers; // # of subscribers in all channels
......@@ -232,7 +232,7 @@ static const ngx_str_t NGX_HTTP_PUSH_STREAM_NO_CHANNEL_ID_MESSAGE = ngx_string(
static const ngx_str_t NGX_HTTP_PUSH_STREAM_NO_CHANNEL_ID_NOT_AUTHORIZED_MESSAGE = ngx_string("Channel id not authorized for this method.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_EMPTY_POST_REQUEST_MESSAGE = ngx_string("Empty post requests are not allowed.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TOO_LARGE_CHANNEL_ID_MESSAGE = ngx_string("Channel id is too large.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TOO_MUCH_BROADCAST_CHANNELS = ngx_string("Subscribed too much broadcast channels.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TOO_MUCH_WILDCARD_CHANNELS = ngx_string("Subscribed too much wildcard channels.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TOO_SUBSCRIBERS_PER_CHANNEL = ngx_string("Subscribers limit per channel has been exceeded.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_CANNOT_CREATE_CHANNELS = ngx_string("Subscriber could not create channels.");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_NUMBER_OF_CHANNELS_EXCEEDED_MESSAGE = ngx_string("Number of channels were exceeded.");
......
......@@ -49,7 +49,7 @@ ngx_socket_t ngx_http_push_stream_socketpairs[NGX_MAX_PROCESSES][2];
static ngx_int_t ngx_http_push_stream_register_worker_message_handler(ngx_cycle_t *cycle);
static void ngx_http_push_stream_broadcast(ngx_http_push_stream_channel_t *channel, ngx_http_push_stream_msg_t *msg, ngx_log_t *log);
static void ngx_http_push_stream_wildcard(ngx_http_push_stream_channel_t *channel, ngx_http_push_stream_msg_t *msg, ngx_log_t *log);
static ngx_int_t ngx_http_push_stream_alert_worker(ngx_pid_t pid, ngx_int_t slot, ngx_log_t *log, ngx_channel_t command);
#define ngx_http_push_stream_alert_worker_check_messages(pid, slot, log) ngx_http_push_stream_alert_worker(pid, slot, log, NGX_CMD_HTTP_PUSH_STREAM_CHECK_MESSAGES)
......
......@@ -49,7 +49,7 @@ static time_t NGX_HTTP_PUSH_STREAM_DEFAULT_CHANNEL_INACTIVITY_TIME = 30;
#define NGX_HTTP_PUSH_STREAM_DEFAULT_PADDING_BY_USER_AGENT "[A|a]ndroid 2,4097,4097:[S|s]afari,1025,0"
#define NGX_HTTP_PUSH_STREAM_DEFAULT_BROADCAST_CHANNEL_PREFIX ""
#define NGX_HTTP_PUSH_STREAM_DEFAULT_WILDCARD_CHANNEL_PREFIX ""
static char * ngx_http_push_stream_channels_statistics(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
......
......@@ -52,11 +52,11 @@ typedef struct {
#define NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_PLAIN_PATTERN "channel: %s" CRLF"published_messages: %ui" CRLF"stored_messages: %ui" CRLF"active_subscribers: %ui"
#define NGX_HTTP_PUSH_STREAM_WORKER_INFO_PLAIN_PATTERN " pid: %d" CRLF" subscribers: %ui" CRLF" uptime: %ui"
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_PLAIN = ngx_string(NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_PLAIN_PATTERN CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_HEAD_PLAIN = ngx_string("hostname: %s, time: %s, channels: %ui, broadcast_channels: %ui, uptime: %ui, infos: " CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_HEAD_PLAIN = ngx_string("hostname: %s, time: %s, channels: %ui, wildcard_channels: %ui, uptime: %ui, infos: " CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_TAIL_PLAIN = ngx_string(CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_ITEM_PLAIN = ngx_string(NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_PLAIN_PATTERN "," CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_LAST_ITEM_PLAIN = ngx_string(NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_PLAIN_PATTERN);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_PLAIN = ngx_string("hostname: %s" CRLF "time: %s" CRLF "channels: %ui" CRLF "broadcast_channels: %ui" CRLF "published_messages: %ui" CRLF "stored_messages: %ui" CRLF "messages_in_trash: %ui" CRLF "channels_in_trash: %ui" CRLF "subscribers: %ui" CRLF "uptime: %ui" CRLF "by_worker:"CRLF"%s" CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_PLAIN = ngx_string("hostname: %s" CRLF "time: %s" CRLF "channels: %ui" CRLF "wildcard_channels: %ui" CRLF "published_messages: %ui" CRLF "stored_messages: %ui" CRLF "messages_in_trash: %ui" CRLF "channels_in_trash: %ui" CRLF "subscribers: %ui" CRLF "uptime: %ui" CRLF "by_worker:"CRLF"%s" CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_WORKER_ITEM_PLAIN = ngx_string(NGX_HTTP_PUSH_STREAM_WORKER_INFO_PLAIN_PATTERN "," CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_WORKER_LAST_ITEM_PLAIN = ngx_string(NGX_HTTP_PUSH_STREAM_WORKER_INFO_PLAIN_PATTERN);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CONTENT_TYPE_PLAIN = ngx_string("text/plain");
......@@ -65,11 +65,11 @@ static ngx_str_t NGX_HTTP_PUSH_STREAM_CONTENT_TYPE_PLAIN = ngx_string("text/pla
#define NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_JSON_PATTERN "{\"channel\": \"%s\", \"published_messages\": \"%ui\", \"stored_messages\": \"%ui\", \"subscribers\": \"%ui\"}"
#define NGX_HTTP_PUSH_STREAM_WORKER_INFO_JSON_PATTERN "{\"pid\": \"%d\", \"subscribers\": \"%ui\", \"uptime\": \"%ui\"}"
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_JSON = ngx_string(NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_JSON_PATTERN CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_HEAD_JSON = ngx_string("{\"hostname\": \"%s\", \"time\": \"%s\", \"channels\": \"%ui\", \"broadcast_channels\": \"%ui\", \"uptime\": \"%ui\", \"infos\": [" CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_HEAD_JSON = ngx_string("{\"hostname\": \"%s\", \"time\": \"%s\", \"channels\": \"%ui\", \"wildcard_channels\": \"%ui\", \"uptime\": \"%ui\", \"infos\": [" CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_TAIL_JSON = ngx_string("]}" CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_ITEM_JSON = ngx_string(NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_JSON_PATTERN "," CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_LAST_ITEM_JSON = ngx_string(NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_JSON_PATTERN CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_JSON = ngx_string("{\"hostname\": \"%s\", \"time\": \"%s\", \"channels\": \"%ui\", \"broadcast_channels\": \"%ui\", \"published_messages\": \"%ui\", \"stored_messages\": \"%ui\", \"messages_in_trash\": \"%ui\", \"channels_in_trash\": \"%ui\", \"subscribers\": \"%ui\", \"uptime\": \"%ui\", \"by_worker\": [" CRLF "%s" CRLF"]}" CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_JSON = ngx_string("{\"hostname\": \"%s\", \"time\": \"%s\", \"channels\": \"%ui\", \"wildcard_channels\": \"%ui\", \"published_messages\": \"%ui\", \"stored_messages\": \"%ui\", \"messages_in_trash\": \"%ui\", \"channels_in_trash\": \"%ui\", \"subscribers\": \"%ui\", \"uptime\": \"%ui\", \"by_worker\": [" CRLF "%s" CRLF"]}" CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_WORKER_ITEM_JSON = ngx_string(NGX_HTTP_PUSH_STREAM_WORKER_INFO_JSON_PATTERN "," CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_WORKER_LAST_ITEM_JSON = ngx_string(NGX_HTTP_PUSH_STREAM_WORKER_INFO_JSON_PATTERN);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CONTENT_TYPE_JSON = ngx_string("application/json");
......@@ -78,11 +78,11 @@ static ngx_str_t NGX_HTTP_PUSH_STREAM_CONTENT_TYPE_X_JSON = ngx_string("text/x-
#define NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_YAML_PATTERN " channel: %s" CRLF" published_messages: %ui" CRLF" stored_messages: %ui" CRLF" subscribers: %ui"
#define NGX_HTTP_PUSH_STREAM_WORKER_INFO_YAML_PATTERN " pid: %d" CRLF" subscribers: %ui" CRLF" uptime: %ui"
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_YAML = ngx_string(NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_YAML_PATTERN CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_HEAD_YAML = ngx_string("hostname: %s" CRLF"time: %s" CRLF"channels: %ui" CRLF"broadcast_channels: %ui" CRLF"uptime: %ui" CRLF"infos: "CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_HEAD_YAML = ngx_string("hostname: %s" CRLF"time: %s" CRLF"channels: %ui" CRLF"wildcard_channels: %ui" CRLF"uptime: %ui" CRLF"infos: "CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_TAIL_YAML = ngx_string(CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_ITEM_YAML = ngx_string(" -" CRLF NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_YAML_PATTERN CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_LAST_ITEM_YAML = ngx_string(" -" CRLF NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_YAML_PATTERN);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_YAML = ngx_string(" hostname: %s" CRLF" time: %s" CRLF" channels: %ui" CRLF" broadcast_channels: %ui" CRLF" published_messages: %ui" CRLF" stored_messages: %ui" CRLF" messages_in_trash: %ui" CRLF" channels_in_trash: %ui" CRLF" subscribers: %ui" CRLF" uptime: %ui" CRLF" by_worker:"CRLF"%s" CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_YAML = ngx_string(" hostname: %s" CRLF" time: %s" CRLF" channels: %ui" CRLF" wildcard_channels: %ui" CRLF" published_messages: %ui" CRLF" stored_messages: %ui" CRLF" messages_in_trash: %ui" CRLF" channels_in_trash: %ui" CRLF" subscribers: %ui" CRLF" uptime: %ui" CRLF" by_worker:"CRLF"%s" CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_WORKER_ITEM_YAML = ngx_string(" -" CRLF NGX_HTTP_PUSH_STREAM_WORKER_INFO_YAML_PATTERN CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_WORKER_LAST_ITEM_YAML = ngx_string(" -" CRLF NGX_HTTP_PUSH_STREAM_WORKER_INFO_YAML_PATTERN);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CONTENT_TYPE_YAML = ngx_string("application/yaml");
......@@ -103,7 +103,7 @@ static ngx_str_t NGX_HTTP_PUSH_STREAM_CONTENT_TYPE_X_YAML = ngx_string("text/x-
" <uptime>%ui</uptime>" CRLF \
"</worker>" CRLF
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_XML = ngx_string("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" CRLF NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_XML_PATTERN CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_HEAD_XML = ngx_string("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" CRLF "<root>" CRLF" <hostname>%s</hostname>" CRLF" <time>%s</time>" CRLF" <channels>%ui</channels>" CRLF" <broadcast_channels>%ui</broadcast_channels>" CRLF" <uptime>%ui</uptime>" CRLF" <infos>" CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_HEAD_XML = ngx_string("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" CRLF "<root>" CRLF" <hostname>%s</hostname>" CRLF" <time>%s</time>" CRLF" <channels>%ui</channels>" CRLF" <wildcard_channels>%ui</wildcard_channels>" CRLF" <uptime>%ui</uptime>" CRLF" <infos>" CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_TAIL_XML = ngx_string(" </infos>" CRLF"</root>" CRLF);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_ITEM_XML = ngx_string(NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_XML_PATTERN);
static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_GROUP_LAST_ITEM_XML = ngx_string(NGX_HTTP_PUSH_STREAM_CHANNEL_INFO_XML_PATTERN);
......@@ -113,7 +113,7 @@ static ngx_str_t NGX_HTTP_PUSH_STREAM_CHANNELS_INFO_SUMMARIZED_XML = ngx_string
" <hostname>%s</hostname>" CRLF \
" <time>%s</time>" CRLF \
" <channels>%ui</channels>" CRLF \
" <broadcast_channels>%ui</broadcast_channels>" CRLF \
" <wildcard_channels>%ui</wildcard_channels>" CRLF \
" <published_messages>%ui</published_messages>" CRLF \
" <stored_messages>%ui</stored_messages>" CRLF \
" <messages_in_trash>%ui</messages_in_trash>" CRLF \
......
......@@ -46,8 +46,8 @@ http {
push_stream_subscriber_connection_ttl 15m;
# connection ttl for long polling
push_stream_longpolling_connection_ttl 30s;
# broadcast
push_stream_broadcast_channel_prefix "broad_";
# wildcard
push_stream_wildcard_channel_prefix "broad_";
#push_stream_message_template "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":\"~text~\",\"eventid\":\"~event-id~\"}";
push_stream_message_template "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":\"~text~\"}";
......@@ -55,7 +55,7 @@ http {
# subscriber may create channels on demand or only authorized
# (publisher) may do it?
push_stream_authorized_channels_only off;
push_stream_broadcast_channel_max_qtd 3;
push_stream_wildcard_channel_max_qtd 3;
server {
......
......@@ -121,11 +121,11 @@ shared_examples_for "statistics location" do
end
end
it "should return detailed channels statistics for an existent broadcast channel" do
channel = 'bd_test_get_detailed_channels_statistics_to_existing_broadcast_channel'
it "should return detailed channels statistics for an existent wildcard channel" do
channel = 'bd_test_get_detailed_channels_statistics_to_existing_wildcard_channel'
body = 'body'
nginx_run_server(config.merge(:broadcast_channel_prefix => 'bd_', :broadcast_channel_max_qtd => 1)) do |conf|
nginx_run_server(config.merge(:wildcard_channel_prefix => 'bd_', :wildcard_channel_max_qtd => 1)) do |conf|
#create channel
publish_message(channel, headers, body)
......@@ -136,7 +136,7 @@ shared_examples_for "statistics location" do
response = JSON.parse(pub_2.response)
response["infos"].length.should eql(1)
response["channels"].to_i.should eql(0)
response["broadcast_channels"].to_i.should eql(1)
response["wildcard_channels"].to_i.should eql(1)
response["infos"][0]["channel"].to_s.should eql(channel)
response["infos"][0]["published_messages"].to_i.should eql(1)
response["infos"][0]["stored_messages"].to_i.should eql(1)
......@@ -216,11 +216,11 @@ shared_examples_for "statistics location" do
end
end
it "should return summarized channels statistics for an existent broadcast channel" do
channel = 'bd_test_get_summarized_channels_statistics_to_existing_broadcast_channel'
it "should return summarized channels statistics for an existent wildcard channel" do
channel = 'bd_test_get_summarized_channels_statistics_to_existing_wildcard_channel'
body = 'body'
nginx_run_server(config.merge(:broadcast_channel_prefix => 'bd_', :broadcast_channel_max_qtd => 1)) do |conf|
nginx_run_server(config.merge(:wildcard_channel_prefix => 'bd_', :wildcard_channel_max_qtd => 1)) do |conf|
#create channel
publish_message(channel, headers, body)
......@@ -231,7 +231,7 @@ shared_examples_for "statistics location" do
response = JSON.parse(pub_2.response)
response.has_key?("channels").should be_true
response["channels"].to_i.should eql(0)
response["broadcast_channels"].to_i.should eql(1)
response["wildcard_channels"].to_i.should eql(1)
response["published_messages"].to_i.should eql(1)
response["subscribers"].to_i.should eql(0)
EventMachine.stop
......@@ -449,11 +449,11 @@ shared_examples_for "statistics location" do
end
end
it "should return detailed channels statistics for an existent broadcast channel using prefix id" do
channel = 'bd_test_get_detailed_channels_statistics_to_existing_broadcast_channel_using_prefix'
it "should return detailed channels statistics for an existent wildcard channel using prefix id" do
channel = 'bd_test_get_detailed_channels_statistics_to_existing_wildcard_channel_using_prefix'
body = 'body'
nginx_run_server(config.merge(:broadcast_channel_prefix => 'bd_', :broadcast_channel_max_qtd => 1)) do |conf|
nginx_run_server(config.merge(:wildcard_channel_prefix => 'bd_', :wildcard_channel_max_qtd => 1)) do |conf|
#create channels
publish_message(channel, headers, body)
......@@ -464,7 +464,7 @@ shared_examples_for "statistics location" do
response = JSON.parse(pub_2.response)
response["infos"].length.should eql(1)
response["channels"].to_i.should eql(0)
response["broadcast_channels"].to_i.should eql(1)
response["wildcard_channels"].to_i.should eql(1)
response["infos"][0]["channel"].to_s.should eql(channel)
response["infos"][0]["published_messages"].to_i.should eql(1)
response["infos"][0]["stored_messages"].to_i.should eql(1)
......@@ -540,7 +540,7 @@ shared_examples_for "statistics location" do
response["hostname"].to_s.should_not be_empty
response["time"].to_s.should_not be_empty
response["channels"].to_s.should_not be_empty
response["broadcast_channels"].to_s.should_not be_empty
response["wildcard_channels"].to_s.should_not be_empty
response["uptime"].to_s.should_not be_empty
response["infos"].to_s.should_not be_empty
......@@ -573,7 +573,7 @@ shared_examples_for "statistics location" do
response["hostname"].to_s.should_not be_empty
response["time"].to_s.should_not be_empty
response["channels"].to_s.should_not be_empty
response["broadcast_channels"].to_s.should_not be_empty
response["wildcard_channels"].to_s.should_not be_empty
response["subscribers"].to_s.should_not be_empty
response["uptime"].to_s.should_not be_empty
response["by_worker"].to_s.should_not be_empty
......@@ -629,7 +629,7 @@ shared_examples_for "statistics location" do
channel = 'ch_test_get_channels_in_trash_in_summarized_channels_statistics'
body = 'body'
nginx_run_server(config.merge(:publisher_mode => 'admin', :broadcast_channel_prefix => 'bd_', :broadcast_channel_max_qtd => 1), :timeout => 55) do |conf|
nginx_run_server(config.merge(:publisher_mode => 'admin', :wildcard_channel_prefix => 'bd_', :wildcard_channel_max_qtd => 1), :timeout => 55) do |conf|
#create channel
publish_message(channel, headers, body)
publish_message("#{channel}_1", headers, body)
......@@ -641,7 +641,7 @@ shared_examples_for "statistics location" do
pub_2.should be_http_status(200)
response = JSON.parse(pub_2.response)
response["channels"].to_i.should eql(2)
response["broadcast_channels"].to_i.should eql(1)
response["wildcard_channels"].to_i.should eql(1)
response["channels_in_trash"].to_i.should eql(0)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
......@@ -655,7 +655,7 @@ shared_examples_for "statistics location" do
pub_3.should be_http_status(200)
response = JSON.parse(pub_3.response)
response["channels"].to_i.should eql(1)
response["broadcast_channels"].to_i.should eql(1)
response["wildcard_channels"].to_i.should eql(1)
response["channels_in_trash"].to_i.should eql(1)
EventMachine.stop
end
......
......@@ -44,7 +44,7 @@ describe "Keepalive" do
headers, body = get_in_socket("/channels-stats", socket)
body.should match_the_pattern(/"channels": "1", "broadcast_channels": "0", "published_messages": "1", "stored_messages": "1", "messages_in_trash": "0", "channels_in_trash": "0", "subscribers": "0", "uptime": "[0-9]*", "by_worker": \[\r\n/)
body.should match_the_pattern(/"channels": "1", "wildcard_channels": "0", "published_messages": "1", "stored_messages": "1", "messages_in_trash": "0", "channels_in_trash": "0", "subscribers": "0", "uptime": "[0-9]*", "by_worker": \[\r\n/)
body.should match_the_pattern(/\{"pid": "[0-9]*", "subscribers": "0", "uptime": "[0-9]*"\}/)
headers, body = get_in_socket("/pub?id=#{channel}", socket)
......
......@@ -37,21 +37,21 @@ describe "Setup Parameters" do
nginx_test_configuration({:max_number_of_channels => 0}).should include("push_stream_max_number_of_channels cannot be zero")
end
it "should not accept '0' as max number of broadcast channels" do
nginx_test_configuration({:max_number_of_broadcast_channels => 0}).should include("push_stream_max_number_of_broadcast_channels cannot be zero")
it "should not accept '0' as max number of wildcard channels" do
nginx_test_configuration({:max_number_of_wildcard_channels => 0}).should include("push_stream_max_number_of_wildcard_channels cannot be zero")
end
it "should not accept '0' as max broadcast channels" do
nginx_test_configuration({:broadcast_channel_max_qtd => 0}).should include("push_stream_broadcast_channel_max_qtd cannot be zero")
it "should not accept '0' as max wildcard channels" do
nginx_test_configuration({:wildcard_channel_max_qtd => 0}).should include("push_stream_wildcard_channel_max_qtd cannot be zero")
end
it "should not set max broadcast channels without set boadcast channel prefix" do
nginx_test_configuration({:broadcast_channel_max_qtd => 1, :broadcast_channel_prefix => ""}).should include("cannot set broadcast channel max qtd if push_stream_broadcast_channel_prefix is not set or blank")
it "should not set max wildcard channels without set boadcast channel prefix" do
nginx_test_configuration({:wildcard_channel_max_qtd => 1, :wildcard_channel_prefix => ""}).should include("cannot set wildcard channel max qtd if push_stream_wildcard_channel_prefix is not set or blank")
end
it "should not accept '0' as max number of broadcast channels" do
config = {:max_number_of_broadcast_channels => 3, :broadcast_channel_max_qtd => 4, :broadcast_channel_prefix => "broad_"}
nginx_test_configuration(config).should include("max number of broadcast channels cannot be smaller than value in push_stream_broadcast_channel_max_qtd")
it "should not accept '0' as max number of wildcard channels" do
config = {:max_number_of_wildcard_channels => 3, :wildcard_channel_max_qtd => 4, :wildcard_channel_prefix => "broad_"}
nginx_test_configuration(config).should include("max number of wildcard channels cannot be smaller than value in push_stream_wildcard_channel_max_qtd")
end
it "should accept a configuration without http block" do
......
require 'spec_helper'
describe "Broadcast Properties" do
describe "Wildcard Properties" do
let(:config) do
{
:authorized_channels_only => "on",
:header_template => 'connected',
:broadcast_channel_prefix => "XXX_"
:wildcard_channel_prefix => "XXX_"
}
end
it "should identify broadcast channels by prefix" do
channel = 'ch_test_broadcast_channel_prefix'
it "should identify wildcard channels by prefix" do
channel = 'ch_test_wildcard_channel_prefix'
channel_broad = 'XXX_123'
channel_broad_fail = 'YYY_123'
body = 'broadcast channel prefix'
body = 'wildcard channel prefix'
nginx_run_server(config) do |conf|
EventMachine.run do
......@@ -35,14 +35,14 @@ describe "Broadcast Properties" do
end
end
it "should limit the number of broadcast channels in the same request" do
channel = 'ch_test_broadcast_channel_max_qtd'
it "should limit the number of wildcard channels in the same request" do
channel = 'ch_test_wildcard_channel_max_qtd'
channel_broad1 = 'XXX_123'
channel_broad2 = 'XXX_321'
channel_broad3 = 'XXX_213'
body = 'broadcast channel prefix'
body = 'wildcard channel prefix'
nginx_run_server(config.merge(:broadcast_channel_max_qtd => 2)) do |conf|
nginx_run_server(config.merge(:wildcard_channel_max_qtd => 2)) do |conf|
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub.callback do
......
......@@ -25,10 +25,10 @@ module NginxConfiguration
:max_subscribers_per_channel => nil,
:max_messages_stored_per_channel => 20,
:max_number_of_channels => nil,
:max_number_of_broadcast_channels => nil,
:max_number_of_wildcard_channels => nil,
:broadcast_channel_max_qtd => 3,
:broadcast_channel_prefix => 'broad_',
:wildcard_channel_max_qtd => 3,
:wildcard_channel_prefix => 'broad_',
:subscriber_mode => nil,
:publisher_mode => nil,
......@@ -119,10 +119,10 @@ http {
<%= write_directive("push_stream_max_subscribers_per_channel", max_subscribers_per_channel, "max subscribers per channel") %>
<%= write_directive("push_stream_max_messages_stored_per_channel", max_messages_stored_per_channel, "max messages to store in memory") %>
<%= write_directive("push_stream_max_number_of_channels", max_number_of_channels) %>
<%= write_directive("push_stream_max_number_of_broadcast_channels", max_number_of_broadcast_channels) %>
<%= write_directive("push_stream_max_number_of_wildcard_channels", max_number_of_wildcard_channels) %>
<%= write_directive("push_stream_broadcast_channel_max_qtd", broadcast_channel_max_qtd) %>
<%= write_directive("push_stream_broadcast_channel_prefix", broadcast_channel_prefix) %>
<%= write_directive("push_stream_wildcard_channel_max_qtd", wildcard_channel_max_qtd) %>
<%= write_directive("push_stream_wildcard_channel_prefix", wildcard_channel_prefix) %>
<%= write_directive("push_stream_padding_by_user_agent", padding_by_user_agent) %>
......
......@@ -316,11 +316,11 @@ describe "Publisher Properties" do
end
end
it "should limit the number of broadcast channels" do
it "should limit the number of wildcard channels" do
body = 'published message'
channel = 'bd_test_max_number_of_broadcast_channels_'
channel = 'bd_test_max_number_of_wildcard_channels_'
nginx_run_server(config.merge(:max_number_of_broadcast_channels => 1, :broadcast_channel_prefix => 'bd_', :broadcast_channel_max_qtd => 1)) do |conf|
nginx_run_server(config.merge(:max_number_of_wildcard_channels => 1, :wildcard_channel_prefix => 'bd_', :wildcard_channel_max_qtd => 1)) do |conf|
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s + 1.to_s).post :head => headers, :body => body
pub.callback do
......
......@@ -150,12 +150,12 @@ describe "Subscriber Properties" do
end
end
it "should not accept access to a broadcast channel without a normal channel" do
nginx_run_server(config.merge(:broadcast_channel_prefix => "bd_")) do |conf|
it "should not accept access to a wildcard channel without a normal channel" do
nginx_run_server(config.merge(:wildcard_channel_prefix => "bd_")) do |conf|
EventMachine.run do
multi = EventMachine::MultiRequest.new
multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/sub/bd_test_broadcast_channels_without_common_channel').get)
multi.add(:a, EventMachine::HttpRequest.new(nginx_address + '/sub/bd_test_wildcard_channels_without_common_channel').get)
multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/sub/bd_').get)
multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/sub/bd1').get)
multi.add(:d, EventMachine::HttpRequest.new(nginx_address + '/sub/bd').get)
......@@ -164,11 +164,11 @@ describe "Subscriber Properties" do
multi.responses[:callback].length.should eql(4)
multi.responses[:callback][:a].should be_http_status(403).without_body
multi.responses[:callback][:a].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribed too much broadcast channels.")
multi.responses[:callback][:a].req.uri.to_s.should eql(nginx_address + '/sub/bd_test_broadcast_channels_without_common_channel')
multi.responses[:callback][:a].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribed too much wildcard channels.")
multi.responses[:callback][:a].req.uri.to_s.should eql(nginx_address + '/sub/bd_test_wildcard_channels_without_common_channel')
multi.responses[:callback][:b].should be_http_status(403).without_body
multi.responses[:callback][:b].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribed too much broadcast channels.")
multi.responses[:callback][:b].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribed too much wildcard channels.")
multi.responses[:callback][:b].req.uri.to_s.should eql(nginx_address + '/sub/bd_')
multi.responses[:callback][:c].should be_http_status(200)
......@@ -183,8 +183,8 @@ describe "Subscriber Properties" do
end
end
it "should accept access to a broadcast channel with a normal channel" do
nginx_run_server(config.merge(:broadcast_channel_prefix => "bd_", :broadcast_channel_max_qtd => 2, :authorized_channels_only => "off")) do |conf|
it "should accept access to a wildcard channel with a normal channel" do
nginx_run_server(config.merge(:wildcard_channel_prefix => "bd_", :wildcard_channel_max_qtd => 2, :authorized_channels_only => "off")) do |conf|
EventMachine.run do
multi = EventMachine::MultiRequest.new
......@@ -197,7 +197,7 @@ describe "Subscriber Properties" do
multi.responses[:callback].length.should eql(4)
multi.responses[:callback][:a].should be_http_status(403).without_body
multi.responses[:callback][:a].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribed too much broadcast channels.")
multi.responses[:callback][:a].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribed too much wildcard channels.")
multi.responses[:callback][:a].req.uri.to_s.should eql(nginx_address + '/sub/bd1/bd2/bd3/bd4/bd_1/bd_2/bd_3')
multi.responses[:callback][:b].should be_http_status(200)
......@@ -248,18 +248,18 @@ describe "Subscriber Properties" do
end
end
it "should accept access to an existing channel and a nonexistent broadcast channel with authorized only 'on'" do
channel = 'ch_test_subscribe_an_existing_channel_and_absent_broadcast_channel_with_authorized_only_on'
broadcast_channel = 'bd_test_subscribe_an_existing_channel_and_absent_broadcast_channel_with_authorized_only_on'
it "should accept access to an existing channel and a nonexistent wildcard channel with authorized only 'on'" do
channel = 'ch_test_subscribe_an_existing_channel_and_absent_wildcard_channel_with_authorized_only_on'
wildcard_channel = 'bd_test_subscribe_an_existing_channel_and_absent_wildcard_channel_with_authorized_only_on'
body = 'body'
nginx_run_server(config.merge(:authorized_channels_only => 'on', :broadcast_channel_prefix => "bd_", :broadcast_channel_max_qtd => 1)) do |conf|
nginx_run_server(config.merge(:authorized_channels_only => 'on', :wildcard_channel_prefix => "bd_", :wildcard_channel_max_qtd => 1)) do |conf|
#create channel
publish_message(channel, headers, body)
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + broadcast_channel.to_s).get :head => headers
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + wildcard_channel.to_s).get :head => headers
sub_1.callback do
sub_1.should be_http_status(200)
EventMachine.stop
......@@ -289,19 +289,19 @@ describe "Subscriber Properties" do
end
end
it "should not accept access to an existing channel without messages and an nonexistent broadcast channel with authorized only 'on'" do
channel = 'ch_test_subscribe_an_existing_channel_without_messages_and_absent_broadcast_channel_and_with_authorized_only_on_should_fail'
broadcast_channel = 'bd_test_subscribe_an_existing_channel_without_messages_and_absent_broadcast_channel_and_with_authorized_only_on_should_fail'
it "should not accept access to an existing channel without messages and an nonexistent wildcard channel with authorized only 'on'" do
channel = 'ch_test_subscribe_an_existing_channel_without_messages_and_absent_wildcard_channel_and_with_authorized_only_on_should_fail'
wildcard_channel = 'bd_test_subscribe_an_existing_channel_without_messages_and_absent_wildcard_channel_and_with_authorized_only_on_should_fail'
body = 'body'
nginx_run_server(config.merge(:authorized_channels_only => 'on', :message_ttl => "1s", :broadcast_channel_prefix => "bd_", :broadcast_channel_max_qtd => 1), :timeout => 10) do |conf|
nginx_run_server(config.merge(:authorized_channels_only => 'on', :message_ttl => "1s", :wildcard_channel_prefix => "bd_", :wildcard_channel_max_qtd => 1), :timeout => 10) do |conf|
#create channel
publish_message(channel, headers, body)
sleep(5) #to ensure message was gone
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + broadcast_channel.to_s).get :head => headers
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + wildcard_channel.to_s).get :head => headers
sub_1.callback do
sub_1.should be_http_status(403).without_body
sub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscriber could not create channels.")
......@@ -582,10 +582,10 @@ describe "Subscriber Properties" do
end
end
it "should limit the number of broadcast channels" do
channel = 'bd_test_max_number_of_broadcast_channels_'
it "should limit the number of wildcard channels" do
channel = 'bd_test_max_number_of_wildcard_channels_'
nginx_run_server(config.merge(:max_number_of_broadcast_channels => 1, :broadcast_channel_prefix => 'bd_', :broadcast_channel_max_qtd => 1)) do |conf|
nginx_run_server(config.merge(:max_number_of_wildcard_channels => 1, :wildcard_channel_prefix => 'bd_', :wildcard_channel_max_qtd => 1)) do |conf|
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/ch1/' + channel.to_s + 1.to_s).get :head => headers
sub_1.stream do
......
......@@ -147,7 +147,7 @@ ngx_http_push_stream_send_response_all_channels_info_summarized(ngx_http_request
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
ngx_sprintf(text->data, (char *) subtype->format_summarized->data, hostname->data, currenttime->data, data->channels, data->broadcast_channels, data->published_messages, data->stored_messages, data->messages_in_trash, data->channels_in_trash, data->subscribers, ngx_time() - data->startup, subscribers_by_workers);
ngx_sprintf(text->data, (char *) subtype->format_summarized->data, hostname->data, currenttime->data, data->channels, data->wildcard_channels, data->published_messages, data->stored_messages, data->messages_in_trash, data->channels_in_trash, data->subscribers, ngx_time() - data->startup, subscribers_by_workers);
text->len = ngx_strlen(text->data);
return ngx_http_push_stream_send_response(r, text, subtype->content_type, NGX_HTTP_OK);
......@@ -258,7 +258,7 @@ ngx_http_push_stream_send_response_all_channels_info_detailed(ngx_http_request_t
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
ngx_sprintf(header_response->data, (char *) head->data, hostname->data, currenttime->data, data->channels, data->broadcast_channels, ngx_time() - data->startup);
ngx_sprintf(header_response->data, (char *) head->data, hostname->data, currenttime->data, data->channels, data->wildcard_channels, ngx_time() - data->startup);
header_response->len = ngx_strlen(header_response->data);
content_len += header_response->len + tail->len;
......
......@@ -357,7 +357,7 @@ ngx_http_push_stream_send_worker_message_locked(ngx_http_push_stream_channel_t *
static void
ngx_http_push_stream_broadcast(ngx_http_push_stream_channel_t *channel, ngx_http_push_stream_msg_t *msg, ngx_log_t *log)
ngx_http_push_stream_wildcard(ngx_http_push_stream_channel_t *channel, ngx_http_push_stream_msg_t *msg, ngx_log_t *log)
{
// subscribers are queued up in a local pool. Queue heads, however, are located
// in shared memory, identified by pid.
......
......@@ -42,13 +42,13 @@ ngx_http_push_stream_publisher_handler(ngx_http_request_t *r)
ngx_http_push_stream_add_response_header(r, &NGX_HTTP_PUSH_STREAM_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, &cf->allowed_origins);
}
// only accept GET, POST and DELETE methods if enable publisher administration
// only accept GET, POST, PUT and DELETE methods if enable publisher administration
if ((cf->location_type == NGX_HTTP_PUSH_STREAM_PUBLISHER_MODE_ADMIN) && !(r->method & (NGX_HTTP_GET|NGX_HTTP_POST|NGX_HTTP_PUT|NGX_HTTP_DELETE))) {
ngx_http_push_stream_add_response_header(r, &NGX_HTTP_PUSH_STREAM_HEADER_ALLOW, &NGX_HTTP_PUSH_STREAM_ALLOW_GET_POST_PUT_DELETE_METHODS);
return ngx_http_push_stream_send_only_header_response(r, NGX_HTTP_NOT_ALLOWED, NULL);
}
// only accept GET and POST methods if NOT enable publisher administration
// only accept GET, POST and PUT methods if NOT enable publisher administration
if ((cf->location_type != NGX_HTTP_PUSH_STREAM_PUBLISHER_MODE_ADMIN) && !(r->method & (NGX_HTTP_GET|NGX_HTTP_POST|NGX_HTTP_PUT))) {
ngx_http_push_stream_add_response_header(r, &NGX_HTTP_PUSH_STREAM_HEADER_ALLOW, &NGX_HTTP_PUSH_STREAM_ALLOW_GET_POST_PUT_METHODS);
return ngx_http_push_stream_send_only_header_response(r, NGX_HTTP_NOT_ALLOWED, NULL);
......
......@@ -102,17 +102,17 @@ static ngx_command_t ngx_http_push_stream_commands[] = {
NGX_HTTP_MAIN_CONF_OFFSET,
offsetof(ngx_http_push_stream_main_conf_t, max_number_of_channels),
NULL },
{ ngx_string("push_stream_max_number_of_broadcast_channels"),
{ ngx_string("push_stream_max_number_of_wildcard_channels"),
NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
NGX_HTTP_MAIN_CONF_OFFSET,
offsetof(ngx_http_push_stream_main_conf_t, max_number_of_broadcast_channels),
offsetof(ngx_http_push_stream_main_conf_t, max_number_of_wildcard_channels),
NULL },
{ ngx_string("push_stream_broadcast_channel_prefix"),
{ ngx_string("push_stream_wildcard_channel_prefix"),
NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
ngx_conf_set_str_slot,
NGX_HTTP_MAIN_CONF_OFFSET,
offsetof(ngx_http_push_stream_main_conf_t, broadcast_channel_prefix),
offsetof(ngx_http_push_stream_main_conf_t, wildcard_channel_prefix),
NULL },
/* Location directives */
......@@ -164,11 +164,11 @@ static ngx_command_t ngx_http_push_stream_commands[] = {
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_push_stream_loc_conf_t, footer_template),
NULL },
{ ngx_string("push_stream_broadcast_channel_max_qtd"),
{ ngx_string("push_stream_wildcard_channel_max_qtd"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_push_stream_loc_conf_t, broadcast_channel_max_qtd),
offsetof(ngx_http_push_stream_loc_conf_t, wildcard_channel_max_qtd),
NULL },
{ ngx_string("push_stream_ping_message_interval"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
......@@ -402,9 +402,9 @@ ngx_http_push_stream_create_main_conf(ngx_conf_t *cf)
mcf->channel_deleted_message_text.data = NULL;
mcf->channel_inactivity_time = NGX_CONF_UNSET;
mcf->ping_message_text.data = NULL;
mcf->broadcast_channel_prefix.data = NULL;
mcf->wildcard_channel_prefix.data = NULL;
mcf->max_number_of_channels = NGX_CONF_UNSET_UINT;
mcf->max_number_of_broadcast_channels = NGX_CONF_UNSET_UINT;
mcf->max_number_of_wildcard_channels = NGX_CONF_UNSET_UINT;
mcf->message_ttl = NGX_CONF_UNSET;
mcf->max_channel_id_length = NGX_CONF_UNSET_UINT;
mcf->max_subscribers_per_channel = NGX_CONF_UNSET;
......@@ -432,7 +432,7 @@ ngx_http_push_stream_init_main_conf(ngx_conf_t *cf, void *parent)
ngx_conf_init_value(conf->channel_inactivity_time, NGX_HTTP_PUSH_STREAM_DEFAULT_CHANNEL_INACTIVITY_TIME);
ngx_conf_merge_str_value(conf->channel_deleted_message_text, conf->channel_deleted_message_text, NGX_HTTP_PUSH_STREAM_CHANNEL_DELETED_MESSAGE_TEXT);
ngx_conf_merge_str_value(conf->ping_message_text, conf->ping_message_text, NGX_HTTP_PUSH_STREAM_PING_MESSAGE_TEXT);
ngx_conf_merge_str_value(conf->broadcast_channel_prefix, conf->broadcast_channel_prefix, NGX_HTTP_PUSH_STREAM_DEFAULT_BROADCAST_CHANNEL_PREFIX);
ngx_conf_merge_str_value(conf->wildcard_channel_prefix, conf->wildcard_channel_prefix, NGX_HTTP_PUSH_STREAM_DEFAULT_WILDCARD_CHANNEL_PREFIX);
// sanity checks
// max number of channels cannot be zero
......@@ -441,9 +441,9 @@ ngx_http_push_stream_init_main_conf(ngx_conf_t *cf, void *parent)
return NGX_CONF_ERROR;
}
// max number of broadcast channels cannot be zero
if ((conf->max_number_of_broadcast_channels != NGX_CONF_UNSET_UINT) && (conf->max_number_of_broadcast_channels == 0)) {
ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "push_stream_max_number_of_broadcast_channels cannot be zero.");
// max number of wildcard channels cannot be zero
if ((conf->max_number_of_wildcard_channels != NGX_CONF_UNSET_UINT) && (conf->max_number_of_wildcard_channels == 0)) {
ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "push_stream_max_number_of_wildcard_channels cannot be zero.");
return NGX_CONF_ERROR;
}
......@@ -513,7 +513,7 @@ ngx_http_push_stream_create_loc_conf(ngx_conf_t *cf)
lcf->message_template.data = NULL;
lcf->header_template.data = NULL;
lcf->footer_template.data = NULL;
lcf->broadcast_channel_max_qtd = NGX_CONF_UNSET_UINT;
lcf->wildcard_channel_max_qtd = NGX_CONF_UNSET_UINT;
lcf->location_type = NGX_CONF_UNSET_UINT;
lcf->ping_message_interval = NGX_CONF_UNSET_MSEC;
lcf->subscriber_connection_ttl = NGX_CONF_UNSET_MSEC;
......@@ -541,7 +541,7 @@ ngx_http_push_stream_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_str_value(conf->header_template, prev->header_template, NGX_HTTP_PUSH_STREAM_DEFAULT_HEADER_TEMPLATE);
ngx_conf_merge_str_value(conf->message_template, prev->message_template, NGX_HTTP_PUSH_STREAM_DEFAULT_MESSAGE_TEMPLATE);
ngx_conf_merge_str_value(conf->footer_template, prev->footer_template, NGX_HTTP_PUSH_STREAM_DEFAULT_FOOTER_TEMPLATE);
ngx_conf_merge_uint_value(conf->broadcast_channel_max_qtd, prev->broadcast_channel_max_qtd, ngx_http_push_stream_module_main_conf->max_number_of_broadcast_channels);
ngx_conf_merge_uint_value(conf->wildcard_channel_max_qtd, prev->wildcard_channel_max_qtd, ngx_http_push_stream_module_main_conf->max_number_of_wildcard_channels);
ngx_conf_merge_msec_value(conf->ping_message_interval, prev->ping_message_interval, NGX_CONF_UNSET_MSEC);
ngx_conf_merge_msec_value(conf->subscriber_connection_ttl, prev->subscriber_connection_ttl, NGX_CONF_UNSET_MSEC);
ngx_conf_merge_msec_value(conf->longpolling_connection_ttl, prev->longpolling_connection_ttl, conf->subscriber_connection_ttl);
......@@ -659,21 +659,21 @@ ngx_http_push_stream_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
return NGX_CONF_ERROR;
}
// broadcast channel max qtd cannot be zero
if ((conf->broadcast_channel_max_qtd != NGX_CONF_UNSET_UINT) && (conf->broadcast_channel_max_qtd == 0)) {
ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "push_stream_broadcast_channel_max_qtd cannot be zero.");
// wildcard channel max qtd cannot be zero
if ((conf->wildcard_channel_max_qtd != NGX_CONF_UNSET_UINT) && (conf->wildcard_channel_max_qtd == 0)) {
ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "push_stream_wildcard_channel_max_qtd cannot be zero.");
return NGX_CONF_ERROR;
}
// broadcast channel max qtd cannot be set without a channel prefix
if ((conf->broadcast_channel_max_qtd != NGX_CONF_UNSET_UINT) && (conf->broadcast_channel_max_qtd > 0) && (ngx_http_push_stream_module_main_conf->broadcast_channel_prefix.len == 0)) {
ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "cannot set broadcast channel max qtd if push_stream_broadcast_channel_prefix is not set or blank.");
// wildcard channel max qtd cannot be set without a channel prefix
if ((conf->wildcard_channel_max_qtd != NGX_CONF_UNSET_UINT) && (conf->wildcard_channel_max_qtd > 0) && (ngx_http_push_stream_module_main_conf->wildcard_channel_prefix.len == 0)) {
ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "cannot set wildcard channel max qtd if push_stream_wildcard_channel_prefix is not set or blank.");
return NGX_CONF_ERROR;
}
// max number of broadcast channels cannot be smaller than value in broadcast channel max qtd
if ((ngx_http_push_stream_module_main_conf->max_number_of_broadcast_channels != NGX_CONF_UNSET_UINT) && (conf->broadcast_channel_max_qtd != NGX_CONF_UNSET_UINT) && (ngx_http_push_stream_module_main_conf->max_number_of_broadcast_channels < conf->broadcast_channel_max_qtd)) {
ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "max number of broadcast channels cannot be smaller than value in push_stream_broadcast_channel_max_qtd.");
// max number of wildcard channels cannot be smaller than value in wildcard channel max qtd
if ((ngx_http_push_stream_module_main_conf->max_number_of_wildcard_channels != NGX_CONF_UNSET_UINT) && (conf->wildcard_channel_max_qtd != NGX_CONF_UNSET_UINT) && (ngx_http_push_stream_module_main_conf->max_number_of_wildcard_channels < conf->wildcard_channel_max_qtd)) {
ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "max number of wildcard channels cannot be smaller than value in push_stream_wildcard_channel_max_qtd.");
return NGX_CONF_ERROR;
}
......@@ -877,7 +877,7 @@ ngx_http_push_stream_init_shm_zone(ngx_shm_zone_t *shm_zone, void *data)
}
d->channels = 0;
d->broadcast_channels = 0;
d->wildcard_channels = 0;
d->published_messages = 0;
d->stored_messages = 0;
d->subscribers = 0;
......
......@@ -387,8 +387,8 @@ ngx_http_push_stream_validate_channels(ngx_http_request_t *r, ngx_http_push_stre
ngx_http_push_stream_loc_conf_t *cf = ngx_http_get_module_loc_conf(r, ngx_http_push_stream_module);
ngx_http_push_stream_requested_channel_t *cur = channels_ids;
ngx_uint_t subscribed_channels_qtd = 0;
ngx_uint_t subscribed_broadcast_channels_qtd = 0;
ngx_flag_t is_broadcast_channel;
ngx_uint_t subscribed_wildcard_channels_qtd = 0;
ngx_flag_t is_wildcard_channel;
ngx_http_push_stream_channel_t *channel;
while ((cur = (ngx_http_push_stream_requested_channel_t *) ngx_queue_next(&cur->queue)) != channels_ids) {
......@@ -407,16 +407,16 @@ ngx_http_push_stream_validate_channels(ngx_http_request_t *r, ngx_http_push_stre
return NGX_ERROR;
}
// count subscribed channel and broadcasts
// count subscribed normal and wildcard channels
subscribed_channels_qtd++;
is_broadcast_channel = 0;
if ((mcf->broadcast_channel_prefix.len > 0) && (ngx_strncmp(cur->id->data, mcf->broadcast_channel_prefix.data, mcf->broadcast_channel_prefix.len) == 0)) {
is_broadcast_channel = 1;
subscribed_broadcast_channels_qtd++;
is_wildcard_channel = 0;
if ((mcf->wildcard_channel_prefix.len > 0) && (ngx_strncmp(cur->id->data, mcf->wildcard_channel_prefix.data, mcf->wildcard_channel_prefix.len) == 0)) {
is_wildcard_channel = 1;
subscribed_wildcard_channels_qtd++;
}
// check if channel exists when authorized_channels_only is on
if (cf->authorized_channels_only && !is_broadcast_channel && (((channel = ngx_http_push_stream_find_channel(cur->id, r->connection->log)) == NULL) || (channel->stored_messages == 0))) {
if (cf->authorized_channels_only && !is_wildcard_channel && (((channel = ngx_http_push_stream_find_channel(cur->id, r->connection->log)) == NULL) || (channel->stored_messages == 0))) {
*status_code = NGX_HTTP_FORBIDDEN;
*explain_error_message = (ngx_str_t *) &NGX_HTTP_PUSH_STREAM_CANNOT_CREATE_CHANNELS;
return NGX_ERROR;
......@@ -430,11 +430,11 @@ ngx_http_push_stream_validate_channels(ngx_http_request_t *r, ngx_http_push_stre
}
}
// check if number of subscribed broadcast channels is acceptable
if ((cf->broadcast_channel_max_qtd != NGX_CONF_UNSET_UINT) && (subscribed_broadcast_channels_qtd > 0) && ((subscribed_broadcast_channels_qtd > cf->broadcast_channel_max_qtd) || (subscribed_broadcast_channels_qtd == subscribed_channels_qtd))) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push stream module: max subscribed broadcast channels exceeded");
// check if number of subscribed wildcard channels is acceptable
if ((cf->wildcard_channel_max_qtd != NGX_CONF_UNSET_UINT) && (subscribed_wildcard_channels_qtd > 0) && ((subscribed_wildcard_channels_qtd > cf->wildcard_channel_max_qtd) || (subscribed_wildcard_channels_qtd == subscribed_channels_qtd))) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push stream module: max subscribed wildcard channels exceeded");
*status_code = NGX_HTTP_FORBIDDEN;
*explain_error_message = (ngx_str_t *) &NGX_HTTP_PUSH_STREAM_TOO_MUCH_BROADCAST_CHANNELS;
*explain_error_message = (ngx_str_t *) &NGX_HTTP_PUSH_STREAM_TOO_MUCH_WILDCARD_CHANNELS;
return NGX_ERROR;
}
......
......@@ -331,7 +331,7 @@ ngx_http_push_stream_add_msg_to_channel(ngx_http_request_t *r, ngx_str_t *id, u_
ngx_shmtx_unlock(&shpool->mutex);
// send an alert to workers
ngx_http_push_stream_broadcast(channel, msg, r->connection->log);
ngx_http_push_stream_wildcard(channel, msg, r->connection->log);
// turn on timer to cleanup buffer of old messages
ngx_http_push_stream_buffer_cleanup_timer_set(cf);
......@@ -662,7 +662,7 @@ ngx_http_push_stream_delete_channel(ngx_str_t *id, u_char *text, size_t len, ngx
if (channel != NULL) {
// remove channel from tree
channel->deleted = 1;
(channel->broadcast) ? NGX_HTTP_PUSH_STREAM_DECREMENT_COUNTER(data->broadcast_channels) : NGX_HTTP_PUSH_STREAM_DECREMENT_COUNTER(data->channels);
(channel->wildcard) ? NGX_HTTP_PUSH_STREAM_DECREMENT_COUNTER(data->wildcard_channels) : NGX_HTTP_PUSH_STREAM_DECREMENT_COUNTER(data->channels);
// move the channel to unrecoverable queue
ngx_rbtree_delete(&data->tree, &channel->node);
......@@ -722,7 +722,7 @@ ngx_http_push_stream_collect_expired_messages_and_empty_channels(ngx_http_push_s
if (!channel->deleted) {
channel->deleted = 1;
channel->expires = ngx_time() + NGX_HTTP_PUSH_STREAM_DEFAULT_SHM_MEMORY_CLEANUP_OBJECTS_TTL;
(channel->broadcast) ? NGX_HTTP_PUSH_STREAM_DECREMENT_COUNTER(data->broadcast_channels) : NGX_HTTP_PUSH_STREAM_DECREMENT_COUNTER(data->channels);
(channel->wildcard) ? NGX_HTTP_PUSH_STREAM_DECREMENT_COUNTER(data->wildcard_channels) : NGX_HTTP_PUSH_STREAM_DECREMENT_COUNTER(data->channels);
// move the channel to trash queue
ngx_rbtree_delete(&data->tree, &channel->node);
......
......@@ -93,7 +93,7 @@ ngx_http_push_stream_initialize_channel(ngx_http_push_stream_channel_t *channel)
ngx_rbtree_insert(&data->tree, &channel->node);
ngx_queue_insert_tail(&data->channels_queue, &channel->queue);
channel->queue_sentinel = &data->channels_queue;
(channel->broadcast) ? data->broadcast_channels++ : data->channels++;
(channel->wildcard) ? data->wildcard_channels++ : data->channels++;
}
static ngx_http_push_stream_channel_t *
......@@ -124,7 +124,7 @@ ngx_http_push_stream_get_channel(ngx_str_t *id, ngx_log_t *log, ngx_http_push_st
ngx_http_push_stream_shm_data_t *data = (ngx_http_push_stream_shm_data_t *) ngx_http_push_stream_shm_zone->data;
ngx_http_push_stream_channel_t *channel;
ngx_slab_pool_t *shpool = (ngx_slab_pool_t *) ngx_http_push_stream_shm_zone->shm.addr;
ngx_flag_t is_broadcast_channel = 0;
ngx_flag_t is_wildcard_channel = 0;
channel = ngx_http_push_stream_find_channel(id, log);
if (channel != NULL) { // we found our channel
......@@ -140,12 +140,12 @@ ngx_http_push_stream_get_channel(ngx_str_t *id, ngx_log_t *log, ngx_http_push_st
return channel;
}
if ((mcf->broadcast_channel_prefix.len > 0) && (ngx_strncmp(id->data, mcf->broadcast_channel_prefix.data, mcf->broadcast_channel_prefix.len) == 0)) {
is_broadcast_channel = 1;
if ((mcf->wildcard_channel_prefix.len > 0) && (ngx_strncmp(id->data, mcf->wildcard_channel_prefix.data, mcf->wildcard_channel_prefix.len) == 0)) {
is_wildcard_channel = 1;
}
if (((!is_broadcast_channel) && (mcf->max_number_of_channels != NGX_CONF_UNSET_UINT) && (mcf->max_number_of_channels == data->channels)) ||
((is_broadcast_channel) && (mcf->max_number_of_broadcast_channels != NGX_CONF_UNSET_UINT) && (mcf->max_number_of_broadcast_channels == data->broadcast_channels))) {
if (((!is_wildcard_channel) && (mcf->max_number_of_channels != NGX_CONF_UNSET_UINT) && (mcf->max_number_of_channels == data->channels)) ||
((is_wildcard_channel) && (mcf->max_number_of_wildcard_channels != NGX_CONF_UNSET_UINT) && (mcf->max_number_of_wildcard_channels == data->wildcard_channels))) {
ngx_shmtx_unlock(&shpool->mutex);
return NGX_HTTP_PUSH_STREAM_NUMBER_OF_CHANNELS_EXCEEDED;
}
......@@ -165,7 +165,7 @@ ngx_http_push_stream_get_channel(ngx_str_t *id, ngx_log_t *log, ngx_http_push_st
ngx_memcpy(channel->id.data, id->data, channel->id.len);
channel->id.data[channel->id.len] = '\0';
channel->broadcast = is_broadcast_channel;
channel->wildcard = is_wildcard_channel;
ngx_http_push_stream_initialize_channel(channel);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment