Skip to content

network: httpd: fix lock usage of URL callbacks

Alaric Senat requested to merge asenat/vlc:fix/httpd-url-catch-lock into master

This lock was left unused in the current code-base. Previously locking in httpd_UrlCatch for nothing.

Locking before calling the callbacks allows non-racy modifications of the callback function pointer and/or opaque data after the start of the HTTPD thread-loop and I think that it was the original intent of the mutex.

This potential race-condition was encountered on the development of the new HLS sout module while trying to hot-swap the httpd URL catch callback context.

Here's a sample of the racy use-case:

httpd_host_t *host = vlc_http_HostNew(obj);
httpd_url_t *url = httpd_UrlNew("/index.html", host, NULL, NULL);

const char *sys = "value1";
httpd_UrlCatch(url, HTTPD_MSG_GET, pf_callback, sys);

// ... Normal program execution ...

const char *new_sys = "value2";
// New context on the HTTP url callback.
httpd_UrlCatch(url, HTTPD_MSG_GET, pf_callback, new_sys);

Merge request reports

Loading