rendered paste bodyIndex: apps/app_voicemail.c===================================================================--- apps/app_voicemail.c (revision 199221)+++ apps/app_voicemail.c (working copy)@@ -5017,7 +5017,7 @@ else if (!strncmp(mwi_msg->cause, "BLK", 3)) ast_log(AST_LOG_WARNING, "MWI light was already on or off for %s\n", mwi_msg->fwd_st); ast_log(AST_LOG_WARNING, "The switch reported '%s'\n", mwi_msg->cause);- ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);+ //ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy); } else { ast_debug(1, "Successfully executed SMDI MWI change for %s\n", extension); }Index: include/asterisk/smdi.h===================================================================--- include/asterisk/smdi.h (revision 199221)+++ include/asterisk/smdi.h (working copy)@@ -37,6 +37,7 @@ #include "asterisk/config.h" #include "asterisk/module.h" #include "asterisk/astobj.h"+#include "asterisk/linkedlists.h" #include "asterisk/optional_api.h" #define SMDI_MESG_DESK_NUM_LEN 3@@ -53,7 +54,7 @@ * ast_smdi_mwi_message structures. */ struct ast_smdi_mwi_message {- ASTOBJ_COMPONENTS(struct ast_smdi_mwi_message);+ AST_LIST_ENTRY(ast_smdi_mwi_message) entry; char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* forwarding station number */ char cause[SMDI_MWI_FAIL_CAUSE_LEN + 1]; /* the type of failure */ struct timeval timestamp; /* a timestamp for the message */@@ -67,7 +68,7 @@ * ast_smdi_md_message structures. */ struct ast_smdi_md_message {- ASTOBJ_COMPONENTS(struct ast_smdi_md_message);+ AST_LIST_ENTRY(ast_smdi_md_message) entry; char mesg_desk_num[SMDI_MESG_DESK_NUM_LEN + 1]; /* message desk number */ char mesg_desk_term[SMDI_MESG_DESK_TERM_LEN + 1]; /* message desk terminal */ char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* forwarding station number */Index: res/res_smdi.c===================================================================--- res/res_smdi.c (revision 199221)+++ res/res_smdi.c (working copy)@@ -153,22 +153,12 @@ static const char config_file[] = "smdi.conf"; -/*! \brief SMDI message desk message queue. */-struct ast_smdi_md_queue {- ASTOBJ_CONTAINER_COMPONENTS(struct ast_smdi_md_message);-};--/*! \brief SMDI message waiting indicator message queue. */-struct ast_smdi_mwi_queue {- ASTOBJ_CONTAINER_COMPONENTS(struct ast_smdi_mwi_message);-};- struct ast_smdi_interface { ASTOBJ_COMPONENTS_FULL(struct ast_smdi_interface, SMDI_MAX_FILENAME_LEN, 1);- struct ast_smdi_md_queue md_q;+ AST_LIST_HEAD_NOLOCK(, ast_smdi_md_queue) md_q; ast_mutex_t md_q_lock; ast_cond_t md_q_cond;- struct ast_smdi_mwi_queue mwi_q;+ AST_LIST_HEAD_NOLOCK(, ast_smdi_mwi_queue) mwi_q; ast_mutex_t mwi_q_lock; ast_cond_t mwi_q_cond; FILE *file;@@ -225,6 +215,8 @@ static void ast_smdi_interface_destroy(struct ast_smdi_interface *iface) {+ struct ast_smdi_md_message *md; + struct ast_smdi_mwi_message *mwi; if (iface->thread != AST_PTHREADT_NULL && iface->thread != AST_PTHREADT_STOP) { pthread_cancel(iface->thread); pthread_join(iface->thread, NULL);@@ -235,10 +227,10 @@ if (iface->file) fclose(iface->file); - ASTOBJ_CONTAINER_DESTROYALL(&iface->md_q, ast_smdi_md_message_destroy);- ASTOBJ_CONTAINER_DESTROYALL(&iface->mwi_q, ast_smdi_mwi_message_destroy);- ASTOBJ_CONTAINER_DESTROY(&iface->md_q);- ASTOBJ_CONTAINER_DESTROY(&iface->mwi_q);+ while ((mwi = AST_LIST_REMOVE_HEAD(&iface->mwi_q, entry)))+ ast_smdi_mwi_message_destroy(mwi);+ while ((md = AST_LIST_REMOVE_HEAD(&iface->md_q, entry)))+ ast_smdi_md_message_destroy(md); ast_mutex_destroy(&iface->md_q_lock); ast_cond_destroy(&iface->md_q_cond);@@ -265,7 +257,7 @@ static void ast_smdi_md_message_push(struct ast_smdi_interface *iface, struct ast_smdi_md_message *md_msg) { ast_mutex_lock(&iface->md_q_lock);- ASTOBJ_CONTAINER_LINK_END(&iface->md_q, md_msg);+ AST_LIST_INSERT_TAIL(&iface->md_q, md_msg, entry); ast_cond_broadcast(&iface->md_q_cond); ast_mutex_unlock(&iface->md_q_lock); }@@ -279,7 +271,7 @@ static void ast_smdi_mwi_message_push(struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *mwi_msg) { ast_mutex_lock(&iface->mwi_q_lock);- ASTOBJ_CONTAINER_LINK_END(&iface->mwi_q, mwi_msg);+ AST_LIST_INSERT_TAIL(&iface->mwi_q, mwi_msg, entry); ast_cond_broadcast(&iface->mwi_q_cond); ast_mutex_unlock(&iface->mwi_q_lock); }@@ -324,7 +316,7 @@ void ast_smdi_md_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_md_message *md_msg) { ast_mutex_lock(&iface->md_q_lock);- ASTOBJ_CONTAINER_LINK_START(&iface->md_q, md_msg);+ AST_LIST_INSERT_HEAD(&iface->md_q, md_msg, entry); ast_cond_broadcast(&iface->md_q_cond); ast_mutex_unlock(&iface->md_q_lock); }@@ -332,7 +324,7 @@ void ast_smdi_mwi_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *mwi_msg) { ast_mutex_lock(&iface->mwi_q_lock);- ASTOBJ_CONTAINER_LINK_START(&iface->mwi_q, mwi_msg);+ AST_LIST_INSERT_HEAD(&iface->mwi_q, mwi_msg, entry); ast_cond_broadcast(&iface->mwi_q_cond); ast_mutex_unlock(&iface->mwi_q_lock); }@@ -370,9 +362,11 @@ { switch (type) { case SMDI_MWI:- return ASTOBJ_CONTAINER_UNLINK_START(&iface->mwi_q);+ return AST_LIST_REMOVE_HEAD(&iface->mwi_q, entry);+ //return ASTOBJ_CONTAINER_UNLINK_START(&iface->mwi_q); case SMDI_MD:- return ASTOBJ_CONTAINER_UNLINK_START(&iface->md_q);+ return AST_LIST_REMOVE_HEAD(&iface->md_q, entry);+ //return ASTOBJ_CONTAINER_UNLINK_START(&iface->md_q); } return NULL; }@@ -392,17 +386,17 @@ return ast_tv(0, 0); } -static inline void unref_msg(void *msg, enum smdi_message_type type)+static inline void unref_msg(void *msg, enum smdi_message_type type, struct ast_smdi_interface *iface) { struct ast_smdi_md_message *md_msg = msg; struct ast_smdi_mwi_message *mwi_msg = msg; switch (type) { case SMDI_MWI:- ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);+ AST_LIST_REMOVE(&iface->mwi_q, mwi_msg, entry); break; case SMDI_MD:- ASTOBJ_UNREF(md_msg, ast_smdi_md_message_destroy);+ AST_LIST_REMOVE(&iface->md_q, md_msg, entry); break; } }@@ -423,7 +417,7 @@ if (elapsed > iface->msg_expiry) { /* found an expired message */- unref_msg(msg, type);+ unref_msg(msg, type, iface); ast_log(LOG_NOTICE, "Purged expired message from %s SMDI %s message queue. " "Message was %ld milliseconds too old.\n", iface->name, (type == SMDI_MD) ? "MD" : "MWI", @@ -442,7 +436,7 @@ ast_smdi_mwi_message_push(iface, msg); break; }- unref_msg(msg, type);+ unref_msg(msg, type, iface); break; } }@@ -476,25 +470,19 @@ switch (type) { case SMDI_MD: if (ast_strlen_zero(search_key)) {- struct ast_smdi_md_message *md_msg = NULL;- /* No search key provided (the code from chan_dahdi does this). * Just pop the top message off of the queue. */-- ASTOBJ_CONTAINER_TRAVERSE(&iface->md_q, !md_msg, do {- md_msg = ASTOBJ_REF(iterator);- } while (0); );-- msg = md_msg;+ msg = AST_LIST_FIRST(iface->md_q); } else if (ast_test_flag(&options, OPT_SEARCH_TERMINAL)) { struct ast_smdi_md_message *md_msg = NULL; /* Searching by the message desk terminal */ - ASTOBJ_CONTAINER_TRAVERSE(&iface->md_q, !md_msg, do {- if (!strcasecmp(iterator->mesg_desk_term, search_key))- md_msg = ASTOBJ_REF(iterator);- } while (0); );+ //ASTOBJ_CONTAINER_TRAVERSE(&iface->md_q, !md_msg, do {+ AST_LIST_TRAVERSE(&iface->md_q, md_msg, entry) {+ if (!strcasecmp(md_msg->mesg_desk_term, search_key))+ break;+ } msg = md_msg; } else if (ast_test_flag(&options, OPT_SEARCH_NUMBER)) {@@ -502,31 +490,38 @@ /* Searching by the message desk number */ - ASTOBJ_CONTAINER_TRAVERSE(&iface->md_q, !md_msg, do {- if (!strcasecmp(iterator->mesg_desk_num, search_key))- md_msg = ASTOBJ_REF(iterator);- } while (0); );+ //ASTOBJ_CONTAINER_TRAVERSE(&iface->md_q, !md_msg, do {+ AST_LIST_TRAVERSE(&iface->md_q, md_msg, entry) {+ if (!strcasecmp(md_msg->mesg_desk_num, search_key))+ break;+ } msg = md_msg; } else {+ struct ast_smdi_md_message *md_msg = NULL; /* Searching by the forwarding station */- msg = ASTOBJ_CONTAINER_FIND(&iface->md_q, search_key);+ AST_LIST_TRAVERSE(&iface->md_q, md_msg, entry) {+ if (!strcasecmp(md_msg->fwd_st, search_key))+ break;+ }+ msg = md_msg; } break; case SMDI_MWI: if (ast_strlen_zero(search_key)) {- struct ast_smdi_mwi_message *mwi_msg = NULL; /* No search key provided (the code from chan_dahdi does this). * Just pop the top message off of the queue. */ - ASTOBJ_CONTAINER_TRAVERSE(&iface->mwi_q, !mwi_msg, do {- mwi_msg = ASTOBJ_REF(iterator);- } while (0); );-- msg = mwi_msg;+ msg = AST_LIST_FIRST(&iface->mwi_q); } else {- msg = ASTOBJ_CONTAINER_FIND(&iface->mwi_q, search_key);+ struct ast_smdi_mwi_message *mwi_msg = NULL;+ /* Searching by the forwarding station */+ AST_LIST_TRAVERSE(&iface->mwi_q, mwi_msg, entry) {+ if (!strcasecmp(mwi_msg->fwd_st, search_key))+ break;+ }+ msg = mwi_msg; } break; }@@ -665,7 +660,7 @@ return NULL; } - ASTOBJ_INIT(md_msg);+ //ASTOBJ_INIT(md_msg); /* read the message desk number */ for (i = 0; i < sizeof(md_msg->mesg_desk_num) - 1; i++) {@@ -718,7 +713,7 @@ /* Put the fwd_st in the name field so that we can use ASTOBJ_FIND to look * up a message on this field */- ast_copy_string(md_msg->name, md_msg->fwd_st, sizeof(md_msg->name));+ //ast_copy_string(md_msg->name, md_msg->fwd_st, sizeof(md_msg->name)); /* read the calling station number (may be blank) */ cp = &md_msg->calling_st[0];@@ -755,7 +750,7 @@ ast_smdi_md_message_push(iface, md_msg); ast_log(LOG_DEBUG, "Recieved SMDI MD message on %s\n", iface->name); - ASTOBJ_UNREF(md_msg, ast_smdi_md_message_destroy);+ //ASTOBJ_UNREF(md_msg, ast_smdi_md_message_destroy); } else if (c == 'W') { /* MWI message */ start = 0;@@ -767,7 +762,7 @@ return NULL; } - ASTOBJ_INIT(mwi_msg);+ //ASTOBJ_INIT(mwi_msg); /* discard the 'I' (from 'MWI') */ fgetc(iface->file);@@ -791,7 +786,7 @@ /* Put the fwd_st in the name field so that we can use ASTOBJ_FIND to look * up a message on this field */- ast_copy_string(mwi_msg->name, mwi_msg->fwd_st, sizeof(mwi_msg->name));+ //ast_copy_string(mwi_msg->name, mwi_msg->fwd_st, sizeof(mwi_msg->name)); /* read the mwi failure cause */ for (i = 0; i < sizeof(mwi_msg->cause) - 1; i++)@@ -804,7 +799,7 @@ ast_smdi_mwi_message_push(iface, mwi_msg); ast_log(LOG_DEBUG, "Recieved SMDI MWI message on %s\n", iface->name); - ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);+ //ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy); } else { ast_log(LOG_ERROR, "Unknown SMDI message type recieved on %s (M%c).\n", iface->name, c); start = 0;@@ -930,8 +925,10 @@ return NULL; ASTOBJ_INIT(iface);- ASTOBJ_CONTAINER_INIT(&iface->md_q);- ASTOBJ_CONTAINER_INIT(&iface->mwi_q);+ //ASTOBJ_CONTAINER_INIT(&iface->md_q);+ //AST_LIST_HEAD_NOLOCK_INIT_VALUE(&iface->md_q);+ //ASTOBJ_CONTAINER_INIT(&iface->mwi_q);+ //AST_LIST_HEAD_NOLOCK_INIT_VALUE(&iface->mwi_q); ast_mutex_init(&iface->md_q_lock); ast_cond_init(&iface->md_q_cond, NULL);@@ -1192,8 +1189,8 @@ if (smd->iface) ASTOBJ_UNREF(smd->iface, ast_smdi_interface_destroy); - if (smd->md_msg)- ASTOBJ_UNREF(smd->md_msg, ast_smdi_md_message_destroy);+// if (smd->md_msg)+// ASTOBJ_UNREF(smd->md_msg, ast_smdi_md_message_destroy); free(smd); }@@ -1279,7 +1276,7 @@ goto return_error; smd->iface = ASTOBJ_REF(iface);- smd->md_msg = ASTOBJ_REF(md_msg);+ smd->md_msg = md_msg; smd->id = ast_atomic_fetchadd_int((int *) &smdi_msg_id, 1); snprintf(buf, len, "%u", smd->id); @@ -1298,8 +1295,8 @@ if (iface) ASTOBJ_UNREF(iface, ast_smdi_interface_destroy); - if (md_msg)- ASTOBJ_UNREF(md_msg, ast_smdi_md_message_destroy);+// if (md_msg)+// ASTOBJ_UNREF(md_msg, ast_smdi_md_message_destroy); if (smd && !datastore) smdi_msg_datastore_destroy(smd);