res_pjsip: Add support for building against pjproject with SIP transaction group lock support.

SIP transaction group lock support has been backported into our pjproject. Since the code
now internally uses a group lock the code is now changed to unlock it if present. Note
that the act of finding the transaction is what actually returns it locked.

For further information about group locks check out the wiki page at:
http://trac.pjsip.org/repos/wiki/Group_Lock

(issue ASTERISK-22818)
Reported by: Matt Jordan


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@402864 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2013-11-16 13:44:47 +00:00
parent b72cc1c96f
commit 18a2f38b76
4 changed files with 134 additions and 1 deletions

123
configure vendored
View File

@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.ac Revision: 400384 .
# From configure.ac Revision: 400769 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for asterisk trunk.
#
@@ -899,6 +899,10 @@ PBX_PORTAUDIO
PORTAUDIO_DIR
PORTAUDIO_INCLUDE
PORTAUDIO_LIB
PBX_PJ_TRANSACTION_GRP_LOCK
PJ_TRANSACTION_GRP_LOCK_DIR
PJ_TRANSACTION_GRP_LOCK_INCLUDE
PJ_TRANSACTION_GRP_LOCK_LIB
PBX_POPT
POPT_DIR
POPT_INCLUDE
@@ -10151,6 +10155,18 @@ fi
PJ_TRANSACTION_GRP_LOCK_DESCRIP="PJSIP Transaction Group Lock Support"
PJ_TRANSACTION_GRP_LOCK_DIR=${pjsip_DIR}
PBX_PJ_TRANSACTION_GRP_LOCK=0
PORTAUDIO_DESCRIP="PortAudio"
PORTAUDIO_OPTION="portaudio"
PBX_PORTAUDIO=0
@@ -23617,6 +23633,111 @@ fi
if test "x${PBX_PJ_TRANSACTION_GRP_LOCK}" != "x1" -a "${USE_PJ_TRANSACTION_GRP_LOCK}" != "no"; then
pbxlibdir=""
# if --with-PJ_TRANSACTION_GRP_LOCK=DIR has been specified, use it.
if test "x${PJ_TRANSACTION_GRP_LOCK_DIR}" != "x"; then
if test -d ${PJ_TRANSACTION_GRP_LOCK_DIR}/lib; then
pbxlibdir="-L${PJ_TRANSACTION_GRP_LOCK_DIR}/lib"
else
pbxlibdir="-L${PJ_TRANSACTION_GRP_LOCK_DIR}"
fi
fi
pbxfuncname="pjsip_tsx_create_uac2"
if test "x${pbxfuncname}" = "x" ; then # empty lib, assume only headers
AST_PJ_TRANSACTION_GRP_LOCK_FOUND=yes
else
ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} "
as_ac_Lib=`$as_echo "ac_cv_lib_pjsip_${pbxfuncname}" | $as_tr_sh`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${pbxfuncname} in -lpjsip" >&5
$as_echo_n "checking for ${pbxfuncname} in -lpjsip... " >&6; }
if eval \${$as_ac_Lib+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpjsip ${pbxlibdir} $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char ${pbxfuncname} ();
int
main ()
{
return ${pbxfuncname} ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
eval "$as_ac_Lib=yes"
else
eval "$as_ac_Lib=no"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
eval ac_res=\$$as_ac_Lib
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
AST_PJ_TRANSACTION_GRP_LOCK_FOUND=yes
else
AST_PJ_TRANSACTION_GRP_LOCK_FOUND=no
fi
CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
fi
# now check for the header.
if test "${AST_PJ_TRANSACTION_GRP_LOCK_FOUND}" = "yes"; then
PJ_TRANSACTION_GRP_LOCK_LIB="${pbxlibdir} -lpjsip "
# if --with-PJ_TRANSACTION_GRP_LOCK=DIR has been specified, use it.
if test "x${PJ_TRANSACTION_GRP_LOCK_DIR}" != "x"; then
PJ_TRANSACTION_GRP_LOCK_INCLUDE="-I${PJ_TRANSACTION_GRP_LOCK_DIR}/include"
fi
PJ_TRANSACTION_GRP_LOCK_INCLUDE="${PJ_TRANSACTION_GRP_LOCK_INCLUDE} "
if test "xpjsip.h" = "x" ; then # no header, assume found
PJ_TRANSACTION_GRP_LOCK_HEADER_FOUND="1"
else # check for the header
ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS} ${PJ_TRANSACTION_GRP_LOCK_INCLUDE}"
ac_fn_c_check_header_mongrel "$LINENO" "pjsip.h" "ac_cv_header_pjsip_h" "$ac_includes_default"
if test "x$ac_cv_header_pjsip_h" = xyes; then :
PJ_TRANSACTION_GRP_LOCK_HEADER_FOUND=1
else
PJ_TRANSACTION_GRP_LOCK_HEADER_FOUND=0
fi
CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
fi
if test "x${PJ_TRANSACTION_GRP_LOCK_HEADER_FOUND}" = "x0" ; then
PJ_TRANSACTION_GRP_LOCK_LIB=""
PJ_TRANSACTION_GRP_LOCK_INCLUDE=""
else
if test "x${pbxfuncname}" = "x" ; then # only checking headers -> no library
PJ_TRANSACTION_GRP_LOCK_LIB=""
fi
PBX_PJ_TRANSACTION_GRP_LOCK=1
cat >>confdefs.h <<_ACEOF
#define HAVE_PJ_TRANSACTION_GRP_LOCK 1
_ACEOF
fi
fi
fi
if test "x${PBX_POPT}" != "x1" -a "${USE_POPT}" != "no"; then
pbxlibdir=""
# if --with-POPT=DIR has been specified, use it.

View File

@@ -433,6 +433,7 @@ AST_EXT_LIB_SETUP([OSS], [Open Sound System], [oss])
AST_EXT_LIB_SETUP([PGSQL], [PostgreSQL], [postgres])
AST_EXT_LIB_SETUP([PJPROJECT], [PJPROJECT], [pjproject])
AST_EXT_LIB_SETUP([POPT], [popt], [popt])
AST_EXT_LIB_SETUP_OPTIONAL([PJ_TRANSACTION_GRP_LOCK], [PJSIP Transaction Group Lock Support], [pjsip])
AST_EXT_LIB_SETUP([PORTAUDIO], [PortAudio], [portaudio])
AST_EXT_LIB_SETUP([PRI], [ISDN PRI], [pri])
AST_EXT_LIB_SETUP_OPTIONAL([PRI_L2_PERSISTENCE], [ISDN Layer 2 persistence option], [PRI], [pri])
@@ -2015,6 +2016,8 @@ fi
AST_PKG_CONFIG_CHECK([PJPROJECT], [libpjproject])
AST_EXT_LIB_CHECK([PJ_TRANSACTION_GRP_LOCK], [pjsip], [pjsip_tsx_create_uac2], [pjsip.h])
AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
AST_EXT_LIB_CHECK([PORTAUDIO], [portaudio], [Pa_GetDeviceCount], [portaudio.h])

View File

@@ -569,6 +569,10 @@
/* Define if your system has the PJPROJECT libraries. */
#undef HAVE_PJPROJECT
/* Define to 1 if pjsip has the PJSIP Transaction Group Lock Support feature.
*/
#undef HAVE_PJ_TRANSACTION_GRP_LOCK
/* Define to 1 if your system defines IP_PKTINFO. */
#undef HAVE_PKTINFO

View File

@@ -134,7 +134,12 @@ static pjsip_dialog *find_dialog(pjsip_rx_data *rdata)
}
dlg = pjsip_tsx_get_dlg(tsx);
#ifdef HAVE_PJ_TRANSACTION_GRP_LOCK
pj_grp_lock_release(tsx->grp_lock);
#else
pj_mutex_unlock(tsx->mutex);
#endif
if (!dlg) {
return NULL;