[svn-commits] branch 1.2 r29732 - in /branches/1.2: ./ apps/
include/asterisk/ res/
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Tue May 23 10:15:24 MST 2006
Author: kpfleming
Date: Tue May 23 12:15:23 2006
New Revision: 29732
URL: http://svn.digium.com/view/asterisk?rev=29732&view=rev
Log:
backport some mutex initialization and linked list handling fixes from trunk
Modified:
branches/1.2/apps/app_sql_postgres.c
branches/1.2/dnsmgr.c
branches/1.2/include/asterisk/linkedlists.h
branches/1.2/include/asterisk/lock.h
branches/1.2/pbx.c
branches/1.2/res/res_features.c
Modified: branches/1.2/apps/app_sql_postgres.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/apps/app_sql_postgres.c?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- branches/1.2/apps/app_sql_postgres.c (original)
+++ branches/1.2/apps/app_sql_postgres.c Tue May 23 12:15:23 2006
@@ -132,7 +132,7 @@
AST_LIST_ENTRY(ast_PGSQL_id) entries;
} *ast_PGSQL_id;
-AST_LIST_HEAD(PGSQLidshead,ast_PGSQL_id) PGSQLidshead;
+static AST_LIST_HEAD_STATIC(PGSQLidshead,ast_PGSQL_id);
static void *find_identifier(int identifier,int identifier_type) {
struct PGSQLidshead *headp;
@@ -551,11 +551,6 @@
int load_module(void)
{
- struct PGSQLidshead *headp;
-
- headp=&PGSQLidshead;
-
- AST_LIST_HEAD_INIT(headp);
return ast_register_application(app, PGSQL_exec, synopsis, descrip);
}
Modified: branches/1.2/dnsmgr.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/dnsmgr.c?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- branches/1.2/dnsmgr.c (original)
+++ branches/1.2/dnsmgr.c Tue May 23 12:15:23 2006
@@ -57,7 +57,7 @@
char name[1];
};
-static AST_LIST_HEAD(entry_list, ast_dnsmgr_entry) entry_list;
+static AST_LIST_HEAD_STATIC(entry_list, ast_dnsmgr_entry);
AST_MUTEX_DEFINE_STATIC(refresh_lock);
@@ -289,7 +289,6 @@
ast_log(LOG_ERROR, "Unable to create schedule context.\n");
return -1;
}
- AST_LIST_HEAD_INIT(&entry_list);
ast_cli_register(&cli_reload);
ast_cli_register(&cli_status);
return do_reload(1);
Modified: branches/1.2/include/asterisk/linkedlists.h
URL: http://svn.digium.com/view/asterisk/branches/1.2/include/asterisk/linkedlists.h?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- branches/1.2/include/asterisk/linkedlists.h (original)
+++ branches/1.2/include/asterisk/linkedlists.h Tue May 23 12:15:23 2006
@@ -101,6 +101,23 @@
}
/*!
+ \brief Defines initial values for a declaration of AST_LIST_HEAD
+*/
+#define AST_LIST_HEAD_INIT_VALUE { \
+ .first = NULL, \
+ .last = NULL, \
+ .lock = AST_MUTEX_INIT_VALUE, \
+ }
+
+/*!
+ \brief Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK
+*/
+#define AST_LIST_HEAD_NOLOCK_INIT_VALUE { \
+ .first = NULL, \
+ .last = NULL, \
+ }
+
+/*!
\brief Defines a structure to be used to hold a list of specified type, statically initialized.
\param name This will be the name of the defined structure.
\param type This is the type of each list entry.
@@ -122,11 +139,18 @@
struct type *first; \
struct type *last; \
ast_mutex_t lock; \
-} name = { \
- .first = NULL, \
- .last = NULL, \
- .lock = AST_MUTEX_INIT_VALUE, \
-};
+} name = AST_LIST_HEAD_INIT_VALUE
+
+/*!
+ \brief Defines a structure to be used to hold a list of specified type, statically initialized.
+
+ This is the same as AST_LIST_HEAD_STATIC, except without the lock included.
+*/
+#define AST_LIST_HEAD_NOLOCK_STATIC(name, type) \
+struct name { \
+ struct type *first; \
+ struct type *last; \
+} name = AST_LIST_HEAD_NOLOCK_INIT_VALUE
/*!
\brief Initializes a list head structure with a specified first entry.
@@ -182,6 +206,12 @@
\param head This is a pointer to the list head structure
*/
#define AST_LIST_FIRST(head) ((head)->first)
+
+/*!
+ \brief Returns the last entry contained in a list.
+ \param head This is a pointer to the list tail structure
+ */
+#define AST_LIST_LAST(head) ((head)->last)
/*!
\brief Returns the next entry in the list after the given entry.
@@ -433,11 +463,13 @@
(head)->last = NULL; \
} else { \
typeof(elm) curelm = (head)->first; \
- while (curelm->field.next != (elm)) \
+ while (curelm && (curelm->field.next != (elm))) \
curelm = curelm->field.next; \
- curelm->field.next = (elm)->field.next; \
- if ((head)->last == (elm)) \
- (head)->last = curelm; \
+ if (curelm) { \
+ curelm->field.next = (elm)->field.next; \
+ if ((head)->last == (elm)) \
+ (head)->last = curelm; \
+ } \
} \
(elm)->field.next = NULL; \
} while (0)
Modified: branches/1.2/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/branches/1.2/include/asterisk/lock.h?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- branches/1.2/include/asterisk/lock.h (original)
+++ branches/1.2/include/asterisk/lock.h Tue May 23 12:15:23 2006
@@ -97,6 +97,13 @@
typedef pthread_cond_t ast_cond_t;
+static pthread_mutex_t empty_mutex;
+
+static void __attribute__((constructor)) init_empty_mutex(void)
+{
+ memset(&empty_mutex, 0, sizeof(empty_mutex));
+}
+
static inline int __ast_pthread_mutex_init_attr(const char *filename, int lineno, const char *func,
const char *mutex_name, ast_mutex_t *t,
pthread_mutexattr_t *attr)
@@ -105,14 +112,16 @@
int canlog = strcmp(filename, "logger.c");
if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
- __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is already initialized.\n",
- filename, lineno, func, mutex_name);
- __ast_mutex_logger("%s line %d (%s): Error: previously initialization of mutex '%s'.\n",
- t->file, t->lineno, t->func, mutex_name);
-#ifdef THREAD_CRASH
- DO_THREAD_CRASH;
-#endif
- return 0;
+ if ((t->mutex) != (empty_mutex)) {
+ __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is already initialized.\n",
+ filename, lineno, func, mutex_name);
+ __ast_mutex_logger("%s line %d (%s): Error: previously initialization of mutex '%s'.\n",
+ t->file, t->lineno, t->func, mutex_name);
+#ifdef THREAD_CRASH
+ DO_THREAD_CRASH;
+#endif
+ return 0;
+ }
}
#endif
Modified: branches/1.2/pbx.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/pbx.c?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- branches/1.2/pbx.c (original)
+++ branches/1.2/pbx.c Tue May 23 12:15:23 2006
@@ -3706,6 +3706,7 @@
int length;
struct ast_state_cb *thiscb, *prevcb;
+ memset(&store, 0, sizeof(store));
AST_LIST_HEAD_INIT(&store);
/* it is very important that this function hold the hintlock _and_ the conlock
Modified: branches/1.2/res/res_features.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/res/res_features.c?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- branches/1.2/res/res_features.c (original)
+++ branches/1.2/res/res_features.c Tue May 23 12:15:23 2006
@@ -866,7 +866,7 @@
};
-static AST_LIST_HEAD(feature_list,ast_call_feature) feature_list;
+static AST_LIST_HEAD_STATIC(feature_list,ast_call_feature);
/* register new feature into feature_list*/
void ast_register_feature(struct ast_call_feature *feature)
@@ -2145,7 +2145,6 @@
{
int res;
- AST_LIST_HEAD_INIT(&feature_list);
memset(parking_ext, 0, sizeof(parking_ext));
memset(parking_con, 0, sizeof(parking_con));
More information about the svn-commits
mailing list