]> piware.de Git - learn-rust.git/commitdiff
simple-http: Naïve unlimited threads
authorMartin Pitt <martin@piware.de>
Sat, 11 Sep 2021 09:36:22 +0000 (11:36 +0200)
committerMartin Pitt <martin@piware.de>
Sat, 11 Sep 2021 09:36:22 +0000 (11:36 +0200)
This introduces a DoS with too many parallel requests.

simple-http/src/main.rs

index d2d0f8801302d343ebd36dd7a1875049feda4292..0993075332c1c2335f135f45f0b1c875d7b5a783 100644 (file)
@@ -64,6 +64,6 @@ fn main() {
 
     for stream in listener.incoming() {
         let stream = stream.unwrap();
-        handle_connection(stream);
+        thread::spawn(|| handle_connection(stream));
     }
 }