Commit 8e467fba authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

fix bug of segfault when the module is part of nginx but not in use

parent bdbe3706
...@@ -177,6 +177,10 @@ ngx_http_push_stream_init_module(ngx_cycle_t *cycle) ...@@ -177,6 +177,10 @@ ngx_http_push_stream_init_module(ngx_cycle_t *cycle)
{ {
ngx_core_conf_t *ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); ngx_core_conf_t *ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
if (ngx_http_push_stream_shm_zone == NULL) {
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "ngx_http_push_stream_module will not be used with this configuration.");
return NGX_OK;
}
ngx_http_push_stream_worker_processes = ccf->worker_processes; ngx_http_push_stream_worker_processes = ccf->worker_processes;
...@@ -188,6 +192,10 @@ ngx_http_push_stream_init_module(ngx_cycle_t *cycle) ...@@ -188,6 +192,10 @@ ngx_http_push_stream_init_module(ngx_cycle_t *cycle)
static ngx_int_t static ngx_int_t
ngx_http_push_stream_init_worker(ngx_cycle_t *cycle) ngx_http_push_stream_init_worker(ngx_cycle_t *cycle)
{ {
if (ngx_http_push_stream_shm_zone == NULL) {
return NGX_OK;
}
if ((ngx_http_push_stream_init_ipc_shm(ngx_http_push_stream_worker_processes)) != NGX_OK) { if ((ngx_http_push_stream_init_ipc_shm(ngx_http_push_stream_worker_processes)) != NGX_OK) {
return NGX_ERROR; return NGX_ERROR;
} }
......
...@@ -73,7 +73,7 @@ module BaseTestCase ...@@ -73,7 +73,7 @@ module BaseTestCase
end end
def create_config_file def create_config_file
template = ERB.new @@config_template template = ERB.new @config_template || @@config_template
config_content = template.result(binding) config_content = template.result(binding)
File.open(config_filename, 'w') {|f| f.write(config_content) } File.open(config_filename, 'w') {|f| f.write(config_content) }
File.open(mime_types_filename, 'w') {|f| f.write(@@mime_tipes_template) } File.open(mime_types_filename, 'w') {|f| f.write(@@mime_tipes_template) }
...@@ -151,6 +151,7 @@ module BaseTestCase ...@@ -151,6 +151,7 @@ module BaseTestCase
@store_messages = 'on' @store_messages = 'on'
@subscriber_connection_timeout = nil @subscriber_connection_timeout = nil
@memory_cleanup_timeout = '5m' @memory_cleanup_timeout = '5m'
@config_template = nil
end end
def publish_message(channel, headers, body) def publish_message(channel, headers, body)
......
...@@ -159,4 +159,32 @@ class TestSetuParameters < Test::Unit::TestCase ...@@ -159,4 +159,32 @@ class TestSetuParameters < Test::Unit::TestCase
stderr_msg = self.start_server stderr_msg = self.start_server
assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'") assert(stderr_msg.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ stderr_msg }'")
end end
def config_test_http_not_configured
@test_config_file = "test_http_not_configured.conf"
@config_template = %q{
pid <%= @pid_file %>;
error_log <%= @main_error_log %> debug;
# Development Mode
master_process off;
daemon off;
worker_processes <%=nginx_workers%>;
events {
worker_connections 1024;
use <%= (RUBY_PLATFORM =~ /darwin/) ? 'kqueue' : 'epoll' %>;
}
}
end
def test_http_not_configured
expected_error_message = "ngx_http_push_stream_module will not be used with this configuration."
self.create_config_file
self.start_server
log_file = File.read(@main_error_log)
assert(log_file.include?(expected_error_message), "Message error not founded: '#{ expected_error_message }' recieved '#{ log_file }'")
ensure
self.stop_server
end
end end
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