Changeset 3455 for pjproject


Ignore:
Timestamp:
Mar 16, 2011 7:34:16 AM (13 years ago)
Author:
nanang
Message:

Fix #1212:

  • Updated pj_register_strerror() to just return PJ_SUCCESS when the same range

and handler is being re-registered.

  • Removed the usage of static flag of error string handler registration in some

modules, which prevent the re-registration of the handler, e.g: in restarting
pjsua, as such flags never got reseted.

Location:
pjproject/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib-util/src/pjlib-util/errno.c

    r3087 r3455  
    2020#include <pjlib-util/errno.h> 
    2121#include <pjlib-util/types.h> 
     22#include <pj/assert.h> 
    2223#include <pj/string.h> 
    2324 
     
    163164PJ_DEF(pj_status_t) pjlib_util_init(void) 
    164165{ 
    165     return pj_register_strerror(PJLIB_UTIL_ERRNO_START,  
    166                                 PJ_ERRNO_SPACE_SIZE,  
    167                                 &pjlib_util_strerror); 
     166    pj_status_t status; 
     167     
     168    status = pj_register_strerror(PJLIB_UTIL_ERRNO_START,  
     169                                  PJ_ERRNO_SPACE_SIZE,  
     170                                  &pjlib_util_strerror); 
     171    pj_assert(status == PJ_SUCCESS); 
     172 
     173    return PJ_SUCCESS; 
    168174} 
  • pjproject/trunk/pjlib/src/pj/errno.c

    r3255 r3455  
    129129            IN_RANGE(start+space-1, err_msg_hnd[i].begin, err_msg_hnd[i].end)) 
    130130        { 
     131            if (err_msg_hnd[i].begin == start &&  
     132                err_msg_hnd[i].end == (start+space) && 
     133                err_msg_hnd[i].strerror == f) 
     134            { 
     135                /* The same range and handler has already been registered */ 
     136                return PJ_SUCCESS; 
     137            } 
     138 
    131139            return PJ_EEXISTS; 
    132140        } 
  • pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c

    r3225 r3455  
    268268/* OpenSSL library initialization counter */ 
    269269static int openssl_init_count; 
    270 static int openssl_reg_strerr; 
    271270 
    272271/* OpenSSL available ciphers */ 
     
    281280static pj_status_t init_openssl(void) 
    282281{ 
     282    pj_status_t status; 
     283 
    283284    if (openssl_init_count) 
    284285        return PJ_SUCCESS; 
     
    287288 
    288289    /* Register error subsystem */ 
    289     if (!openssl_reg_strerr) { 
    290         pj_status_t status; 
    291  
    292         openssl_reg_strerr = 1; 
    293         status = pj_register_strerror(PJ_SSL_ERRNO_START,  
    294                                       PJ_SSL_ERRNO_SPACE_SIZE,  
    295                                       &ssl_strerror); 
    296         pj_assert(status == PJ_SUCCESS); 
    297     } 
     290    status = pj_register_strerror(PJ_SSL_ERRNO_START,  
     291                                  PJ_SSL_ERRNO_SPACE_SIZE,  
     292                                  &ssl_strerror); 
     293    pj_assert(status == PJ_SUCCESS); 
    298294 
    299295    /* Init OpenSSL lib */ 
  • pjproject/trunk/pjmedia/src/pjmedia-audiodev/audiodev.c

    r3440 r3455  
    365365{ 
    366366    unsigned i; 
    367     pj_status_t status = PJ_SUCCESS; 
     367    pj_status_t status; 
    368368 
    369369    /* Allow init() to be called multiple times as long as there is matching 
     
    375375 
    376376    /* Register error subsystem */ 
    377     pj_register_strerror(PJMEDIA_AUDIODEV_ERRNO_START,  
    378                          PJ_ERRNO_SPACE_SIZE,  
    379                          &pjmedia_audiodev_strerror); 
     377    status = pj_register_strerror(PJMEDIA_AUDIODEV_ERRNO_START,  
     378                                  PJ_ERRNO_SPACE_SIZE,  
     379                                  &pjmedia_audiodev_strerror); 
     380    pj_assert(status == PJ_SUCCESS); 
    380381 
    381382    /* Init */ 
  • pjproject/trunk/pjmedia/src/pjmedia/endpoint.c

    r3360 r3455  
    4444 
    4545 
    46 /* Flag to indicate whether pjmedia error subsystem has been registered 
    47  * to pjlib. 
    48  */ 
    49 static int error_subsys_registered; 
    50  
    5146/* Config to control rtpmap inclusion for static payload types */ 
    5247pj_bool_t pjmedia_add_rtpmap_for_static_pt =  
     
    106101    pj_status_t status; 
    107102 
    108     if (!error_subsys_registered) { 
    109         pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE,  
    110                              &pjmedia_strerror); 
    111         error_subsys_registered = 1; 
    112     } 
     103    status = pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE, 
     104                                  &pjmedia_strerror); 
     105    pj_assert(status == PJ_SUCCESS); 
    113106 
    114107    PJ_ASSERT_RETURN(pf && p_endpt, PJ_EINVAL); 
  • pjproject/trunk/pjnath/src/pjnath/errno.c

    r2724 r3455  
    2020#include <pjnath/errno.h> 
    2121#include <pjnath/stun_msg.h> 
     22#include <pj/assert.h> 
    2223#include <pj/log.h> 
    2324#include <pj/string.h> 
     
    177178    status = pj_register_strerror(PJNATH_ERRNO_START, 299,  
    178179                                  &pjnath_strerror); 
    179     if (status != PJ_SUCCESS) 
    180         return status; 
     180    pj_assert(status == PJ_SUCCESS); 
    181181 
    182182    status = pj_register_strerror(PJ_STATUS_FROM_STUN_CODE(300),  
    183183                                  699 - 300,  
    184184                                  &pjnath_strerror2); 
    185     return status; 
     185    pj_assert(status == PJ_SUCCESS); 
     186 
     187    return PJ_SUCCESS; 
    186188} 
    187189 
  • pjproject/trunk/pjsip-apps/src/samples/latency.c

    r2394 r3455  
    169169                           ); 
    170170 
    171     pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE,  
    172                          &pjmedia_strerror); 
     171    status = pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE,  
     172                                  &pjmedia_strerror); 
     173    pj_assert(status == PJ_SUCCESS); 
    173174 
    174175    /* Wav */ 
  • pjproject/trunk/pjsip/src/pjsip-simple/evsub.c

    r3412 r3455  
    288288    }; 
    289289 
    290     pj_register_strerror(PJSIP_SIMPLE_ERRNO_START, PJ_ERRNO_SPACE_SIZE, 
    291                          &pjsipsimple_strerror); 
     290    status = pj_register_strerror(PJSIP_SIMPLE_ERRNO_START, 
     291                                  PJ_ERRNO_SPACE_SIZE, 
     292                                  &pjsipsimple_strerror); 
     293    pj_assert(status == PJ_SUCCESS); 
    292294 
    293295    PJ_ASSERT_RETURN(endpt != NULL, PJ_EINVAL); 
  • pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c

    r3106 r3455  
    118118 
    119119 
    120 /* Specifies whether error subsystem has been registered to pjlib. */ 
    121 static int error_subsys_initialized; 
    122  
    123120/* 
    124121 * This is the global handler for memory allocation failure, for pools that 
     
    426423 
    427424 
    428     if (!error_subsys_initialized) { 
    429         pj_register_strerror(PJSIP_ERRNO_START, PJ_ERRNO_SPACE_SIZE, 
    430                              &pjsip_strerror); 
    431         error_subsys_initialized = 1; 
    432     } 
     425    status = pj_register_strerror(PJSIP_ERRNO_START, PJ_ERRNO_SPACE_SIZE, 
     426                                  &pjsip_strerror); 
     427    pj_assert(status == PJ_SUCCESS); 
    433428 
    434429    PJ_LOG(5, (THIS_FILE, "Creating endpoint instance...")); 
Note: See TracChangeset for help on using the changeset viewer.