Changeset 610 for pjproject/trunk


Ignore:
Timestamp:
Jul 18, 2006 12:10:53 AM (18 years ago)
Author:
bennylp
Message:

Fixed several bugs related to TCP:

Location:
pjproject/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/include/pj/compat/os_win32.h

    r433 r610  
    7474 * the status of non-blocking connect() operation. 
    7575 */ 
    76 #define PJ_HAS_SO_ERROR             0 
     76#define PJ_HAS_SO_ERROR             1 
    7777 
    7878/* This value specifies the value set in errno by the OS when a non-blocking 
  • pjproject/trunk/pjlib/src/pj/ioqueue_common_abs.c

    r592 r610  
    210210          int value; 
    211211          socklen_t vallen = sizeof(value); 
    212           int gs_rc = getsockopt(h->fd, SOL_SOCKET, SO_ERROR,  
    213                               &value, &vallen); 
     212          int gs_rc = pj_sock_getsockopt(h->fd, SOL_SOCKET, SO_ERROR,  
     213                                        &value, &vallen); 
    214214          if (gs_rc != 0) { 
    215215            /* Argh!! What to do now???  
     
    525525 
    526526    /* Call callback. */ 
    527     if (h->cb.on_connect_complete && !IS_CLOSING(h)) 
    528         (*h->cb.on_connect_complete)(h, -1); 
     527    if (h->cb.on_connect_complete && !IS_CLOSING(h)) { 
     528        pj_status_t status = -1; 
     529#if (defined(PJ_HAS_SO_ERROR) && PJ_HAS_SO_ERROR!=0) 
     530        int value; 
     531        socklen_t vallen = sizeof(value); 
     532        int gs_rc = pj_sock_getsockopt(h->fd, SOL_SOCKET, SO_ERROR,  
     533                                       &value, &vallen); 
     534        if (gs_rc == 0) { 
     535            status = PJ_RETURN_OS_ERROR(value); 
     536        } 
     537#endif 
     538 
     539        (*h->cb.on_connect_complete)(h, status); 
     540    } 
    529541} 
    530542 
  • pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c

    r602 r610  
    283283on_return: 
    284284    pj_rwmutex_unlock_write(endpt->mod_mutex); 
     285 
     286    if (status != PJ_SUCCESS) { 
     287        char errmsg[PJ_ERR_MSG_SIZE]; 
     288 
     289        pj_strerror(status, errmsg, sizeof(errmsg)); 
     290        PJ_LOG(3,(THIS_FILE, "Module \"%.*s\" can not be unregistered: %s", 
     291                  (int)mod->name.slen, mod->name.ptr, errmsg)); 
     292    } 
     293 
    285294    return status; 
    286295} 
     
    527536 
    528537    /* Unregister modules. */ 
    529     while ((mod=endpt->module_list.prev) != &endpt->module_list) { 
     538    mod = endpt->module_list.prev; 
     539    while (mod != &endpt->module_list) { 
     540        pjsip_module *prev = mod->prev; 
    530541        pjsip_endpt_unregister_module(endpt, mod); 
     542        mod = prev; 
    531543    } 
    532544 
     
    596608    pj_pool_release( pool ); 
    597609 
     610    PJ_UNUSED_ARG(endpt); 
    598611    /* 
    599612    pj_mutex_unlock(endpt->mutex); 
  • pjproject/trunk/pjsip/src/pjsip/sip_transaction.c

    r600 r610  
    649649static pj_status_t mod_tsx_layer_unload(void) 
    650650{ 
     651    /* Only self destroy when there's no transaction in the table. 
     652     * Transaction may refuse to destroy when it has pending 
     653     * transmission. If we destroy the module now, application will 
     654     * crash when the pending transaction finally got error response 
     655     * from transport and when it tries to unregister itself. 
     656     */ 
     657    if (pj_hash_count(mod_tsx_layer.htable) != 0) 
     658        return PJ_EBUSY; 
     659 
    651660    /* Destroy mutex. */ 
    652661    pj_mutex_destroy(mod_tsx_layer.mutex); 
     
    928937    if (tsx->transport_flag & TSX_HAS_PENDING_TRANSPORT) { 
    929938        tsx->transport_flag |= TSX_HAS_PENDING_DESTROY; 
     939        tsx->tsx_user = NULL; 
    930940        PJ_LOG(4,(tsx->obj_name, "Will destroy later because transport is " 
    931941                                 "in progress")); 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c

    r605 r610  
    12411241    tcp = pj_ioqueue_get_user_data(key); 
    12421242 
     1243    /* Mark that pending connect() operation has completed. */ 
     1244    tcp->has_pending_connect = PJ_FALSE; 
     1245 
     1246    /* Check connect() status */ 
     1247    if (status != PJ_SUCCESS) { 
     1248 
     1249        tcp_perror(tcp->base.obj_name, "TCP connect() error", status); 
     1250 
     1251        /* Cancel all delayed transmits */ 
     1252        while (!pj_list_empty(&tcp->delayed_list)) { 
     1253            struct delayed_tdata *pending_tx; 
     1254            pj_ioqueue_op_key_t *op_key; 
     1255 
     1256            pending_tx = tcp->delayed_list.next; 
     1257            pj_list_erase(pending_tx); 
     1258 
     1259            op_key = (pj_ioqueue_op_key_t*)pending_tx->tdata_op_key; 
     1260 
     1261            on_write_complete(tcp->key, op_key, -status); 
     1262        } 
     1263 
     1264        /* We can not destroy the transport since high level objects may 
     1265         * still keep reference to this transport. So we can only  
     1266         * instruct transport manager to gracefully start the shutdown 
     1267         * procedure for this transport. 
     1268         */ 
     1269        if (tcp->close_reason==PJ_SUCCESS) tcp->close_reason = status; 
     1270        pjsip_transport_shutdown(&tcp->base); 
     1271        return; 
     1272    } 
     1273 
    12431274    PJ_LOG(4,(tcp->base.obj_name,  
    12441275              "TCP transport %.*s:%d is connected to %.*s:%d", 
     
    12501281              tcp->base.remote_name.port)); 
    12511282 
    1252     /* Mark that pending connect() operation has completed. */ 
    1253     tcp->has_pending_connect = PJ_FALSE; 
    1254  
    1255     /* Check connect() status */ 
    1256     if (status != PJ_SUCCESS) { 
    1257  
    1258         tcp_perror(tcp->base.obj_name, "TCP connect() error", status); 
    1259  
    1260         /* We can not destroy the transport since high level objects may 
    1261          * still keep reference to this transport. So we can only  
    1262          * instruct transport manager to gracefully start the shutdown 
    1263          * procedure for this transport. 
    1264          */ 
    1265         if (tcp->close_reason==PJ_SUCCESS) tcp->close_reason = status; 
    1266         pjsip_transport_shutdown(&tcp->base); 
    1267         return; 
    1268     } 
    12691283 
    12701284    /* Update (again) local address, just in case local address currently 
Note: See TracChangeset for help on using the changeset viewer.