Skip to content

Commit e8ad855

Browse files
authored
Merge pull request #162 from Tcode-Motion/fix-web-server-starvation-bug-2578265139593772338
🧹 Remove unnecessary clone and fix lock starvation in web server
2 parents ea89863 + 228c51e commit e8ad855

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎stdlib/src/web.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,9 @@ impl StdlibRegistry {
398398
Mutex::new(tiny_http::Server::http(format!("0.0.0.0:{}", port)).unwrap());
399399
thread::spawn(move || {
400400
while SERVER_RUNNING.load(Ordering::SeqCst) {
401-
let page = PAGE_CONTENT.lock().unwrap().clone();
402401
if let Ok(mut req) = server.lock().unwrap().recv() {
403-
let r = tiny_http::Response::from_string(&page).with_header(
402+
let page = PAGE_CONTENT.lock().unwrap();
403+
let r = tiny_http::Response::from_string(&*page).with_header(
404404
tiny_http::Header::from_bytes(
405405
&b"Content-Type"[..],
406406
&b"text/html; charset=utf-8"[..],
@@ -466,9 +466,9 @@ impl StdlibRegistry {
466466
Mutex::new(tiny_http::Server::http(format!("0.0.0.0:{}", port)).unwrap());
467467
thread::spawn(move || {
468468
while SERVER_RUNNING.load(Ordering::SeqCst) {
469-
let page = PAGE_CONTENT.lock().unwrap().clone();
470469
if let Ok(mut req) = server.lock().unwrap().recv() {
471-
let r = tiny_http::Response::from_string(&page).with_header(
470+
let page = PAGE_CONTENT.lock().unwrap();
471+
let r = tiny_http::Response::from_string(&*page).with_header(
472472
tiny_http::Header::from_bytes(
473473
&b"Content-Type"[..],
474474
&b"text/html; charset=utf-8"[..],

0 commit comments

Comments
 (0)