diff options
Diffstat (limited to 'pjlib')
-rw-r--r-- | pjlib/include/pj/compat/os_win32.h | 2 | ||||
-rw-r--r-- | pjlib/src/pj/ioqueue_common_abs.c | 20 |
2 files changed, 17 insertions, 5 deletions
diff --git a/pjlib/include/pj/compat/os_win32.h b/pjlib/include/pj/compat/os_win32.h index cf7431d6..95d3cd6e 100644 --- a/pjlib/include/pj/compat/os_win32.h +++ b/pjlib/include/pj/compat/os_win32.h @@ -73,7 +73,7 @@ /* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return * the status of non-blocking connect() operation. */ -#define PJ_HAS_SO_ERROR 0 +#define PJ_HAS_SO_ERROR 1 /* This value specifies the value set in errno by the OS when a non-blocking * socket recv() or send() can not return immediately. diff --git a/pjlib/src/pj/ioqueue_common_abs.c b/pjlib/src/pj/ioqueue_common_abs.c index 982c8080..5356f91d 100644 --- a/pjlib/src/pj/ioqueue_common_abs.c +++ b/pjlib/src/pj/ioqueue_common_abs.c @@ -209,8 +209,8 @@ void ioqueue_dispatch_write_event(pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h) { int value; socklen_t vallen = sizeof(value); - int gs_rc = getsockopt(h->fd, SOL_SOCKET, SO_ERROR, - &value, &vallen); + int gs_rc = pj_sock_getsockopt(h->fd, SOL_SOCKET, SO_ERROR, + &value, &vallen); if (gs_rc != 0) { /* Argh!! What to do now??? * Just indicate that the socket is connected. The @@ -524,8 +524,20 @@ void ioqueue_dispatch_exception_event( pj_ioqueue_t *ioqueue, pj_mutex_unlock(h->mutex); /* Call callback. */ - if (h->cb.on_connect_complete && !IS_CLOSING(h)) - (*h->cb.on_connect_complete)(h, -1); + if (h->cb.on_connect_complete && !IS_CLOSING(h)) { + pj_status_t status = -1; +#if (defined(PJ_HAS_SO_ERROR) && PJ_HAS_SO_ERROR!=0) + int value; + socklen_t vallen = sizeof(value); + int gs_rc = pj_sock_getsockopt(h->fd, SOL_SOCKET, SO_ERROR, + &value, &vallen); + if (gs_rc == 0) { + status = PJ_RETURN_OS_ERROR(value); + } +#endif + + (*h->cb.on_connect_complete)(h, status); + } } /* |