Browse Source

Use flow control to avoid being spammed by fast talkers

fruit
Tony Garnock-Jones 2 years ago
parent
commit
3030d1959e
  1. 3
      syndicate/distributed/server/tcp.rkt

3
syndicate/distributed/server/tcp.rkt

@ -14,9 +14,10 @@ @@ -14,9 +14,10 @@
(assert (tcp-accepted id))
(assert (server-poa id))
(stop-when (retracted (server-poa-ready id)))
(on-start (issue-unbounded-credit! tcp-in id))
(on-start (issue-credit! #:amount 32768 tcp-in id))
(define accumulate! (packet-accumulator (lambda (p) (send! (message-poa->server id p)))))
(on (message (tcp-in id $bs))
(issue-credit! #:amount (bytes-length bs) tcp-in id)
(accumulate! bs))
(on (message (message-server->poa id $p))
(send! (tcp-out id (encode p)))

Loading…
Cancel
Save