embedthis/mpr-4 — pull request #3 by jchampio (2012-09-13 21:48:29+00:00)
Title: Fix writeSocket corner case

In the ```writeSocket()``` function, the call to ```send()``` bytes on the socket is immediately followed by a call to ```mprResetYield()```. If ```send()``` returns a negative value, ```mprGetSocketError()``` is called to determine the next course of action.

However, on some platforms, the call to ```mprResetYield()``` is enough to reset the global error code to zero. This causes the error handling code to fall through and return ```-errCode``` (which is zero), which in turn causes the calling code to believe that no bytes have been written. This leads to partial packet duplication.

This patch moves the call to ```mprGetSocketError()``` directly after the call to ```send()```. It also adds an assertion that the ```errCode``` is never zero when ```send()``` returns -1.