|
26 | 26 | ; To adjust this while running, adjust the req-window* time, not |
27 | 27 | ; req-limit*, because algorithm doesn't enforce decreases in the latter. |
28 | 28 |
|
29 | | - req-times* (table) |
30 | 29 | req-limit* 30 |
31 | 30 | req-window* 10 ;10 |
32 | 31 | dos-window* 2 ;2 |
33 | 32 | ) |
34 | | - |
| 33 | +(or= req-times* (table)) |
35 | 34 |
|
36 | 35 | (def serve ((o port 8080)) |
37 | 36 | (wipe quitsrv*) |
|
65 | 64 | ; a thread to handle it. also arrange to kill that thread |
66 | 65 | ; if it has not completed in threadlife* seconds. |
67 | 66 |
|
68 | | -(= threadlife* 30 requests* 0 requests/ip* (table) |
69 | | - throttle-ips* (table) ignore-ips* (table) spurned* (table)) |
| 67 | +(or= threadlife* 30 requests* 0 requests/ip* (table) |
| 68 | + throttle-ips* (table) ignore-ips* (table) spurned* (table)) |
70 | 69 |
|
71 | 70 | (def accept-request-with-deadline (s) |
72 | 71 | (with ((in out ip) (socket-accept s) |
|
332 | 331 |
|
333 | 332 | ;; extending the server with new ops |
334 | 333 |
|
335 | | -(= srvops* (table) redirector* (table) optimes* (table) opcounts* (table)) |
| 334 | +(or= srvops* (table) redirector* (table) optimes* (table) opcounts* (table)) |
336 | 335 |
|
337 | 336 | (def save-optime (name elapsed) |
338 | 337 | ; this is the place to put a/b testing |
@@ -392,7 +391,7 @@ stdout, returns a url to redirect requests to after processing." |
392 | 391 | it))) |
393 | 392 | "")) |
394 | 393 |
|
395 | | -(= fns* (table) fnids* nil timed-fnids* nil) |
| 394 | +(or= fns* (table) fnids* nil timed-fnids* nil) |
396 | 395 |
|
397 | 396 | ; count on huge (expt 64 10) size of fnid space to avoid clashes |
398 | 397 |
|
@@ -600,7 +599,7 @@ stdout, returns a url to redirect requests to after processing." |
600 | 599 |
|
601 | 600 | ; only unique per server invocation |
602 | 601 |
|
603 | | -(= unique-ids* (table)) |
| 602 | +(or= unique-ids* (table)) |
604 | 603 |
|
605 | 604 | (def unique-id ((o len 8)) |
606 | 605 | (let id (sym (rand-string (max 5 len))) |
@@ -661,7 +660,7 @@ stdout, returns a url to redirect requests to after processing." |
661 | 660 |
|
662 | 661 | ; Background Threads |
663 | 662 |
|
664 | | -(= bgthreads* (table) pending-bgthreads* nil) |
| 663 | +(or= bgthreads* (table) pending-bgthreads* nil) |
665 | 664 |
|
666 | 665 | (def new-bgthread (id f sec) |
667 | 666 | (aif (bgthreads* id) (break-thread it)) |
|
0 commit comments