Changeset 3088


Ignore:
Timestamp:
Feb 5, 2010 11:11:52 AM (14 years ago)
Author:
bennylp
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/ioqueue_common_abs.c

    r2826 r3088  
    200200    if (h->connecting) { 
    201201        /* Completion of connect() operation */ 
    202         pj_ssize_t bytes_transfered; 
     202        pj_status_t status; 
    203203        pj_bool_t has_lock; 
    204204 
     
    227227             * the socket to send/receive. 
    228228             */ 
    229             bytes_transfered = 0; 
     229              status = PJ_SUCCESS; 
    230230          } else { 
    231             bytes_transfered = value; 
     231              status = PJ_STATUS_FROM_OS(value); 
    232232          } 
    233233        } 
    234234#elif defined(PJ_WIN32) && PJ_WIN32!=0 
    235         bytes_transfered = 0; /* success */ 
     235        status = PJ_SUCCESS; /* success */ 
    236236#else 
    237237        /* Excellent information in D.J. Bernstein page: 
     
    246246         */ 
    247247        { 
    248             int gp_rc; 
    249248            struct sockaddr_in addr; 
    250             socklen_t addrlen = sizeof(addr); 
    251  
    252             gp_rc = getpeername(h->fd, (struct sockaddr*)&addr, &addrlen); 
    253             bytes_transfered = (gp_rc < 0) ? gp_rc : -gp_rc; 
     249            int addrlen = sizeof(addr); 
     250 
     251            status = pj_sock_getpeername(h->fd, (struct sockaddr*)&addr, 
     252                                         &addrlen); 
    254253        } 
    255254#endif 
     
    270269        /* Call callback. */ 
    271270        if (h->cb.on_connect_complete && !IS_CLOSING(h)) 
    272             (*h->cb.on_connect_complete)(h, bytes_transfered); 
     271            (*h->cb.on_connect_complete)(h, status); 
    273272 
    274273        /* Unlock if we still hold the lock */ 
Note: See TracChangeset for help on using the changeset viewer.