Module: sip-router Branch: master Commit: 020559fd87eca6605371be4e9d21778b6285f6f6 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=020559fd...
Author: Henning Westerholt henning.westerholt@1und1.de Committer: Henning Westerholt henning.westerholt@1und1.de Date: Sun May 3 20:07:53 2009 +0200
small refactoring to decrease exported symbols signature
- move unlink_unsafe_dlg function to header file, make them static - move unref_dlg_unsafe, ref_dlg_unsafe macros to implementation file
---
modules_k/dialog/dlg_hash.c | 54 ++++++++++++++++++++++++++------------- modules_k/dialog/dlg_hash.h | 58 +++++++++++------------------------------- 2 files changed, 51 insertions(+), 61 deletions(-)
diff --git a/modules_k/dialog/dlg_hash.c b/modules_k/dialog/dlg_hash.c index a699e72..65e5876 100644 --- a/modules_k/dialog/dlg_hash.c +++ b/modules_k/dialog/dlg_hash.c @@ -490,27 +490,45 @@ void link_dlg(struct dlg_cell *dlg, int n)
/*! - * \brief Unlink a dialog from the list without locking - * \see unref_dlg_unsafe - * \param d_entry unlinked entry - * \param dlg unlinked dialog + * \brief Reference a dialog without locking + * \param _dlg dialog + * \param _cnt increment for the reference counter */ -inline void unlink_unsafe_dlg(struct dlg_entry *d_entry, - struct dlg_cell *dlg) -{ - if (dlg->next) - dlg->next->prev = dlg->prev; - else - d_entry->last = dlg->prev; - if (dlg->prev) - dlg->prev->next = dlg->next; - else - d_entry->first = dlg->next; +#define ref_dlg_unsafe(_dlg,_cnt) \ + do { \ + (_dlg)->ref += (_cnt); \ + LM_DBG("ref dlg %p with %d -> %d\n", \ + (_dlg),(_cnt),(_dlg)->ref); \ + }while(0)
- dlg->next = dlg->prev = 0;
- return; -} +/*! + * \brief Unreference a dialog without locking + * \param _dlg dialog + * \param _cnt decrement for the reference counter + */ +#define unref_dlg_unsafe(_dlg,_cnt,_d_entry) \ + do { \ + (_dlg)->ref -= (_cnt); \ + LM_DBG("unref dlg %p with %d -> %d\n",\ + (_dlg),(_cnt),(_dlg)->ref);\ + if ((_dlg)->ref<0) {\ + LM_CRIT("bogus ref %d with cnt %d for dlg %p [%u:%u] "\ + "with clid '%.*s' and tags '%.*s' '%.*s'\n",\ + (_dlg)->ref, _cnt, _dlg,\ + (_dlg)->h_entry, (_dlg)->h_id,\ + (_dlg)->callid.len, (_dlg)->callid.s,\ + (_dlg)->tag[DLG_CALLER_LEG].len,\ + (_dlg)->tag[DLG_CALLER_LEG].s,\ + (_dlg)->tag[DLG_CALLEE_LEG].len,\ + (_dlg)->tag[DLG_CALLEE_LEG].s); \ + }\ + if ((_dlg)->ref<=0) { \ + unlink_unsafe_dlg( _d_entry, _dlg);\ + LM_DBG("ref <=0 for dialog %p\n",_dlg);\ + destroy_dlg(_dlg);\ + }\ + }while(0)
/*! diff --git a/modules_k/dialog/dlg_hash.h b/modules_k/dialog/dlg_hash.h index e717a2b..e01c311 100644 --- a/modules_k/dialog/dlg_hash.h +++ b/modules_k/dialog/dlg_hash.h @@ -163,7 +163,21 @@ extern struct dlg_cell *current_dlg_pointer; * \param d_entry unlinked entry * \param dlg unlinked dialog */ -inline void unlink_unsafe_dlg(struct dlg_entry *d_entry, struct dlg_cell *dlg); +static inline void unlink_unsafe_dlg(struct dlg_entry *d_entry, struct dlg_cell *dlg) +{ + if (dlg->next) + dlg->next->prev = dlg->prev; + else + d_entry->last = dlg->prev; + if (dlg->prev) + dlg->prev->next = dlg->next; + else + d_entry->first = dlg->next; + + dlg->next = dlg->prev = 0; + + return; +}
/*! @@ -174,48 +188,6 @@ inline void destroy_dlg(struct dlg_cell *dlg);
/*! - * \brief Reference a dialog without locking - * \param _dlg dialog - * \param _cnt increment for the reference counter - */ -#define ref_dlg_unsafe(_dlg,_cnt) \ - do { \ - (_dlg)->ref += (_cnt); \ - LM_DBG("ref dlg %p with %d -> %d\n", \ - (_dlg),(_cnt),(_dlg)->ref); \ - }while(0) - - -/*! - * \brief Unreference a dialog without locking - * \param _dlg dialog - * \param _cnt decrement for the reference counter - */ -#define unref_dlg_unsafe(_dlg,_cnt,_d_entry) \ - do { \ - (_dlg)->ref -= (_cnt); \ - LM_DBG("unref dlg %p with %d -> %d\n",\ - (_dlg),(_cnt),(_dlg)->ref);\ - if ((_dlg)->ref<0) {\ - LM_CRIT("bogus ref %d with cnt %d for dlg %p [%u:%u] "\ - "with clid '%.*s' and tags '%.*s' '%.*s'\n",\ - (_dlg)->ref, _cnt, _dlg,\ - (_dlg)->h_entry, (_dlg)->h_id,\ - (_dlg)->callid.len, (_dlg)->callid.s,\ - (_dlg)->tag[DLG_CALLER_LEG].len,\ - (_dlg)->tag[DLG_CALLER_LEG].s,\ - (_dlg)->tag[DLG_CALLEE_LEG].len,\ - (_dlg)->tag[DLG_CALLEE_LEG].s); \ - }\ - if ((_dlg)->ref<=0) { \ - unlink_unsafe_dlg( _d_entry, _dlg);\ - LM_DBG("ref <=0 for dialog %p\n",_dlg);\ - destroy_dlg(_dlg);\ - }\ - }while(0) - - -/*! * \brief Initialize the global dialog table * \param size size of the table * \return 0 on success, -1 on failure