[I've been working through making kamailio build on NetBSD -- thanks for
merging my recent PR with two small fixes.]
In src/Makefile.defs, there is a setting of LOCALBASE, which is
basically a case statement by OS. A few examples:
Linux /usr/local presuambly the tradition /usr/local per autucoonf
FreeBSD /usr/local hijacked by ports system - not traditional /usr/local
NetBSD /usr/pkg pkgsrc puts things here (local is still local)
There is a need for two separate prefixes when building something like
this:
where the software being built should be installed: basically like
--prefix=/foo in autoconf
where things that the software depends on should be found, sort of
what autoconf would use for --with-bar=/baz, so that /baz/include is
added to CPPFLAGS and "-L/baz/lib -R/baz/lib" to LDFLAGS.
I needed to add the C_INCLUDES as
ifeq ($(OS), netbsd)
C_INCLUDES+= -I$(LOCALBASE)/include
since otherwise a libxml2 header is not found (and with the above it
builds fine):
gcc -fPIC -DPIC -g -funroll-loops -Wcast-align -m64 -minline-all-stringops -falign-loops -ftree-vectorize -fno-strict-overflow -mtune=generic -Wall -DNAME='"kamailio"' -DVERSION='"5.4.0-dev3"' -DARCH='"x86_64"' -DOS='netbsd_' -DOS_QUOTED='"netbsd"' -DCOMPILER='"gcc 5.5.0"' -D__CPU_x86_64 -D__OS_netbsd -DVERSIONVAL=5004000 -DCFG_DIR='"/usr/pkg/etc/kamailio/"' -DSHARE_DIR='"/usr/pkg/share/kamailio/"' -DRUN_DIR='"/var/run/kamailio/"' -DPKG_MALLOC -DSHM_MMAP -DDNS_IP_HACK -DUSE_MCAST -DUSE_TCP -DDISABLE_NAGLE -DHAVE_RESOLV_RES -DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLACKLIST -DUSE_NAPTR -DWITH_XAVP -DMEM_JOIN_FREE -DF_MALLOC -DQ_MALLOC -DTLSF_MALLOC -DDBG_SR_MEMORY -DUSE_TLS -DTLS_HOOKS -DUSE_CORE_STATS -DSTATISTICS -DMALLOC_STATS -DUSE_SCTP -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DCC_GCC_LIKE_ASM -DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM -DHAVE_SELECT -I/usr/pkg/include/libxml2 -I/usr/include -DMOD_NAME='"ims_registrar_pcscf"' -c notify.c -o notify.o -MMD -MP
notify.c:38:36: fatal error: libxml2/libxml/globals.h: No such file or directory
Of course, on Linux this issue is usually avoided because everything is
installed with --prefix=/usr which is in te default search path.
So my questions are:
Is LOCALBASE supposed to be where kamailio is built into?
(If so, then /usr/pkg seems like a wrong default on NetBSD, following
the autoconf /usr/local norm, even though pkgsrc builds would pass in
/usr/pkg.)
Or is it where dependencies are?
(If so, why isn't LOCALBASE/include put in cflags?)
If dependencies are supposed to be someplace else, what's the
mechanism to look for them? C_INCLUDES is set to empty, so I can't
pass that in. Shouldn't the plan be explained in INSTALL (and sorry
if I missed it)?
Even a very brief clue would be appreciated, so I can align my changes
with the overall intent.
Thanks,
Greg
Module: kamailio
Branch: master
Commit: 125031daeade9dab5c36b912dda65700d95c4c6a
URL: https://github.com/kamailio/kamailio/commit/125031daeade9dab5c36b912dda6570…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-03-23T17:48:39+01:00
dialog: exposed functions to search dlg and lock table entry
---
Modified: src/modules/dialog/dlg_hash.h
---
Diff: https://github.com/kamailio/kamailio/commit/125031daeade9dab5c36b912dda6570…
Patch: https://github.com/kamailio/kamailio/commit/125031daeade9dab5c36b912dda6570…
---
diff --git a/src/modules/dialog/dlg_hash.h b/src/modules/dialog/dlg_hash.h
index eb933c5acb..ed5cd7bef0 100644
--- a/src/modules/dialog/dlg_hash.h
+++ b/src/modules/dialog/dlg_hash.h
@@ -324,6 +324,18 @@ int dlg_update_rr_set(struct dlg_cell * dlg, unsigned int leg, str *rr);
int dlg_set_toroute(dlg_cell_t *dlg, str *route);
+/*!
+ * \brief Lookup a dialog in the global list
+ *
+ * Note that the caller is responsible for decrementing (or reusing)
+ * the reference counter by one again iff a dialog has been found.
+ * \param h_entry number of the hash table entry
+ * \param h_id id of the hash table entry
+ * \param lmode id if 0, then dlg table entry is unlocked, otherwise is locked
+ * \return dialog structure on success, NULL on failure
+ */
+dlg_cell_t *dlg_lookup_mode(unsigned int h_entry, unsigned int h_id, int lmode);
+
/*!
* \brief Lookup a dialog in the global list
*
@@ -335,6 +347,17 @@ int dlg_set_toroute(dlg_cell_t *dlg, str *route);
*/
dlg_cell_t* dlg_lookup(unsigned int h_entry, unsigned int h_id);
+/*!
+ * \brief Search a dialog in the global list by iuid
+ *
+ * Note that the caller is responsible for decrementing (or reusing)
+ * the reference counter by one again if a dialog has been found.
+ * \param diuid internal unique id per dialog
+ * \param lmode id if 0, then dlg table entry is unlocked, otherwise is locked
+ * \return dialog structure on success, NULL on failure
+ */
+dlg_cell_t* dlg_get_by_iuid_mode(dlg_iuid_t *diuid, int lmode);
+
/*!
* \brief Search and return dialog in the global list by iuid
*
Module: kamailio
Branch: master
Commit: a4f8c0291bfd32752c0c2c323f618c6ac0c91d53
URL: https://github.com/kamailio/kamailio/commit/a4f8c0291bfd32752c0c2c323f618c6…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-03-23T17:36:44+01:00
dialog: functions to search dialog by uuid and keep table entry locked
- helper macros to lock/unlock table entry with dlg cell structure
---
Modified: src/modules/dialog/dlg_hash.c
Modified: src/modules/dialog/dlg_hash.h
---
Diff: https://github.com/kamailio/kamailio/commit/a4f8c0291bfd32752c0c2c323f618c6…
Patch: https://github.com/kamailio/kamailio/commit/a4f8c0291bfd32752c0c2c323f618c6…
---
diff --git a/src/modules/dialog/dlg_hash.c b/src/modules/dialog/dlg_hash.c
index 4e0e28b788..5557e87574 100644
--- a/src/modules/dialog/dlg_hash.c
+++ b/src/modules/dialog/dlg_hash.c
@@ -762,9 +762,10 @@ int dlg_update_rr_set(struct dlg_cell * dlg, unsigned int leg, str *rr)
* the reference counter by one again iff a dialog has been found.
* \param h_entry number of the hash table entry
* \param h_id id of the hash table entry
+ * \param lmode id if 0, then dlg table entry is unlocked, otherwise is locked
* \return dialog structure on success, NULL on failure
*/
-dlg_cell_t *dlg_lookup( unsigned int h_entry, unsigned int h_id)
+dlg_cell_t *dlg_lookup_mode(unsigned int h_entry, unsigned int h_id, int lmode)
{
dlg_cell_t *dlg;
dlg_entry_t *d_entry;
@@ -777,24 +778,59 @@ dlg_cell_t *dlg_lookup( unsigned int h_entry, unsigned int h_id)
d_entry = &(d_table->entries[h_entry]);
- dlg_lock( d_table, d_entry);
+ dlg_lock(d_table, d_entry);
for( dlg=d_entry->first ; dlg ; dlg=dlg->next ) {
if (dlg->h_id == h_id) {
ref_dlg_unsafe(dlg, 1);
- dlg_unlock( d_table, d_entry);
+ if (likely(lmode == 0)) {
+ dlg_unlock(d_table, d_entry);
+ }
LM_DBG("dialog id=%u found on entry %u\n", h_id, h_entry);
return dlg;
}
}
- dlg_unlock( d_table, d_entry);
+ dlg_unlock(d_table, d_entry);
not_found:
LM_DBG("no dialog id=%u found on entry %u\n", h_id, h_entry);
return 0;
}
+/*!
+ * \brief Lookup a dialog in the global list
+ *
+ * Note that the caller is responsible for decrementing (or reusing)
+ * the reference counter by one again iff a dialog has been found.
+ * \param h_entry number of the hash table entry
+ * \param h_id id of the hash table entry
+ * \return dialog structure on success, NULL on failure
+ */
+dlg_cell_t *dlg_lookup(unsigned int h_entry, unsigned int h_id)
+{
+ return dlg_lookup_mode(h_entry, h_id, 0);
+}
+
+/*!
+ * \brief Search a dialog in the global list by iuid
+ *
+ * Note that the caller is responsible for decrementing (or reusing)
+ * the reference counter by one again if a dialog has been found.
+ * \param diuid internal unique id per dialog
+ * \param lmode id if 0, then dlg table entry is unlocked, otherwise is locked
+ * \return dialog structure on success, NULL on failure
+ */
+dlg_cell_t* dlg_get_by_iuid_mode(dlg_iuid_t *diuid, int lmode)
+{
+ if(diuid==NULL)
+ return NULL;
+ if(diuid->h_id==0)
+ return NULL;
+ /* dlg ref counter is increased by next line */
+ return dlg_lookup_mode(diuid->h_entry, diuid->h_id, lmode);
+}
+
/*!
* \brief Search a dialog in the global list by iuid
*
@@ -810,7 +846,7 @@ dlg_cell_t* dlg_get_by_iuid(dlg_iuid_t *diuid)
if(diuid->h_id==0)
return NULL;
/* dlg ref counter is increased by next line */
- return dlg_lookup(diuid->h_entry, diuid->h_id);
+ return dlg_lookup_mode(diuid->h_entry, diuid->h_id, 0);
}
/*!
diff --git a/src/modules/dialog/dlg_hash.h b/src/modules/dialog/dlg_hash.h
index 5ecf13f871..eb933c5acb 100644
--- a/src/modules/dialog/dlg_hash.h
+++ b/src/modules/dialog/dlg_hash.h
@@ -201,6 +201,21 @@ extern dlg_table_t *d_table;
} \
} while(0)
+/*!
+ * \brief Set a dialog lock (re-entrant)
+ * \param _dlg dialog cell
+ */
+#define dlg_cell_lock(_dlg) \
+ dlg_lock(d_table, &(d_table->entries[(_dlg)->h_entry]))
+
+/*!
+ * \brief Set a dialog lock (re-entrant)
+ * \param _dlg dialog cell
+ */
+#define dlg_cell_unlock(_dlg) \
+ dlg_unlock(d_table, &(d_table->entries[(_dlg)->h_entry]))
+
+
/*!
* \brief Unlink a dialog from the list without locking
* \see unref_dlg_unsafe