Commit e4a5e005 authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

fix memory leaks when saving channels on a rbtree with ids which collides,...

fix memory leaks when saving channels on a rbtree with ids which collides, problem inherited from Nginx and reported by Lanshun Zhou
parent a690c2e0
......@@ -27,6 +27,6 @@
#define NGX_HTTP_PUSH_STREAM_MODULE_VERSION_H_
static const ngx_str_t NGX_HTTP_PUSH_STREAM_TAG = ngx_string("0.3.2");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_COMMIT = ngx_string("92491f7c847bbc6bf092c08701438622770aab90");
static const ngx_str_t NGX_HTTP_PUSH_STREAM_COMMIT = ngx_string("a690c2e0d32cf4a18de72aac6e9ac385e3148675");
#endif /* NGX_HTTP_PUSH_STREAM_MODULE_VERSION_H_ */
......@@ -59,19 +59,14 @@ ngx_http_push_stream_find_channel_on_tree(ngx_str_t *id, ngx_log_t *log, ngx_rbt
/* hash == node->key */
do {
channel = (ngx_http_push_stream_channel_t *) node;
channel = (ngx_http_push_stream_channel_t *) node;
rc = ngx_memn2cmp(id->data, channel->id.data, id->len, channel->id.len);
if (rc == 0) {
return channel;
}
node = (rc < 0) ? node->left : node->right;
} while (node != sentinel && hash == node->key);
rc = ngx_memn2cmp(id->data, channel->id.data, id->len, channel->id.len);
if (rc == 0) {
return channel;
}
break;
node = (rc < 0) ? node->left : node->right;
}
return NULL;
......
require File.expand_path('base_test_case', File.dirname(__FILE__))
class TestChannelIdCollision < Test::Unit::TestCase
include BaseTestCase
def test_create_and_retrieve_channels_with_ids_that_collide
channels = ["A", "plumless", "buckeroo", "B", "fc0591", "123rainerbommert", "C", "a1sellers", "advertees", "D"]
channels.each do |channel|
EventMachine.run {
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel).post :body => 'x', :timeout => 30
pub.callback {
assert_equal(200, pub.response_header.status, "Channel '#{channel}' was not created")
EventMachine.stop
}
}
end
channels.each do |channel|
EventMachine.run {
pub = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel).get :timeout => 30
pub.callback {
assert_equal(200, pub.response_header.status, "Channel '#{channel}' was not founded")
EventMachine.stop
}
}
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