diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-14 21:32:00 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-05-14 21:32:00 +0000 |
commit | 848841973a5c5b8d2de336ed32f5b4ab80ca8d79 (patch) | |
tree | d36d7d542d0d6ba89c806a8acd12d366bd58a368 /main | |
parent | ec6b2c6e0554dd4374dea87f80d99f9495a80b03 (diff) |
Add ast_assert(), which can be used to handle fatal errors. It is only compiled
in if dev-mode is enabled, and only aborts if DO_CRASH is defined.
(inspired by issue #12650)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@116463 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/abstract_jb.c | 4 | ||||
-rw-r--r-- | main/channel.c | 4 | ||||
-rw-r--r-- | main/rtp.c | 6 | ||||
-rw-r--r-- | main/sched.c | 4 | ||||
-rw-r--r-- | main/udptl.c | 3 |
5 files changed, 8 insertions, 13 deletions
diff --git a/main/abstract_jb.c b/main/abstract_jb.c index ed2600070..25bd8fd0d 100644 --- a/main/abstract_jb.c +++ b/main/abstract_jb.c @@ -433,7 +433,7 @@ static void jb_get_and_deliver(struct ast_channel *chan) return; default: ast_log(LOG_ERROR, "This should never happen!\n"); - CRASH; + ast_assert(0); break; } @@ -489,7 +489,7 @@ static int create_jb(struct ast_channel *chan, struct ast_frame *frr) bridged = ast_bridged_channel(chan); if (!bridged) { /* We should always have bridged chan if a jitterbuffer is in use */ - CRASH; + ast_assert(0); } snprintf(name1, sizeof(name1), "%s", bridged->name); tmp = strchr(name1, '/'); diff --git a/main/channel.c b/main/channel.c index d9ab77c38..392b0b113 100644 --- a/main/channel.c +++ b/main/channel.c @@ -912,7 +912,7 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin) if (((fin->frametype == AST_FRAME_VOICE) && (qlen > 96)) || (qlen > 128)) { if (fin->frametype != AST_FRAME_VOICE) { ast_log(LOG_WARNING, "Exceptionally long queue length queuing to %s\n", chan->name); - CRASH; + ast_assert(0); } else { if (option_debug) ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name); @@ -1476,7 +1476,7 @@ int ast_hangup(struct ast_channel *chan) ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd " "is blocked by thread %ld in procedure %s! Expect a failure\n", (long)pthread_self(), chan->name, (long)chan->blocker, chan->blockproc); - CRASH; + ast_assert(0); } if (!ast_test_flag(chan, AST_FLAG_ZOMBIE)) { if (option_debug) diff --git a/main/rtp.c b/main/rtp.c index 658bd0891..2597fb178 100644 --- a/main/rtp.c +++ b/main/rtp.c @@ -855,8 +855,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp) rtcpheader = (unsigned int *)(rtcpdata + AST_FRIENDLY_OFFSET); if (res < 0) { - if (errno == EBADF) - CRASH; + ast_assert(errno != EBADF); if (errno != EAGAIN) { ast_log(LOG_WARNING, "RTCP Read error: %s. Hanging up.\n", strerror(errno)); return NULL; @@ -1134,8 +1133,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp) rtpheader = (unsigned int *)(rtp->rawdata + AST_FRIENDLY_OFFSET); if (res < 0) { - if (errno == EBADF) - CRASH; + ast_assert(errno != EBADF); if (errno != EAGAIN) { ast_log(LOG_WARNING, "RTP Read error: %s. Hanging up.\n", strerror(errno)); return NULL; diff --git a/main/sched.c b/main/sched.c index 04589a018..935e85398 100644 --- a/main/sched.c +++ b/main/sched.c @@ -282,9 +282,7 @@ int ast_sched_del(struct sched_context *con, int id) if (!s) { if (option_debug) ast_log(LOG_DEBUG, "Attempted to delete nonexistent schedule entry %d!\n", id); -#ifdef DO_CRASH - CRASH; -#endif + ast_assert(0); return -1; } diff --git a/main/udptl.c b/main/udptl.c index 718b46fb8..a9386ac09 100644 --- a/main/udptl.c +++ b/main/udptl.c @@ -639,8 +639,7 @@ struct ast_frame *ast_udptl_read(struct ast_udptl *udptl) if (res < 0) { if (errno != EAGAIN) ast_log(LOG_WARNING, "UDPTL read error: %s\n", strerror(errno)); - if (errno == EBADF) - CRASH; + ast_assert(errno != EBADF); return &ast_null_frame; } |