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
57127bb9
Commit
57127bb9
authored
Feb 04, 2012
by
Wandenberg Peixoto
Committed by
Wandenberg
Nov 08, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
returning to use ngx_http_chunked_filter_module on version 1.1.4+
parent
e2700bef
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
16 additions
and
33 deletions
+16
-33
CHANGELOG.textile
CHANGELOG.textile
+3
-1
README.textile
README.textile
+0
-5
ngx_http_push_stream_module.h
include/ngx_http_push_stream_module.h
+0
-2
ngx_http_push_stream_module_utils.h
include/ngx_http_push_stream_module_utils.h
+4
-5
measure_memory_spec.rb
misc/spec/mix/measure_memory_spec.rb
+3
-3
websocket_spec.rb
misc/spec/subscriber/websocket_spec.rb
+1
-1
ngx_http_push_stream_module_ipc.c
src/ngx_http_push_stream_module_ipc.c
+0
-1
ngx_http_push_stream_module_setup.c
src/ngx_http_push_stream_module_setup.c
+0
-2
ngx_http_push_stream_module_subscriber.c
src/ngx_http_push_stream_module_subscriber.c
+1
-3
ngx_http_push_stream_module_utils.c
src/ngx_http_push_stream_module_utils.c
+4
-10
No files found.
CHANGELOG.textile
View file @
57127bb9
h1(#changelog). Changelog
h1(#changelog). Changelog
* Back to use Nginx chunked filter
h2. Version 0.3.5
h2. Version 0.3.5
* Use JSONP when port numbers don't match.
* Use JSONP when port numbers don't match.
...
@@ -133,7 +135,7 @@ h2. Version 0.2.2
...
@@ -133,7 +135,7 @@ h2. Version 0.2.2
* Fixing memory allocation for channel id
* Fixing memory allocation for channel id
* Fixing response for detailed channels statistics when have a big number of channels
* Fixing response for detailed channels statistics when have a big number of channels
* Creating different timers to clear the memory, one for expired messages and another for empty channels
* Creating different timers to clear the memory, one for expired messages and another for empty channels
* Disable Nginx chun
c
ked filter for module locations
* Disable Nginx chunked filter for module locations
h2. Version 0.2.1
h2. Version 0.2.1
...
...
README.textile
View file @
57127bb9
...
@@ -174,11 +174,6 @@ h1(#installation). Installation <a name="installation" href="#"> </a>
...
@@ -174,11 +174,6 @@ h1(#installation). Installation <a name="installation" href="#"> </a>
sudo /usr/local/nginx/sbin/nginx -c $NGINX_PUSH_STREAM_MODULE_PATH/misc/nginx.conf
sudo /usr/local/nginx/sbin/nginx -c $NGINX_PUSH_STREAM_MODULE_PATH/misc/nginx.conf
</pre>
</pre>
h1(#attention). Attention
This module controls everything needed to send the messages to subscribers.
So it disable Nginx's chuncked filter to reduce memory consumption in streaming connections.
h1(#memory-usage). Memory usage
h1(#memory-usage). Memory usage
Just as information is listed below the minimum amount of memory used for each object:
Just as information is listed below the minimum amount of memory used for each object:
...
...
include/ngx_http_push_stream_module.h
View file @
57127bb9
...
@@ -264,8 +264,6 @@ static const ngx_str_t NGX_HTTP_PUSH_STREAM_HEADER_EXPLAIN = ngx_string("X-Ngin
...
@@ -264,8 +264,6 @@ static const ngx_str_t NGX_HTTP_PUSH_STREAM_HEADER_EXPLAIN = ngx_string("X-Ngin
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_MODE
=
ngx_string
(
"X-Nginx-PushStream-Mode"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_MODE
=
ngx_string
(
"X-Nginx-PushStream-Mode"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_TAG
=
ngx_string
(
"X-Nginx-PushStream-Tag"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_TAG
=
ngx_string
(
"X-Nginx-PushStream-Tag"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_COMMIT
=
ngx_string
(
"X-Nginx-PushStream-Commit"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_COMMIT
=
ngx_string
(
"X-Nginx-PushStream-Commit"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_TRANSFER_ENCODING
=
ngx_string
(
"Transfer-Encoding"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_CHUNCKED
=
ngx_string
(
"chunked"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_ETAG
=
ngx_string
(
"Etag"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_ETAG
=
ngx_string
(
"Etag"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_IF_NONE_MATCH
=
ngx_string
(
"If-None-Match"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_IF_NONE_MATCH
=
ngx_string
(
"If-None-Match"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_VARY
=
ngx_string
(
"Vary"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_HEADER_VARY
=
ngx_string
(
"Vary"
);
...
...
include/ngx_http_push_stream_module_utils.h
View file @
57127bb9
...
@@ -209,12 +209,11 @@ static const ngx_str_t NGX_HTTP_PUSH_STREAM_EVENTSOURCE_MESSAGE_PREFIX = ngx_st
...
@@ -209,12 +209,11 @@ static const ngx_str_t NGX_HTTP_PUSH_STREAM_EVENTSOURCE_MESSAGE_PREFIX = ngx_st
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_EVENTSOURCE_ID_TEMPLATE
=
ngx_string
(
"id: ~event-id~"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_EVENTSOURCE_ID_TEMPLATE
=
ngx_string
(
"id: ~event-id~"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_EVENTSOURCE_EVENT_TEMPLATE
=
ngx_string
(
"event: ~event-type~"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_EVENTSOURCE_EVENT_TEMPLATE
=
ngx_string
(
"event: ~event-type~"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_EVENTSOURCE_CONTENT_TYPE
=
ngx_string
(
"text/event-stream; charset=utf-8"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_EVENTSOURCE_CONTENT_TYPE
=
ngx_string
(
"text/event-stream; charset=utf-8"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_EVENTSOURCE_PING_MESSAGE_CHUNK
=
ngx_string
(
"
6"
CRLF
": -1"
CRLF
CRLF
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_EVENTSOURCE_PING_MESSAGE_CHUNK
=
ngx_string
(
"
: -1"
CRLF
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_LAST_CHUNK
=
ngx_string
(
"0"
CRLF
CRLF
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_INIT_CHUNK
=
ngx_string
(
"(["
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_INIT_CHUNK
=
ngx_string
(
"2"
CRLF
"(["
CRLF
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_MID_CHUNK
=
ngx_string
(
","
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_MID_CHUNK
=
ngx_string
(
"1"
CRLF
","
CRLF
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_END_CHUNK
=
ngx_string
(
"]);"
CRLF
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_END_CHUNK
=
ngx_string
(
"5"
CRLF
"]);"
CRLF
CRLF
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_CONTENT_TYPE
=
ngx_string
(
"application/javascript"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_CALLBACK_CONTENT_TYPE
=
ngx_string
(
"application/javascript"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_PADDING_BY_USER_AGENT_PATTERN
=
ngx_string
(
"([^:]+),(
\\
d+),(
\\
d+)"
);
static
const
ngx_str_t
NGX_HTTP_PUSH_STREAM_PADDING_BY_USER_AGENT_PATTERN
=
ngx_string
(
"([^:]+),(
\\
d+),(
\\
d+)"
);
...
...
misc/spec/mix/measure_memory_spec.rb
View file @
57127bb9
...
@@ -15,8 +15,8 @@ describe "Measure Memory" do
...
@@ -15,8 +15,8 @@ describe "Measure Memory" do
}
}
end
end
message_estimate_size
=
1
75
message_estimate_size
=
1
68
channel_estimate_size
=
27
2
channel_estimate_size
=
27
0
subscriber_estimate_size
=
160
subscriber_estimate_size
=
160
subscriber_estimate_system_size
=
7000
subscriber_estimate_system_size
=
7000
...
@@ -44,7 +44,7 @@ describe "Measure Memory" do
...
@@ -44,7 +44,7 @@ describe "Measure Memory" do
resp
=
JSON
.
parse
(
pub_2
.
response
)
resp
=
JSON
.
parse
(
pub_2
.
response
)
expected_message
=
shared_size
/
(
message_estimate_size
+
body
.
size
)
expected_message
=
shared_size
/
(
message_estimate_size
+
body
.
size
)
resp
[
"published_messages"
].
to_i
.
should
be_within
(
2
0
).
of
(
expected_message
)
resp
[
"published_messages"
].
to_i
.
should
be_within
(
8
0
).
of
(
expected_message
)
EventMachine
.
stop
EventMachine
.
stop
end
end
end
end
...
...
misc/spec/subscriber/websocket_spec.rb
View file @
57127bb9
...
@@ -274,7 +274,7 @@ describe "Subscriber WebSocket" do
...
@@ -274,7 +274,7 @@ describe "Subscriber WebSocket" do
socket_2
=
open_socket
(
nginx_host
,
nginx_port
)
socket_2
=
open_socket
(
nginx_host
,
nginx_port
)
socket_2
.
print
(
"
#{
request_2
}
\r\n
"
)
socket_2
.
print
(
"
#{
request_2
}
\r\n
"
)
headers_2
,
body_2
=
read_response_on_socket
(
socket_2
,
'}'
)
headers_2
,
body_2
=
read_response_on_socket
(
socket_2
,
'}'
)
body_2
.
should
eql
(
"
11
\r\n
{
\"
text
\"
:
\"
#{
body
}
\"
}
\r\n
\r\n
"
)
body_2
.
should
eql
(
"
{
\"
text
\"
:
\"
#{
body
}
\"
}
\r\n
"
)
end
end
end
end
...
...
src/ngx_http_push_stream_module_ipc.c
View file @
57127bb9
...
@@ -406,7 +406,6 @@ ngx_http_push_stream_respond_to_subscribers(ngx_http_push_stream_channel_t *chan
...
@@ -406,7 +406,6 @@ ngx_http_push_stream_respond_to_subscribers(ngx_http_push_stream_channel_t *chan
ngx_http_push_stream_subscription_t
*
subscription
=
ngx_queue_data
(
cur
,
ngx_http_push_stream_subscription_t
,
channel_worker_queue
);
ngx_http_push_stream_subscription_t
*
subscription
=
ngx_queue_data
(
cur
,
ngx_http_push_stream_subscription_t
,
channel_worker_queue
);
ngx_http_push_stream_subscriber_t
*
subscriber
=
subscription
->
subscriber
;
ngx_http_push_stream_subscriber_t
*
subscriber
=
subscription
->
subscriber
;
if
(
subscriber
->
longpolling
)
{
if
(
subscriber
->
longpolling
)
{
ngx_http_push_stream_add_response_header
(
subscriber
->
request
,
&
NGX_HTTP_PUSH_STREAM_HEADER_TRANSFER_ENCODING
,
&
NGX_HTTP_PUSH_STREAM_HEADER_CHUNCKED
);
ngx_http_push_stream_add_polling_headers
(
subscriber
->
request
,
msg
->
time
,
msg
->
tag
,
subscriber
->
request
->
pool
);
ngx_http_push_stream_add_polling_headers
(
subscriber
->
request
,
msg
->
time
,
msg
->
tag
,
subscriber
->
request
->
pool
);
ngx_http_send_header
(
subscriber
->
request
);
ngx_http_send_header
(
subscriber
->
request
);
...
...
src/ngx_http_push_stream_module_setup.c
View file @
57127bb9
...
@@ -764,8 +764,6 @@ ngx_http_push_stream_setup_handler(ngx_conf_t *cf, void *conf, ngx_int_t (*handl
...
@@ -764,8 +764,6 @@ ngx_http_push_stream_setup_handler(ngx_conf_t *cf, void *conf, ngx_int_t (*handl
psmcf
->
enabled
=
1
;
psmcf
->
enabled
=
1
;
clcf
->
handler
=
handler
;
clcf
->
handler
=
handler
;
clcf
->
if_modified_since
=
NGX_HTTP_IMS_OFF
;
clcf
->
if_modified_since
=
NGX_HTTP_IMS_OFF
;
// disable chunked_filter_module for streaming connections
clcf
->
chunked_transfer_encoding
=
0
;
return
NGX_CONF_OK
;
return
NGX_CONF_OK
;
}
}
...
...
src/ngx_http_push_stream_module_subscriber.c
View file @
57127bb9
...
@@ -118,7 +118,6 @@ ngx_http_push_stream_subscriber_handler(ngx_http_request_t *r)
...
@@ -118,7 +118,6 @@ ngx_http_push_stream_subscriber_handler(ngx_http_request_t *r)
return
NGX_HTTP_INTERNAL_SERVER_ERROR
;
return
NGX_HTTP_INTERNAL_SERVER_ERROR
;
}
}
ngx_http_push_stream_add_response_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_TRANSFER_ENCODING
,
&
NGX_HTTP_PUSH_STREAM_HEADER_CHUNCKED
);
ngx_http_send_header
(
r
);
ngx_http_send_header
(
r
);
// sending response content header
// sending response content header
...
@@ -264,7 +263,6 @@ ngx_http_push_stream_subscriber_polling_handler(ngx_http_request_t *r, ngx_http_
...
@@ -264,7 +263,6 @@ ngx_http_push_stream_subscriber_polling_handler(ngx_http_request_t *r, ngx_http_
r
->
headers_out
.
status
=
NGX_HTTP_OK
;
r
->
headers_out
.
status
=
NGX_HTTP_OK
;
r
->
headers_out
.
content_length_n
=
-
1
;
r
->
headers_out
.
content_length_n
=
-
1
;
ngx_http_push_stream_add_response_header
(
r
,
&
NGX_HTTP_PUSH_STREAM_HEADER_TRANSFER_ENCODING
,
&
NGX_HTTP_PUSH_STREAM_HEADER_CHUNCKED
);
ngx_http_send_header
(
r
);
ngx_http_send_header
(
r
);
// sending response content header
// sending response content header
...
@@ -297,7 +295,7 @@ ngx_http_push_stream_subscriber_polling_handler(ngx_http_request_t *r, ngx_http_
...
@@ -297,7 +295,7 @@ ngx_http_push_stream_subscriber_polling_handler(ngx_http_request_t *r, ngx_http_
ngx_http_push_stream_send_response_text
(
r
,
cf
->
footer_template
.
data
,
cf
->
footer_template
.
len
,
0
);
ngx_http_push_stream_send_response_text
(
r
,
cf
->
footer_template
.
data
,
cf
->
footer_template
.
len
,
0
);
}
}
ngx_http_
push_stream_send_response_text
(
r
,
NGX_HTTP_PUSH_STREAM_LAST_CHUNK
.
data
,
NGX_HTTP_PUSH_STREAM_LAST_CHUNK
.
len
,
1
);
ngx_http_
send_special
(
r
,
NGX_HTTP_LAST
|
NGX_HTTP_FLUSH
);
return
NGX_OK
;
return
NGX_OK
;
}
}
...
...
src/ngx_http_push_stream_module_utils.c
View file @
57127bb9
...
@@ -96,7 +96,6 @@ ngx_http_push_stream_delete_channels(ngx_http_push_stream_shm_data_t *data, ngx_
...
@@ -96,7 +96,6 @@ ngx_http_push_stream_delete_channels(ngx_http_push_stream_shm_data_t *data, ngx_
ngx_shmtx_unlock
(
&
shpool
->
mutex
);
ngx_shmtx_unlock
(
&
shpool
->
mutex
);
if
(
subscriber
->
longpolling
)
{
if
(
subscriber
->
longpolling
)
{
ngx_http_push_stream_add_response_header
(
subscriber
->
request
,
&
NGX_HTTP_PUSH_STREAM_HEADER_TRANSFER_ENCODING
,
&
NGX_HTTP_PUSH_STREAM_HEADER_CHUNCKED
);
ngx_http_push_stream_add_polling_headers
(
subscriber
->
request
,
ngx_time
(),
0
,
subscriber
->
request
->
pool
);
ngx_http_push_stream_add_polling_headers
(
subscriber
->
request
,
ngx_time
(),
0
,
subscriber
->
request
->
pool
);
ngx_http_send_header
(
subscriber
->
request
);
ngx_http_send_header
(
subscriber
->
request
);
...
@@ -518,11 +517,7 @@ ngx_http_push_stream_output_filter(ngx_http_request_t *r, ngx_chain_t *in)
...
@@ -518,11 +517,7 @@ ngx_http_push_stream_output_filter(ngx_http_request_t *r, ngx_chain_t *in)
rc
=
ngx_http_output_filter
(
r
,
in
);
rc
=
ngx_http_output_filter
(
r
,
in
);
if
((
ctx
=
ngx_http_get_module_ctx
(
r
,
ngx_http_push_stream_module
))
!=
NULL
)
{
if
((
ctx
=
ngx_http_get_module_ctx
(
r
,
ngx_http_push_stream_module
))
!=
NULL
)
{
#if defined nginx_version && nginx_version >= 1001004
ngx_chain_update_chains
(
r
->
pool
,
&
ctx
->
free
,
&
ctx
->
busy
,
&
in
,
(
ngx_buf_tag_t
)
&
ngx_http_push_stream_module
);
ngx_chain_update_chains
(
r
->
pool
,
&
ctx
->
free
,
&
ctx
->
busy
,
&
in
,
(
ngx_buf_tag_t
)
&
ngx_http_push_stream_module
);
#else
ngx_chain_update_chains
(
&
ctx
->
free
,
&
ctx
->
busy
,
&
in
,
(
ngx_buf_tag_t
)
&
ngx_http_push_stream_module
);
#endif
}
}
return
rc
;
return
rc
;
...
@@ -635,7 +630,7 @@ ngx_http_push_stream_send_response_finalize(ngx_http_request_t *r)
...
@@ -635,7 +630,7 @@ ngx_http_push_stream_send_response_finalize(ngx_http_request_t *r)
if
(
pslcf
->
location_type
==
NGX_HTTP_PUSH_STREAM_WEBSOCKET_MODE
)
{
if
(
pslcf
->
location_type
==
NGX_HTTP_PUSH_STREAM_WEBSOCKET_MODE
)
{
rc
=
ngx_http_push_stream_send_response_text
(
r
,
NGX_HTTP_PUSH_STREAM_WEBSOCKET_CLOSE_LAST_FRAME_BYTE
,
sizeof
(
NGX_HTTP_PUSH_STREAM_WEBSOCKET_CLOSE_LAST_FRAME_BYTE
),
1
);
rc
=
ngx_http_push_stream_send_response_text
(
r
,
NGX_HTTP_PUSH_STREAM_WEBSOCKET_CLOSE_LAST_FRAME_BYTE
,
sizeof
(
NGX_HTTP_PUSH_STREAM_WEBSOCKET_CLOSE_LAST_FRAME_BYTE
),
1
);
}
else
{
}
else
{
rc
=
ngx_http_
push_stream_send_response_text
(
r
,
NGX_HTTP_PUSH_STREAM_LAST_CHUNK
.
data
,
NGX_HTTP_PUSH_STREAM_LAST_CHUNK
.
len
,
1
);
rc
=
ngx_http_
send_special
(
r
,
NGX_HTTP_LAST
|
NGX_HTTP_FLUSH
);
}
}
}
}
...
@@ -1241,10 +1236,9 @@ ngx_http_push_stream_get_formatted_chunk(const u_char *text, off_t len, ngx_pool
...
@@ -1241,10 +1236,9 @@ ngx_http_push_stream_get_formatted_chunk(const u_char *text, off_t len, ngx_pool
{
{
ngx_str_t
*
chunk
;
ngx_str_t
*
chunk
;
/* the "0000000000000000" is 64-bit hexadimal string */
chunk
=
ngx_http_push_stream_create_str
(
temp_pool
,
sizeof
(
CRLF
)
+
len
);
chunk
=
ngx_http_push_stream_create_str
(
temp_pool
,
sizeof
(
"0000000000000000"
CRLF
CRLF
CRLF
)
+
len
);
if
(
chunk
!=
NULL
)
{
if
(
chunk
!=
NULL
)
{
ngx_sprintf
(
chunk
->
data
,
"%
xO"
CRLF
"%*s"
CRLF
CRLF
,
len
+
sizeof
(
CRLF
)
-
1
,
(
size_t
)
len
,
text
);
ngx_sprintf
(
chunk
->
data
,
"%
*s"
CRLF
,
(
size_t
)
len
,
text
);
chunk
->
len
=
ngx_strlen
(
chunk
->
data
);
chunk
->
len
=
ngx_strlen
(
chunk
->
data
);
}
}
return
chunk
;
return
chunk
;
...
...
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