Changeset 2894


Ignore:
Timestamp:
Aug 17, 2009 3:59:21 PM (10 years ago)
Author:
nanang
Message:

Ticket #948: Fixed bug Replaces extension stops functioning after the library is restarted, by adding deinit module function and register it into atexit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_replaces.c

    r2394 r2894  
    2828#include <pjsip/sip_util.h> 
    2929#include <pj/assert.h> 
     30#include <pj/log.h> 
    3031#include <pj/pool.h> 
    3132#include <pj/string.h> 
     33 
     34#define THIS_FILE               "sip_replaces.c" 
    3235 
    3336 
     
    5154/* Globals */ 
    5255static pjsip_endpoint *the_endpt; 
     56static pj_bool_t is_initialized; 
    5357 
    5458PJ_DEF(pjsip_replaces_hdr*) pjsip_replaces_hdr_create(pj_pool_t *pool) 
     
    157161} 
    158162 
     163 
     164/* Deinitialize Replaces */ 
     165static void pjsip_replaces_deinit_module(void) 
     166{ 
     167    is_initialized = PJ_FALSE; 
     168} 
     169 
    159170/* 
    160171 * Initialize Replaces support in PJSIP.  
     
    164175    pj_status_t status; 
    165176    const pj_str_t STR_REPLACES = { "replaces", 8 }; 
    166     static pj_bool_t is_initialized; 
    167177 
    168178    the_endpt = endpt; 
     
    180190    status = pjsip_endpt_add_capability(endpt, NULL, PJSIP_H_SUPPORTED, NULL, 
    181191                                        1, &STR_REPLACES); 
     192 
     193    /* Register deinit module to be executed when PJLIB shutdown */ 
     194    if (pj_atexit(&pjsip_replaces_deinit_module) != PJ_SUCCESS) { 
     195        /* Failure to register this function may cause this module won't  
     196         * work properly when the stack is restarted (without quitting  
     197         * application). 
     198         */ 
     199        pj_assert(!"Failed to register Replaces deinit."); 
     200        PJ_LOG(1, (THIS_FILE, "Failed to register Replaces deinit.")); 
     201    } 
    182202 
    183203    is_initialized = PJ_TRUE; 
Note: See TracChangeset for help on using the changeset viewer.