set some key functions to report the file func line of the caller not of the actual function

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1278 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-04-27 15:02:35 +00:00
parent 3c4d46c1cf
commit 31e31566a5
6 changed files with 83 additions and 21 deletions

View File

@ -47,7 +47,7 @@ extern "C" {
#endif
#include <assert.h>
#include <setjmp.h>
#include <switch_version.h>
#include <switch_apr.h>
#include <switch_sqlite.h>

View File

@ -72,13 +72,20 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_get_state(switch_channel *ch
*/
SWITCH_DECLARE(unsigned int) switch_channel_ready(switch_channel *channel);
SWITCH_DECLARE(switch_channel_state) switch_channel_perform_set_state(switch_channel *channel,
const char *file,
const char *func,
int line,
switch_channel_state state);
/*!
\brief Set the current state of a channel
\param channel channel to set state of
\param state new state
\return current state of channel after application of new state
*/
SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *channel, switch_channel_state state);
#define switch_channel_set_state(channel, state) switch_channel_perform_set_state(channel, __FILE__, __FUNCTION__, __LINE__, state)
/*!
\brief return a cause code for a given string
@ -231,19 +238,29 @@ SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel *channel, switch_cha
*/
SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel *channel, switch_channel_flag flags);
SWITCH_DECLARE(switch_status) switch_channel_perform_answer(switch_channel *channel,
const char *file,
const char *func,
int line);
/*!
\brief Answer a channel (initiate/acknowledge a successful connection)
\param channel channel to answer
\return SWITCH_STATUS_SUCCESS if channel was answered successfully
*/
SWITCH_DECLARE(switch_status) switch_channel_answer(switch_channel *channel);
#define switch_channel_answer(channel) switch_channel_perform_answer(channel, __FILE__, __FUNCTION__, __LINE__)
SWITCH_DECLARE(switch_status) switch_channel_perform_pre_answer(switch_channel *channel,
const char *file,
const char *func,
int line);
/*!
\brief Indicate progress on a channel to attempt early media
\param channel channel to pre-answer
\return SWITCH_STATUS_SUCCESS
*/
SWITCH_DECLARE(switch_status) switch_channel_pre_answer(switch_channel *channel);
*/
#define switch_channel_pre_answer(channel) switch_channel_perform_pre_answer(channel, __FILE__, __FUNCTION__, __LINE__)
/*!
\brief add a state handler table to a given channel
@ -298,14 +315,20 @@ SWITCH_DECLARE(switch_status) switch_channel_set_name(switch_channel *channel, c
*/
SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel *channel);
SWITCH_DECLARE(switch_channel_state) switch_channel_perform_hangup(switch_channel *channel,
const char *file,
const char *func,
int line,
switch_call_cause_t hangup_cause);
/*!
\brief Hangup a channel flagging it's state machine to end
\param channel channel to hangup
\param hangup_cause the appropriate hangup cause
\return the resulting channel state.
*/
SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *channel, switch_call_cause_t hangup_cause);
#define switch_channel_hangup(channel, hangup_cause) switch_channel_perform_hangup(channel, __FILE__, __FUNCTION__, __LINE__, hangup_cause)
/*!
\brief Test for presence of DTMF on a given channel

View File

@ -420,7 +420,18 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
\param sig signal to send
\return status returned by the session's signal handler
*/
SWITCH_DECLARE(switch_status) switch_core_session_kill_channel(switch_core_session *session, switch_signal sig);
SWITCH_DECLARE(switch_status) switch_core_session_perform_kill_channel(switch_core_session *session,
const char *file,
const char *func,
int line,
switch_signal sig);
/*!
\brief Send a signal to a channel
\param session session to send signal to
\param sig signal to send
\return status returned by the session's signal handler
*/
#define switch_core_session_kill_channel(session, sig) switch_core_session_perform_kill_channel(session, __FILE__, __FUNCTION__, __LINE__, sig)
/*!
\brief Wait for a session to be ready for input

View File

@ -586,7 +586,8 @@ typedef enum {
SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE = 102,
SWITCH_CAUSE_MANDATORY_IE_LENGTH_ERROR = 103,
SWITCH_CAUSE_PROTOCOL_ERROR = 111,
SWITCH_CAUSE_INTERWORKING = 127
SWITCH_CAUSE_INTERWORKING = 127,
SWITCH_CAUSE_CRASH = 500
} switch_call_cause_t;

View File

@ -81,6 +81,7 @@ static struct switch_cause_table CAUSE_CHART[] = {
{ "MANDATORY_IE_LENGTH_ERROR", SWITCH_CAUSE_MANDATORY_IE_LENGTH_ERROR },
{ "PROTOCOL_ERROR", SWITCH_CAUSE_PROTOCOL_ERROR },
{ "INTERWORKING", SWITCH_CAUSE_INTERWORKING },
{ "CRASH", SWITCH_CAUSE_CRASH },
{ NULL, 0 }
};
@ -362,7 +363,11 @@ SWITCH_DECLARE(const char *) switch_channel_state_name(switch_channel_state stat
return state_names[state];
}
SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *channel, switch_channel_state state)
SWITCH_DECLARE(switch_channel_state) switch_channel_perform_set_state(switch_channel *channel,
const char *file,
const char *func,
int line,
switch_channel_state state)
{
switch_channel_state last_state;
int ok = 0;
@ -480,8 +485,10 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *ch
if (ok) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n", channel->name,
state_names[last_state], state_names[state]);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n",
channel->name,
state_names[last_state],
state_names[state]);
channel->state = state;
if (state == CS_HANGUP && channel->hangup_cause == SWITCH_CAUSE_UNALLOCATED) {
@ -499,8 +506,10 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *ch
switch_core_session_signal_state_change(channel->session);
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Invalid State Change %s -> %s\n", channel->name,
state_names[last_state], state_names[state]);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_WARNING, "%s Invalid State Change %s -> %s\n",
channel->name,
state_names[last_state],
state_names[state]);
//we won't tolerate an invalid state change so we can make sure we are as robust as a nice cup of dark coffee!
if (channel->state < CS_HANGUP) {
@ -687,7 +696,11 @@ SWITCH_DECLARE(switch_caller_extension *) switch_channel_get_caller_extension(sw
}
SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *channel, switch_call_cause_t hangup_cause)
SWITCH_DECLARE(switch_channel_state) switch_channel_perform_hangup(switch_channel *channel,
const char *file,
const char *func,
int line,
switch_call_cause_t hangup_cause)
{
assert(channel != NULL);
@ -701,7 +714,8 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *chann
channel->state = CS_HANGUP;
channel->hangup_cause = hangup_cause;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n", channel->name,
switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n",
channel->name,
state_names[last_state], switch_channel_cause2str(channel->hangup_cause));
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
@ -714,7 +728,10 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_hangup(switch_channel *chann
return channel->state;
}
SWITCH_DECLARE(switch_status) switch_channel_pre_answer(switch_channel *channel)
SWITCH_DECLARE(switch_status) switch_channel_perform_pre_answer(switch_channel *channel,
const char *file,
const char *func,
int line)
{
switch_core_session_message msg;
char *uuid = switch_core_session_get_uuid(channel->session);
@ -731,14 +748,17 @@ SWITCH_DECLARE(switch_status) switch_channel_pre_answer(switch_channel *channel)
status = switch_core_session_message_send(uuid, &msg);
if (status == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Pre-Answer %s!\n", channel->name);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name);
switch_channel_set_flag(channel, CF_EARLY_MEDIA);
}
return status;
}
SWITCH_DECLARE(switch_status) switch_channel_answer(switch_channel *channel)
SWITCH_DECLARE(switch_status) switch_channel_perform_answer(switch_channel *channel,
const char *file,
const char *func,
int line)
{
assert(channel != NULL);
@ -751,7 +771,7 @@ SWITCH_DECLARE(switch_status) switch_channel_answer(switch_channel *channel)
channel->times.answered = switch_time_now();
switch_channel_set_flag(channel, CF_ANSWERED);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Answer %s!\n", channel->name);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Answer %s!\n", channel->name);
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_ANSWER) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, event);
switch_event_fire(&event);

View File

@ -1393,10 +1393,16 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
return status;
}
SWITCH_DECLARE(switch_status) switch_core_session_kill_channel(switch_core_session *session, switch_signal sig)
SWITCH_DECLARE(switch_status) switch_core_session_perform_kill_channel(switch_core_session *session,
const char *file,
const char *func,
int line,
switch_signal sig)
{
struct switch_io_event_hook_kill_channel *ptr;
switch_status status = SWITCH_STATUS_FALSE;
switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Kill %s [%d]\n", switch_channel_get_name(session->channel), sig);
if (session->endpoint_interface->io_routines->kill_channel) {
if ((status = session->endpoint_interface->io_routines->kill_channel(session, sig)) == SWITCH_STATUS_SUCCESS) {
@ -1812,6 +1818,7 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
const switch_state_handler_table *driver_state_handler = NULL;
const switch_state_handler_table *application_state_handler = NULL;
/*
Life of the channel. you have channel and pool in your session
everywhere you go you use the session to malloc with