diff options
author | Nanang Izzuddin <nanang@teluu.com> | 2009-08-17 15:59:21 +0000 |
---|---|---|
committer | Nanang Izzuddin <nanang@teluu.com> | 2009-08-17 15:59:21 +0000 |
commit | d32ffc67d3b2870cabc5ea6fd45bd529629a5413 (patch) | |
tree | 3293cd89d6d1e84959f41b09da1609379fa2263f /pjsip/src | |
parent | 13f50ed498f48ebcb51699621a6e51d877754867 (diff) |
Ticket #948: Fixed bug Replaces extension stops functioning after the library is restarted, by adding deinit module function and register it into atexit.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2894 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src')
-rw-r--r-- | pjsip/src/pjsip-ua/sip_replaces.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/pjsip/src/pjsip-ua/sip_replaces.c b/pjsip/src/pjsip-ua/sip_replaces.c index ae60fca8..21b91453 100644 --- a/pjsip/src/pjsip-ua/sip_replaces.c +++ b/pjsip/src/pjsip-ua/sip_replaces.c @@ -27,9 +27,12 @@ #include <pjsip/sip_ua_layer.h> #include <pjsip/sip_util.h> #include <pj/assert.h> +#include <pj/log.h> #include <pj/pool.h> #include <pj/string.h> +#define THIS_FILE "sip_replaces.c" + /* * Replaces header vptr. @@ -50,6 +53,7 @@ static pjsip_hdr_vptr replaces_hdr_vptr = /* Globals */ static pjsip_endpoint *the_endpt; +static pj_bool_t is_initialized; PJ_DEF(pjsip_replaces_hdr*) pjsip_replaces_hdr_create(pj_pool_t *pool) { @@ -156,6 +160,13 @@ static pjsip_hdr *parse_hdr_replaces(pjsip_parse_ctx *ctx) return (pjsip_hdr*)hdr; } + +/* Deinitialize Replaces */ +static void pjsip_replaces_deinit_module(void) +{ + is_initialized = PJ_FALSE; +} + /* * Initialize Replaces support in PJSIP. */ @@ -163,7 +174,6 @@ PJ_DEF(pj_status_t) pjsip_replaces_init_module(pjsip_endpoint *endpt) { pj_status_t status; const pj_str_t STR_REPLACES = { "replaces", 8 }; - static pj_bool_t is_initialized; the_endpt = endpt; @@ -180,6 +190,16 @@ PJ_DEF(pj_status_t) pjsip_replaces_init_module(pjsip_endpoint *endpt) status = pjsip_endpt_add_capability(endpt, NULL, PJSIP_H_SUPPORTED, NULL, 1, &STR_REPLACES); + /* Register deinit module to be executed when PJLIB shutdown */ + if (pj_atexit(&pjsip_replaces_deinit_module) != PJ_SUCCESS) { + /* Failure to register this function may cause this module won't + * work properly when the stack is restarted (without quitting + * application). + */ + pj_assert(!"Failed to register Replaces deinit."); + PJ_LOG(1, (THIS_FILE, "Failed to register Replaces deinit.")); + } + is_initialized = PJ_TRUE; return PJ_SUCCESS; } |