mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 02:26:23 +00:00
clean up scheduler debugging and expose defines in the Makefile (bug #4703)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6145 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
2
Makefile
2
Makefile
@@ -52,7 +52,7 @@ DEBUG=-g #-pg
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
# Optional debugging parameters
|
# Optional debugging parameters
|
||||||
DEBUG_THREADS = #-DDEBUG_THREADS #-DDO_CRASH #-DDETECT_DEADLOCKS
|
DEBUG_THREADS = #-DDUMP_SCHEDULER #-DDEBUG_SCHEDULER #-DDEBUG_THREADS #-DDO_CRASH #-DDETECT_DEADLOCKS
|
||||||
|
|
||||||
# Uncomment next one to enable ast_frame tracing (for debugging)
|
# Uncomment next one to enable ast_frame tracing (for debugging)
|
||||||
TRACE_FRAMES = #-DTRACE_FRAMES
|
TRACE_FRAMES = #-DTRACE_FRAMES
|
||||||
|
24
sched.c
24
sched.c
@@ -260,6 +260,10 @@ int ast_sched_add(struct sched_context *con, int when, ast_sched_cb callback, vo
|
|||||||
res = tmp->id;
|
res = tmp->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef DUMP_SCHEDULER
|
||||||
|
/* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */
|
||||||
|
ast_sched_dump(con);
|
||||||
|
#endif
|
||||||
ast_mutex_unlock(&con->lock);
|
ast_mutex_unlock(&con->lock);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -289,6 +293,10 @@ int ast_sched_del(struct sched_context *con, int id)
|
|||||||
last = s;
|
last = s;
|
||||||
s = s->next;
|
s = s->next;
|
||||||
}
|
}
|
||||||
|
#ifdef DUMP_SCHEDULER
|
||||||
|
/* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */
|
||||||
|
ast_sched_dump(con);
|
||||||
|
#endif
|
||||||
ast_mutex_unlock(&con->lock);
|
ast_mutex_unlock(&con->lock);
|
||||||
if (!s) {
|
if (!s) {
|
||||||
ast_log(LOG_NOTICE, "Attempted to delete nonexistent schedule entry %d!\n", id);
|
ast_log(LOG_NOTICE, "Attempted to delete nonexistent schedule entry %d!\n", id);
|
||||||
@@ -300,7 +308,7 @@ int ast_sched_del(struct sched_context *con, int id)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ast_sched_dump(struct sched_context *con)
|
void ast_sched_dump(const struct sched_context *con)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Dump the contents of the scheduler to
|
* Dump the contents of the scheduler to
|
||||||
@@ -311,16 +319,14 @@ void ast_sched_dump(struct sched_context *con)
|
|||||||
time_t s, ms;
|
time_t s, ms;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
#ifdef SCHED_MAX_CACHE
|
#ifdef SCHED_MAX_CACHE
|
||||||
ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total, %d Cache)\n",
|
ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total, %d Cache)\n", con->schedcnt, con->eventcnt - 1, con->schedccnt);
|
||||||
con-> schedcnt, con->eventcnt - 1, con->schedccnt);
|
|
||||||
#else
|
#else
|
||||||
ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total)\n",
|
ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total)\n", con->schedcnt, con->eventcnt - 1);
|
||||||
con-> schedcnt, con->eventcnt - 1);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ast_log(LOG_DEBUG, "=================================================\n");
|
ast_log(LOG_DEBUG, "=============================================================\n");
|
||||||
ast_log(LOG_DEBUG, "|ID Callback Data Time (sec:ms) |\n");
|
ast_log(LOG_DEBUG, "|ID Callback Data Time (sec:ms) |\n");
|
||||||
ast_log(LOG_DEBUG, "+-----+-----------+-----------+-----------------+\n");
|
ast_log(LOG_DEBUG, "+-----+-----------------+-----------------+-----------------+\n");
|
||||||
q = con->schedq;
|
q = con->schedq;
|
||||||
while(q) {
|
while(q) {
|
||||||
s = q->when.tv_sec - tv.tv_sec;
|
s = q->when.tv_sec - tv.tv_sec;
|
||||||
@@ -329,7 +335,7 @@ void ast_sched_dump(struct sched_context *con)
|
|||||||
ms += 1000000;
|
ms += 1000000;
|
||||||
s--;
|
s--;
|
||||||
}
|
}
|
||||||
ast_log(LOG_DEBUG, "|%.4d | %p | %p | %.6ld : %.6ld |\n",
|
ast_log(LOG_DEBUG, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n",
|
||||||
q->id,
|
q->id,
|
||||||
q->callback,
|
q->callback,
|
||||||
q->data,
|
q->data,
|
||||||
@@ -337,7 +343,7 @@ void ast_sched_dump(struct sched_context *con)
|
|||||||
(long)ms);
|
(long)ms);
|
||||||
q=q->next;
|
q=q->next;
|
||||||
}
|
}
|
||||||
ast_log(LOG_DEBUG, "=================================================\n");
|
ast_log(LOG_DEBUG, "=============================================================\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user