Add rate limiting and fix bug from previous commit (read does not return EAGAIN)