I reported a bug on last weekend...This bug can be easily reproduced by sending continuous small chunks data. If we use pb or amp and send any data whose size can't fit the buffer (128K),
iocp reactor will raise a ERROR_IO_PENDING. and close the connection immediately. It looks like many write events are triggered instead of one.
two ways to work around:
1: increase the buffer limit.
2: don't try to send chunks data in a very short period...
after years development, iocp has been improved but not enough...comparing with other reactors like epoll,,,it is still experimental.
update: I have solved this bug. patch will be submitted soon.
This bug actually was triggered when SEND_LIMIT is reaching. IOCP may re schedule the writing operation which will lead to doWrite is called twice for the same data. When PB is unable to deserialize these bytes, it will simply close the connection and raise an exception.
What we need to do is to make sure doWrite being invoked in order. When the callback isn't invoked, we shouldn't call doWrite again.
I introduced an variable to solve this bug. now the test pass.