From a27f9954380e807a22b4dc75663e7091f52db325 Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Sun, 28 Sep 2014 12:18:03 +0200 Subject: [PATCH 1/2] attempt to fix #729 --- core/daemons.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/daemons.c b/core/daemons.c index 85f48da7..c121e475 100644 --- a/core/daemons.c +++ b/core/daemons.c @@ -237,7 +237,12 @@ void uwsgi_detach_daemons() { time_t timeout = uwsgi_now() + (uwsgi.reload_mercy ? uwsgi.reload_mercy : 3); int waitpid_status; while (!kill(ud->pid, 0)) { - kill(-(ud->pid), ud->stop_signal); + if (uwsgi_instance_is_reloading && ud->reload_signal > 0) { + kill(-(ud->pid), ud->reload_signal); + } + else { + kill(-(ud->pid), ud->stop_signal); + } sleep(1); waitpid(ud->pid, &waitpid_status, WNOHANG); if (uwsgi_now() >= timeout) { From ffeefea93bde574c87325cb307e86aba7865f8e5 Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Mon, 29 Sep 2014 11:56:11 +0200 Subject: [PATCH 2/2] preliminary support for RTSP --- plugins/http/common.h | 4 ++++ plugins/http/http.c | 10 ++++++++++ plugins/http/keepalive.c | 13 +++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/plugins/http/common.h b/plugins/http/common.h index 7ec55faf..fb46663a 100644 --- a/plugins/http/common.h +++ b/plugins/http/common.h @@ -48,6 +48,8 @@ struct uwsgi_http { int enable_proxy_protocol; int proto_http; + + int manage_rtsp; }; struct http_session { @@ -140,6 +142,8 @@ struct http_session { char *proxy_src_port; uint16_t proxy_src_len; uint16_t proxy_src_port_len; + + int is_rtsp; }; diff --git a/plugins/http/http.c b/plugins/http/http.c index 82c7b9ce..19f82623 100644 --- a/plugins/http/http.c +++ b/plugins/http/http.c @@ -67,6 +67,8 @@ struct uwsgi_option http_options[] = { {"http-enable-proxy-protocol", optional_argument, 0, "manage PROXY protocol requests", uwsgi_opt_true, &uhttp.enable_proxy_protocol, 0}, {"http-backend-http", no_argument, 0, "use plain http protocol instead of uwsgi for backend nodes", uwsgi_opt_true, &uhttp.proto_http, 0}, + + {"http-manage-rtsp", no_argument, 0, "manage RTSP sessions", uwsgi_opt_true, &uhttp.manage_rtsp, 0}, {0, 0, 0, 0, 0, 0, 0}, }; @@ -469,6 +471,10 @@ static int http_headers_parse_dumb(struct corerouter_peer *peer, int skip) { if (uhttp.keepalive && !uwsgi_strncmp("HTTP/1.1", 8, base, ptr-base)) { hr->session.can_keepalive = 1; } + if (uhttp.manage_rtsp && !uwsgi_strncmp("RTSP/1.0", 8, base, ptr-base)) { + hr->session.can_keepalive = 1; + hr->is_rtsp = 1; + } ptr += 2; found = 1; break; @@ -653,6 +659,10 @@ int http_headers_parse(struct corerouter_peer *peer, int skip) { if (uhttp.keepalive && !uwsgi_strncmp("HTTP/1.1", 8, base, ptr-base)) { hr->session.can_keepalive = 1; } + if (uhttp.manage_rtsp && !uwsgi_strncmp("RTSP/1.0", 8, base, ptr-base)) { + hr->session.can_keepalive = 1; + hr->is_rtsp = 1; + } ptr += 2; found = 1; break; diff --git a/plugins/http/keepalive.c b/plugins/http/keepalive.c index 7315a63a..8bdff6c8 100644 --- a/plugins/http/keepalive.c +++ b/plugins/http/keepalive.c @@ -17,7 +17,7 @@ int http_response_parse(struct http_session *hr, struct uwsgi_buffer *ub, size_t // protocol for(i=0;isession.can_keepalive && uwsgi_strncmp("HTTP/1.1", 8, buf, i)) { + if (!hr->is_rtsp && hr->session.can_keepalive && uwsgi_strncmp("HTTP/1.1", 8, buf, i)) { goto end; } if (i+1 >= len) return -1;; @@ -34,6 +34,15 @@ int http_response_parse(struct http_session *hr, struct uwsgi_buffer *ub, size_t for(i=next;iis_rtsp) { + if (next + 3 >= len) return -1; + char *code = buf + next; + if (code[0] != '2' || code[1] != '0' || code[2] != '0') { + hr->is_rtsp = 0; + hr->session.can_keepalive = 0; + } + } if (i+1 >= len) return -1; next = i + 1; found = 1; @@ -116,7 +125,7 @@ int http_response_parse(struct http_session *hr, struct uwsgi_buffer *ub, size_t } } - if (!has_size) { + if (!has_size && !hr->is_rtsp) { #ifdef UWSGI_ZLIB if (hr->has_gzip) { hr->force_gzip = 1;