summaryrefslogtreecommitdiff
path: root/pjlib
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-07-18 10:33:09 +0000
committerBenny Prijono <bennylp@teluu.com>2008-07-18 10:33:09 +0000
commit63ba5ff8c3c834b685b4e5f41833f77737008193 (patch)
tree7033e0ccbd17c85edffa9c5699ec597de2038016 /pjlib
parent97ffd0a2aec425c15afe83d10f9d218a45c7d050 (diff)
Ticket #575: Unregistering from Windows IOCompletionPort (IOCP) ioqueue does not close the socket handle (thanks Gang Liu for the report)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2155 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib')
-rw-r--r--pjlib/src/pj/ioqueue_winnt.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/pjlib/src/pj/ioqueue_winnt.c b/pjlib/src/pj/ioqueue_winnt.c
index 82dcc057..a5618e36 100644
--- a/pjlib/src/pj/ioqueue_winnt.c
+++ b/pjlib/src/pj/ioqueue_winnt.c
@@ -786,7 +786,21 @@ PJ_DEF(pj_status_t) pj_ioqueue_unregister( pj_ioqueue_key_t *key )
* We also need to close handle to make sure that no further events
* will come to the handle.
*/
- CloseHandle(key->hnd);
+ /* Update 2008/07/18 (http://trac.pjsip.org/repos/ticket/575):
+ * - It seems that CloseHandle() in itself does not actually close
+ * the socket (i.e. it will still appear in "netstat" output). Also
+ * if we only use CloseHandle(), an "Invalid Handle" exception will
+ * be raised in WSACleanup().
+ * - MSDN documentation says that CloseHandle() must be called after
+ * closesocket() call (see
+ * http://msdn.microsoft.com/en-us/library/ms724211(VS.85).aspx).
+ * But turns out that this will raise "Invalid Handle" exception
+ * in debug mode.
+ * So because of this, we replaced CloseHandle() with closesocket()
+ * instead. These was tested on WinXP SP2.
+ */
+ //CloseHandle(key->hnd);
+ pj_sock_close((pj_sock_t)key->hnd);
/* Reset callbacks */
key->cb.on_accept_complete = NULL;