add_header(&req, "Event", "message-summary");
add_header(&req, "Content-Type", notifymime);
- snprintf(tmp, sizeof(tmp), "Messages-Waiting: %s\n", newmsgs ? "yes" : "no");
- snprintf(tmp2, sizeof(tmp2), "Voicemail: %d/%d\n", newmsgs, oldmsgs);
+ snprintf(tmp, sizeof(tmp), "Messages-Waiting: %s\r\n", newmsgs ? "yes" : "no");
+ snprintf(tmp2, sizeof(tmp2), "Voicemail: %d/%d\r\n", newmsgs, oldmsgs);
snprintf(clen, sizeof(clen), "%d", (int)(strlen(tmp) + strlen(tmp2)));
add_header(&req, "Content-Length", clen);
add_line(&req, tmp);
*
* General Asterisk channel definitions.
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
pthread_mutex_t mutex;
char *file;
int lineno;
+ int reentrancy;
char *func;
pthread_t thread;
};
t->lineno = lineno;
t->func = func;
t->thread = 0;
+ t->reentrancy = 0;
return pthread_mutex_init(&t->mutex, attr);
}
res = pthread_mutex_lock(&t->mutex);
#endif /* DETECT_DEADLOCKS */
if (!res) {
+ t->reentrancy++;
t->file = filename;
t->lineno = lineno;
t->func = func;
#endif /* definded(AST_MUTEX_INIT_W_CONSTRUCTORS) || defined(AST_MUTEX_INIT_ON_FIRST_USE) */
res = pthread_mutex_trylock(&t->mutex);
if (!res) {
+ t->reentrancy++;
t->file = filename;
t->lineno = lineno;
t->func = func;
filename, lineno, func, mutex_name);
}
#endif
- /* Assumes lock is actually held */
- t->file = NULL;
- t->lineno = 0;
- t->func = NULL;
- t->thread = 0;
+ --t->reentrancy;
+ if (t->reentrancy < 0) {
+ fprintf(stderr, "%s line %d (%s): Freed more times than we've locked!\n",
+ filename, lineno, func, mutex_name);
+ t->reentrancy = 0;
+ }
+ if (!t->rentrancy) {
+ t->file = NULL;
+ t->lineno = 0;
+ t->func = NULL;
+ t->thread = 0;
+ }
res = pthread_mutex_unlock(&t->mutex);
if (res) {
fprintf(stderr, "%s line %d (%s): Error releasing mutex: %s\n",