Ver Fonte

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
Henning Westerholt há 16 anos atrás
pai
commit
020559fd87
2 ficheiros alterados com 51 adições e 61 exclusões
  1. 36 18
      modules_k/dialog/dlg_hash.c
  2. 15 43
      modules_k/dialog/dlg_hash.h

+ 36 - 18
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)
 
 
 
 
 /*!
 /*!

+ 15 - 43
modules_k/dialog/dlg_hash.h

@@ -163,7 +163,21 @@ extern struct dlg_cell  *current_dlg_pointer;
  * \param d_entry unlinked entry
  * \param d_entry unlinked entry
  * \param dlg unlinked dialog
  * \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;
+}
 
 
 
 
 /*!
 /*!
@@ -173,48 +187,6 @@ inline void unlink_unsafe_dlg(struct dlg_entry *d_entry, struct dlg_cell *dlg);
 inline void destroy_dlg(struct dlg_cell *dlg);
 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
  * \brief Initialize the global dialog table
  * \param size size of the table
  * \param size size of the table