Misc (#1026): PJLIB does not return the correct error code when TCP connection fails on Linux

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@3088 74dad513-b988-da41-8d7b-12977e46ad98
remotes/origin/iphone
Benny Prijono 15 years ago
parent d8435e6798
commit 653af2ec75

@ -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) {

Loading…
Cancel
Save