CPU spins when connection closed while receiving post body.
hidekiy opened this issue · 4 comments
I made this patch before:
966e4e8
but I don't have clear repro.
Today I finally created a good repro for this problem.
https://gist.github.com/719061
on Perl 5.12.2, CentOS 5 64bit, Twiggy 0.1008
About the patch. I wonder there is a situation
In this situation I think respect $retval.
AnyEvent::Handle uses sysread(), but Twiggy uses read() because it was speed tuned by using Perl IO.
This difference may caused an edge-case in the socket that closed by TCP Reset.
I made a mistake. This commit:
https://github.com/hidekiy/Twiggy/commit/966e4e80c7dfb46f83e5962072f3a70f68e81320
Confirm, it is easy to cause twiggy server 100% load
% nc 0 5000
POST / HTTP/1.1
User-Agent: curl/7.24.0 (i686-pc-linux-gnu) libcurl/7.24.0 GnuTLS/2.12.16 zlib/1.2.6
Host: 0:5000
Accept: */*
Content-Length: 4
Content-Type: application/x-www-form-urlencoded
1
^C
Open a pull request with a unit test and I will get it merged and shipped.