… | |
… | |
2240 | handles requests until the server gets some QUIT command, causing it to |
2240 | handles requests until the server gets some QUIT command, causing it to |
2241 | close the connection first (highly desirable for a busy TCP server). A |
2241 | close the connection first (highly desirable for a busy TCP server). A |
2242 | client dropping the connection is an error, which means this variant can |
2242 | client dropping the connection is an error, which means this variant can |
2243 | detect an unexpected detection close. |
2243 | detect an unexpected detection close. |
2244 | |
2244 | |
2245 | To handle this case, always make sure you have a on-empty read queue, by |
2245 | To handle this case, always make sure you have a non-empty read queue, by |
2246 | pushing the "read request start" handler on it: |
2246 | pushing the "read request start" handler on it: |
2247 | |
2247 | |
2248 | # we assume a request starts with a single line |
2248 | # we assume a request starts with a single line |
2249 | my @start_request; @start_request = (line => sub { |
2249 | my @start_request; @start_request = (line => sub { |
2250 | my ($hdl, $line) = @_; |
2250 | my ($hdl, $line) = @_; |