Merge branch 'master' of ssh://github.com/unbit/uwsgi

This commit is contained in:
Unbit
2014-09-30 07:59:21 +02:00
4 changed files with 31 additions and 3 deletions
+6 -1
View File
@@ -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) {
+4
View File
@@ -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;
};
+10
View File
@@ -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;
+11 -2
View File
@@ -17,7 +17,7 @@ int http_response_parse(struct http_session *hr, struct uwsgi_buffer *ub, size_t
// protocol
for(i=0;i<len;i++) {
if (buf[i] == ' ') {
if (hr->session.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;i<len;i++) {
if (buf[i] == '\r' || buf[i] == '\n') {
// status ready
// if we are in RTSP mode we need to ensure a 200 is returned
if (hr->is_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;