diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-07-10 21:35:27 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-07-10 21:35:27 +0000 |
commit | 1e26f458f4e9c7d6547a613e66c9df94abeb913a (patch) | |
tree | c640c4842a31914bc36518e6afe140fab2cd08f4 /pjlib/src/pj/ioqueue_winnt.c | |
parent | 29912cad95b2725acbe030abed625998307eae0f (diff) |
Fixed several bugs in WinNT IOCP: (1) accept() does not return correct addresses, (2) handle error condition when accept() returns -1 as the new socket
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@599 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/ioqueue_winnt.c')
-rw-r--r-- | pjlib/src/pj/ioqueue_winnt.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/pjlib/src/pj/ioqueue_winnt.c b/pjlib/src/pj/ioqueue_winnt.c index fbf308e1..71977cbd 100644 --- a/pjlib/src/pj/ioqueue_winnt.c +++ b/pjlib/src/pj/ioqueue_winnt.c @@ -26,6 +26,7 @@ #include <pj/log.h> #include <pj/assert.h> #include <pj/errno.h> +#include <pj/compat/socket.h> #if defined(PJ_HAS_WINSOCK2_H) && PJ_HAS_WINSOCK2_H != 0 @@ -173,7 +174,7 @@ static void ioqueue_on_accept_complete(ioqueue_accept_rec *accept_overlapped) &locallen, &remote, &remotelen); - if (*accept_overlapped->addrlen > locallen) { + if (*accept_overlapped->addrlen >= locallen) { pj_memcpy(accept_overlapped->local, local, locallen); pj_memcpy(accept_overlapped->remote, remote, locallen); } else { @@ -627,10 +628,18 @@ static pj_bool_t poll_iocp( HANDLE hIocp, DWORD dwTimeout, ioqueue_on_accept_complete((ioqueue_accept_rec*)pOv); if (key->cb.on_accept_complete) { ioqueue_accept_rec *accept_rec = (ioqueue_accept_rec*)pOv; + pj_status_t status = PJ_SUCCESS; + + if (accept_rec->newsock == PJ_INVALID_SOCKET) { + int dwError = WSAGetLastError(); + if (dwError == 0) dwError = OSERR_ENOTCONN; + status = PJ_RETURN_OS_ERROR(dwError); + } + key->cb.on_accept_complete(key, (pj_ioqueue_op_key_t*)pOv, accept_rec->newsock, - PJ_SUCCESS); + status); accept_rec->newsock = PJ_INVALID_SOCKET; } break; |