summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2010-02-05 11:11:52 +0000
committerBenny Prijono <bennylp@teluu.com>2010-02-05 11:11:52 +0000
commitf3ed1c64b067688cd1ce7226fde47ea06b7021ce (patch)
tree51ded1afaecb6cc55578f75ae12f937b9b5392b2
parentb813b2c567747c86ebe2c3de24ed6af26119ccf2 (diff)
Misc (#1026): PJLIB does not return the correct error code when TCP connection fails on Linux
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3088 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjlib/src/pj/ioqueue_common_abs.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/pjlib/src/pj/ioqueue_common_abs.c b/pjlib/src/pj/ioqueue_common_abs.c
index cccabc8b..bcd4f6a3 100644
--- a/pjlib/src/pj/ioqueue_common_abs.c
+++ b/pjlib/src/pj/ioqueue_common_abs.c
@@ -199,7 +199,7 @@ void ioqueue_dispatch_write_event(pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h)
#if defined(PJ_HAS_TCP) && PJ_HAS_TCP!=0
if (h->connecting) {
/* Completion of connect() operation */
- pj_ssize_t bytes_transfered;
+ pj_status_t status;
pj_bool_t has_lock;
/* Clear operation. */
@@ -226,13 +226,13 @@ void ioqueue_dispatch_write_event(pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h)
* application will get error as soon as it tries to use
* the socket to send/receive.
*/
- bytes_transfered = 0;
+ status = PJ_SUCCESS;
} else {
- bytes_transfered = value;
+ status = PJ_STATUS_FROM_OS(value);
}
}
#elif defined(PJ_WIN32) && PJ_WIN32!=0
- bytes_transfered = 0; /* success */
+ status = PJ_SUCCESS; /* success */
#else
/* Excellent information in D.J. Bernstein page:
* http://cr.yp.to/docs/connect.html
@@ -245,12 +245,11 @@ void ioqueue_dispatch_write_event(pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h)
* of suggestions from Douglas C. Schmidt and Ken Keys.
*/
{
- int gp_rc;
struct sockaddr_in addr;
- socklen_t addrlen = sizeof(addr);
+ int addrlen = sizeof(addr);
- gp_rc = getpeername(h->fd, (struct sockaddr*)&addr, &addrlen);
- bytes_transfered = (gp_rc < 0) ? gp_rc : -gp_rc;
+ status = pj_sock_getpeername(h->fd, (struct sockaddr*)&addr,
+ &addrlen);
}
#endif
@@ -269,7 +268,7 @@ void ioqueue_dispatch_write_event(pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h)
/* Call callback. */
if (h->cb.on_connect_complete && !IS_CLOSING(h))
- (*h->cb.on_connect_complete)(h, bytes_transfered);
+ (*h->cb.on_connect_complete)(h, status);
/* Unlock if we still hold the lock */
if (has_lock) {