Re: [INTERNALS-WIN] noticed some incorrect error handling for some socket specific API's on windows
| From: | Pierre Joye | Date: | Wed, 02 Sep 2009 15:10:28 +0000 |
| Subject: | Re: [INTERNALS-WIN] noticed some incorrect error handling for some socket specific API's on windows | ||
| References: | 1 2 | Groups: | php.internals.win |
| Request: | Send a blank email to internals-win+get-599@lists.php.net to get a copy of this message | ||
hi,
On Wed, Sep 2, 2009 at 4:57 PM, Keisial<keisial@gmail.com> wrote:
> Sriram Natarajan wrote:
>> HI
>> On Windows , socket API's does not return '-1' on failure. In this
>> case, most commonly returned error code is either SOCKET_ERROR or
>> INVALID_SOCKET. Af course, most of us know this. However, I did notice
>> that within our php implementation in some places we do check for the
>> same BSD style error value (< 0) rather than using the appropriate
>> macros.
> Both SOCKET_ERROR and INVALID_SOCKET value -1. So the current code isn't
> wrong.
>
>> Here is a suggested patch to address this. Here, the issue is - if we
>> didn't catch the error at the right place, we might end up providing
>> incorrect error message(s). Please let me know, if I overlooked some
>> thing obvious here.
>
> You are checking the getsockname() return against SOCK_CONN_ERR.
> However, msdn documentation on getsockname function specifies "If no
> error occurs, *getsockname* returns zero. Otherwise, a value of
> SOCKET_ERROR is returned, and a specific error code can be retrieved by
> calling *WSAGetLastError*
>
> <http://msdn.microsoft.com/en-us/library/ms741580%28VS.85%29.aspx>."
>
> http://msdn.microsoft.com/en-us/library/ms738543%28VS.85%29.aspx
>
> Finally, I don't have SOCK_CONN_ERR on my windows headers, although I
> checked on several versions. It may be a new macro also evaluating to
> -1, but I wouldn't use a macro so hard to have.
Please check the code. There is a #define SOCK_CONN_ERR SOCKET_ERROR
for portability reasons.
Cheers,
--
Pierre
http://blog.thepimp.net | http://www.libgd.org