diff options
author | mogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-03 15:53:07 +0000 |
---|---|---|
committer | mogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-03 15:53:07 +0000 |
commit | 4a1aaf52ae4189e660ad57ba69253f54603a2beb (patch) | |
tree | 27a80e26cf8f6ea1728ab5b2b8cc7573fd9f7cdc /channels/chan_mgcp.c | |
parent | 1bd1494da59a95dce73628aafc4ba892036b82b2 (diff) |
bug #8076 check option_debug before printing to debug channel.
patch provided in bugnote, with minor changes.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@44253 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_mgcp.c')
-rw-r--r-- | channels/chan_mgcp.c | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index fbdf74982..cd2cad804 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -462,7 +462,8 @@ static int unalloc_sub(struct mgcp_subchannel *sub) ast_log(LOG_WARNING, "Trying to unalloc the real channel %s@%s?!?\n", p->name, p->parent->name); return -1; } - ast_log(LOG_DEBUG, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name); + if (option_debug) + ast_log(LOG_DEBUG, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name); sub->owner = NULL; if (!ast_strlen_zero(sub->cxident)) { @@ -725,7 +726,8 @@ static int mgcp_postrequest(struct mgcp_endpoint *p, struct mgcp_subchannel *sub /* XXX Should schedule retransmission XXX */ /* SC } else - ast_log(LOG_DEBUG, "Deferring transmission of transaction %d\n", seqno); + if (option_debug) + ast_log(LOG_DEBUG, "Deferring transmission of transaction %d\n", seqno); */ return 0; } @@ -738,7 +740,8 @@ static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub, struct mgcp_request **queue, *q, *r, *t; ast_mutex_t *l; - ast_log(LOG_DEBUG, "Slow sequence is %d\n", p->slowsequence); + if (option_debug) + ast_log(LOG_DEBUG, "Slow sequence is %d\n", p->slowsequence); if (p->slowsequence) { queue = &p->cmd_queue; l = &p->cmd_queue_lock; @@ -918,11 +921,13 @@ static int mgcp_hangup(struct ast_channel *ast) ast_log(LOG_DEBUG, "mgcp_hangup(%s)\n", ast->name); } if (!ast->tech_pvt) { - ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n"); return 0; } if (strcmp(sub->magic, MGCP_SUBCHANNEL_MAGIC)) { - ast_log(LOG_DEBUG, "Invalid magic. MGCP subchannel freed up already.\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Invalid magic. MGCP subchannel freed up already.\n"); return 0; } ast_mutex_lock(&sub->lock); @@ -1195,7 +1200,8 @@ static struct ast_frame *mgcp_rtp_read(struct mgcp_subchannel *sub) /* We already hold the channel lock */ if (f->frametype == AST_FRAME_VOICE) { if (f->subclass != sub->owner->nativeformats) { - ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); + if (option_debug) + ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); sub->owner->nativeformats = f->subclass; ast_set_read_format(sub->owner, sub->owner->readformat); ast_set_write_format(sub->owner, sub->owner->writeformat); @@ -1670,8 +1676,9 @@ static struct mgcp_subchannel *find_subchannel_and_lock(char *name, int msgid, s /* SC */ break; } else if (name && !strcasecmp(p->name, tmp)) { - ast_log(LOG_DEBUG, "Coundn't determine subchannel, assuming current master %s@%s-%d\n", - p->name, g->name, p->sub->id); + if (option_debug) + ast_log(LOG_DEBUG, "Coundn't determine subchannel, assuming current master %s@%s-%d\n", + p->name, g->name, p->sub->id); sub = p->sub; found = 1; break; @@ -2616,7 +2623,8 @@ static void *mgcp_ss(void *data) res = ast_waitfordigit(chan, timeout); timeout = 0; if (res < 0) { - ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n"); + if (option_debug) + ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n"); /*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/ ast_indicate(chan, -1); ast_hangup(chan); @@ -2684,7 +2692,8 @@ static void *mgcp_ss(void *data) timeout = matchdigittimeout; } } else if (res == 0) { - ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n"); + if (option_debug) + ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n"); /*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);*/ transmit_notify_request(sub, "G/cg"); /*zt_wait_event(p->subs[index].zfd);*/ @@ -2820,11 +2829,13 @@ static void *mgcp_ss(void *data) for (;;) { res = ast_waitfordigit(chan, to); if (!res) { - ast_log(LOG_DEBUG, "Timeout...\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Timeout...\n"); break; } if (res < 0) { - ast_log(LOG_DEBUG, "Got hangup...\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Got hangup...\n"); ast_hangup(chan); break; } @@ -2901,8 +2912,9 @@ static int attempt_transfer(struct mgcp_endpoint *p) /* Tell the caller not to hangup */ return 1; } else { - ast_log(LOG_DEBUG, "Neither %s nor %s are in a bridge, nothing to transfer\n", - p->sub->owner->name, p->sub->next->owner->name); + if (option_debug) + ast_log(LOG_DEBUG, "Neither %s nor %s are in a bridge, nothing to transfer\n", + p->sub->owner->name, p->sub->next->owner->name); p->sub->next->owner->_softhangup |= AST_SOFTHANGUP_DEV; if (p->sub->next->owner) { p->sub->next->alreadygone = 1; @@ -3068,7 +3080,8 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req, ev = get_header(req, "O"); s = strchr(ev, '/'); if (s) ev = s + 1; - ast_log(LOG_DEBUG, "Endpoint '%s@%s-%d' observed '%s'\n", p->name, p->parent->name, sub->id, ev); + if (option_debug) + ast_log(LOG_DEBUG, "Endpoint '%s@%s-%d' observed '%s'\n", p->name, p->parent->name, sub->id, ev); /* Keep looking for events unless this was a hangup */ if (strcasecmp(ev, "hu") && strcasecmp(ev, "hd") && strcasecmp(ev, "ping")) { transmit_notify_request(sub, p->curtone); @@ -3166,7 +3179,8 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req, } else if (!strcasecmp(ev, "hu")) { p->hookstate = MGCP_ONHOOK; sub->cxmode = MGCP_CX_RECVONLY; - ast_log(LOG_DEBUG, "MGCP %s@%s Went on hook\n", p->name, p->parent->name); + if (option_debug) + ast_log(LOG_DEBUG, "MGCP %s@%s Went on hook\n", p->name, p->parent->name); /* Do we need to send MDCX before a DLCX ? if (sub->rtp) { transmit_modify_request(sub); @@ -3333,7 +3347,8 @@ static int mgcpsock_read(int *id, int fd, short events, void *ignore) ast_mutex_lock(&gw->msgs_lock); for (prev = NULL, cur = gw->msgs; cur; prev = cur, cur = cur->next) { if (cur->seqno == ident) { - ast_log(LOG_DEBUG, "Got response back on transaction %d\n", ident); + if (option_debug) + ast_log(LOG_DEBUG, "Got response back on transaction %d\n", ident); if (prev) prev->next = cur->next; else |