Browse Source

MT#55283 fix HTTP/WS deadlock

Avoid trying to acquire a recursive lock by making sure the response is
always generated in a different thread.

Fixes #1656

Change-Id: I6c4c5bb52cb95a204823848bb427ab24f42dcccd
(cherry picked from commit 04ce204ef6)
pull/1736/head
Richard Fuchs 3 years ago
parent
commit
aa9be51267
1 changed files with 12 additions and 12 deletions
  1. +12
    -12
      daemon/websocket.c

+ 12
- 12
daemon/websocket.c View File

@ -511,6 +511,14 @@ static const char *websocket_http_ng(struct websocket_message *wm) {
static const char *websocket_http_404(struct websocket_message *wm) {
ilogs(http, LOG_WARN, "Unhandled HTTP URI: '%s'", wm->uri);
websocket_http_complete(wm->wc, 404, "text/plain", 10, "not found\n");
return NULL;
}
static int websocket_http_get(struct websocket_conn *wc) {
struct websocket_message *wm = wc->wm;
const char *uri = wm->uri;
@ -525,12 +533,8 @@ static int websocket_http_get(struct websocket_conn *wc) {
handler = websocket_http_cli;
else if (!strcmp(uri, "/metrics"))
handler = websocket_http_metrics;
if (!handler) {
ilogs(http, LOG_WARN, "Unhandled HTTP GET URI: '%s'", uri);
websocket_http_complete(wm->wc, 404, "text/plain", 10, "not found\n");
return 0;
}
else
handler = websocket_http_404;
websocket_message_push(wc, handler);
return 0;
@ -594,12 +598,8 @@ static int websocket_http_body(struct websocket_conn *wc, const char *body, size
handler = websocket_http_ng;
else if (!strcmp(uri, "/admin") && wm->method == M_POST && wm->content_type == CT_JSON)
handler = websocket_janus_process;
if (!handler) {
ilogs(http, LOG_WARN, "Unhandled HTTP POST URI: '%s'", wm->uri);
websocket_http_complete(wm->wc, 404, "text/plain", 10, "not found\n");
return 0;
}
else
handler = websocket_http_404;
websocket_message_push(wc, handler);
return 0;


Loading…
Cancel
Save