summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pjlib-util/src/pjlib-util/errno.c12
-rw-r--r--pjlib/src/pj/errno.c8
-rw-r--r--pjlib/src/pj/ssl_sock_ossl.c16
-rw-r--r--pjmedia/src/pjmedia-audiodev/audiodev.c9
-rw-r--r--pjmedia/src/pjmedia/endpoint.c13
-rw-r--r--pjnath/src/pjnath/errno.c8
-rw-r--r--pjsip-apps/src/samples/latency.c5
-rw-r--r--pjsip/src/pjsip-simple/evsub.c6
-rw-r--r--pjsip/src/pjsip/sip_endpoint.c11
9 files changed, 46 insertions, 42 deletions
diff --git a/pjlib-util/src/pjlib-util/errno.c b/pjlib-util/src/pjlib-util/errno.c
index 9e726d12..7594431b 100644
--- a/pjlib-util/src/pjlib-util/errno.c
+++ b/pjlib-util/src/pjlib-util/errno.c
@@ -19,6 +19,7 @@
*/
#include <pjlib-util/errno.h>
#include <pjlib-util/types.h>
+#include <pj/assert.h>
#include <pj/string.h>
@@ -162,7 +163,12 @@ pj_str_t pjlib_util_strerror(pj_status_t statcode,
PJ_DEF(pj_status_t) pjlib_util_init(void)
{
- return pj_register_strerror(PJLIB_UTIL_ERRNO_START,
- PJ_ERRNO_SPACE_SIZE,
- &pjlib_util_strerror);
+ pj_status_t status;
+
+ status = pj_register_strerror(PJLIB_UTIL_ERRNO_START,
+ PJ_ERRNO_SPACE_SIZE,
+ &pjlib_util_strerror);
+ pj_assert(status == PJ_SUCCESS);
+
+ return PJ_SUCCESS;
}
diff --git a/pjlib/src/pj/errno.c b/pjlib/src/pj/errno.c
index e36b3266..40ac9779 100644
--- a/pjlib/src/pj/errno.c
+++ b/pjlib/src/pj/errno.c
@@ -128,6 +128,14 @@ PJ_DEF(pj_status_t) pj_register_strerror( pj_status_t start,
if (IN_RANGE(start, err_msg_hnd[i].begin, err_msg_hnd[i].end) ||
IN_RANGE(start+space-1, err_msg_hnd[i].begin, err_msg_hnd[i].end))
{
+ if (err_msg_hnd[i].begin == start &&
+ err_msg_hnd[i].end == (start+space) &&
+ err_msg_hnd[i].strerror == f)
+ {
+ /* The same range and handler has already been registered */
+ return PJ_SUCCESS;
+ }
+
return PJ_EEXISTS;
}
}
diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c
index 97458835..98888906 100644
--- a/pjlib/src/pj/ssl_sock_ossl.c
+++ b/pjlib/src/pj/ssl_sock_ossl.c
@@ -267,7 +267,6 @@ static pj_str_t ssl_strerror(pj_status_t status,
/* OpenSSL library initialization counter */
static int openssl_init_count;
-static int openssl_reg_strerr;
/* OpenSSL available ciphers */
static pj_ssl_cipher openssl_ciphers[100];
@@ -280,21 +279,18 @@ static int sslsock_idx;
/* Initialize OpenSSL */
static pj_status_t init_openssl(void)
{
+ pj_status_t status;
+
if (openssl_init_count)
return PJ_SUCCESS;
openssl_init_count = 1;
/* Register error subsystem */
- if (!openssl_reg_strerr) {
- pj_status_t status;
-
- openssl_reg_strerr = 1;
- status = pj_register_strerror(PJ_SSL_ERRNO_START,
- PJ_SSL_ERRNO_SPACE_SIZE,
- &ssl_strerror);
- pj_assert(status == PJ_SUCCESS);
- }
+ status = pj_register_strerror(PJ_SSL_ERRNO_START,
+ PJ_SSL_ERRNO_SPACE_SIZE,
+ &ssl_strerror);
+ pj_assert(status == PJ_SUCCESS);
/* Init OpenSSL lib */
SSL_library_init();
diff --git a/pjmedia/src/pjmedia-audiodev/audiodev.c b/pjmedia/src/pjmedia-audiodev/audiodev.c
index 26288616..1614955d 100644
--- a/pjmedia/src/pjmedia-audiodev/audiodev.c
+++ b/pjmedia/src/pjmedia-audiodev/audiodev.c
@@ -364,7 +364,7 @@ static void deinit_driver(unsigned drv_idx)
PJ_DEF(pj_status_t) pjmedia_aud_subsys_init(pj_pool_factory *pf)
{
unsigned i;
- pj_status_t status = PJ_SUCCESS;
+ pj_status_t status;
/* Allow init() to be called multiple times as long as there is matching
* number of shutdown().
@@ -374,9 +374,10 @@ PJ_DEF(pj_status_t) pjmedia_aud_subsys_init(pj_pool_factory *pf)
}
/* Register error subsystem */
- pj_register_strerror(PJMEDIA_AUDIODEV_ERRNO_START,
- PJ_ERRNO_SPACE_SIZE,
- &pjmedia_audiodev_strerror);
+ status = pj_register_strerror(PJMEDIA_AUDIODEV_ERRNO_START,
+ PJ_ERRNO_SPACE_SIZE,
+ &pjmedia_audiodev_strerror);
+ pj_assert(status == PJ_SUCCESS);
/* Init */
aud_subsys.pf = pf;
diff --git a/pjmedia/src/pjmedia/endpoint.c b/pjmedia/src/pjmedia/endpoint.c
index 8f781796..bb7929df 100644
--- a/pjmedia/src/pjmedia/endpoint.c
+++ b/pjmedia/src/pjmedia/endpoint.c
@@ -43,11 +43,6 @@ static const pj_str_t STR_SENDRECV = { "sendrecv", 8 };
-/* Flag to indicate whether pjmedia error subsystem has been registered
- * to pjlib.
- */
-static int error_subsys_registered;
-
/* Config to control rtpmap inclusion for static payload types */
pj_bool_t pjmedia_add_rtpmap_for_static_pt =
PJMEDIA_ADD_RTPMAP_FOR_STATIC_PT;
@@ -105,11 +100,9 @@ PJ_DEF(pj_status_t) pjmedia_endpt_create(pj_pool_factory *pf,
unsigned i;
pj_status_t status;
- if (!error_subsys_registered) {
- pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
- &pjmedia_strerror);
- error_subsys_registered = 1;
- }
+ status = pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
+ &pjmedia_strerror);
+ pj_assert(status == PJ_SUCCESS);
PJ_ASSERT_RETURN(pf && p_endpt, PJ_EINVAL);
PJ_ASSERT_RETURN(worker_cnt <= MAX_THREADS, PJ_EINVAL);
diff --git a/pjnath/src/pjnath/errno.c b/pjnath/src/pjnath/errno.c
index 1656ce33..2cf840e9 100644
--- a/pjnath/src/pjnath/errno.c
+++ b/pjnath/src/pjnath/errno.c
@@ -19,6 +19,7 @@
*/
#include <pjnath/errno.h>
#include <pjnath/stun_msg.h>
+#include <pj/assert.h>
#include <pj/log.h>
#include <pj/string.h>
@@ -176,13 +177,14 @@ PJ_DEF(pj_status_t) pjnath_init(void)
status = pj_register_strerror(PJNATH_ERRNO_START, 299,
&pjnath_strerror);
- if (status != PJ_SUCCESS)
- return status;
+ pj_assert(status == PJ_SUCCESS);
status = pj_register_strerror(PJ_STATUS_FROM_STUN_CODE(300),
699 - 300,
&pjnath_strerror2);
- return status;
+ pj_assert(status == PJ_SUCCESS);
+
+ return PJ_SUCCESS;
}
diff --git a/pjsip-apps/src/samples/latency.c b/pjsip-apps/src/samples/latency.c
index 90c17216..92d3d7b1 100644
--- a/pjsip-apps/src/samples/latency.c
+++ b/pjsip-apps/src/samples/latency.c
@@ -168,8 +168,9 @@ int main(int argc, char *argv[])
NULL /* callback on error */
);
- pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
- &pjmedia_strerror);
+ status = pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
+ &pjmedia_strerror);
+ pj_assert(status == PJ_SUCCESS);
/* Wav */
status = pjmedia_wav_player_port_create( pool, /* memory pool */
diff --git a/pjsip/src/pjsip-simple/evsub.c b/pjsip/src/pjsip-simple/evsub.c
index bf26a3db..dc662aa6 100644
--- a/pjsip/src/pjsip-simple/evsub.c
+++ b/pjsip/src/pjsip-simple/evsub.c
@@ -287,8 +287,10 @@ PJ_DEF(pj_status_t) pjsip_evsub_init_module(pjsip_endpoint *endpt)
{ "NOTIFY", 6}
};
- pj_register_strerror(PJSIP_SIMPLE_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
- &pjsipsimple_strerror);
+ status = pj_register_strerror(PJSIP_SIMPLE_ERRNO_START,
+ PJ_ERRNO_SPACE_SIZE,
+ &pjsipsimple_strerror);
+ pj_assert(status == PJ_SUCCESS);
PJ_ASSERT_RETURN(endpt != NULL, PJ_EINVAL);
PJ_ASSERT_RETURN(mod_evsub.mod.id == -1, PJ_EINVALIDOP);
diff --git a/pjsip/src/pjsip/sip_endpoint.c b/pjsip/src/pjsip/sip_endpoint.c
index e0fe4f08..3a632885 100644
--- a/pjsip/src/pjsip/sip_endpoint.c
+++ b/pjsip/src/pjsip/sip_endpoint.c
@@ -117,9 +117,6 @@ void deinit_sip_parser(void);
pj_status_t pjsip_tel_uri_subsys_init(void);
-/* Specifies whether error subsystem has been registered to pjlib. */
-static int error_subsys_initialized;
-
/*
* This is the global handler for memory allocation failure, for pools that
* are created by the endpoint (by default, all pools ARE allocated by
@@ -425,11 +422,9 @@ PJ_DEF(pj_status_t) pjsip_endpt_create(pj_pool_factory *pf,
pj_lock_t *lock = NULL;
- if (!error_subsys_initialized) {
- pj_register_strerror(PJSIP_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
- &pjsip_strerror);
- error_subsys_initialized = 1;
- }
+ status = pj_register_strerror(PJSIP_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
+ &pjsip_strerror);
+ pj_assert(status == PJ_SUCCESS);
PJ_LOG(5, (THIS_FILE, "Creating endpoint instance..."));