]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
If an error occurs when reading from an RTP socket, and the error code does not
authorRussell Bryant <russell@russellbryant.com>
Thu, 29 Mar 2007 17:14:33 +0000 (17:14 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 29 Mar 2007 17:14:33 +0000 (17:14 +0000)
indicate that we should try again, then return NULL instead of a "null frame".
This will prevent Asterisk from trying over and over again, and eventually
causing the system to crash.  (issue #8285, john)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@59357 65c4cc65-6c06-0410-ace0-fbb531ad65f3

rtp.c

diff --git a/rtp.c b/rtp.c
index 13dab38dccaacebca0287a1d131be63b1af8fef8..ce85b45510105d4ef3b217aac2926650ace3b6b6 100644 (file)
--- a/rtp.c
+++ b/rtp.c
@@ -386,10 +386,12 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
                                        0, (struct sockaddr *)&sin, &len);
        
        if (res < 0) {
-               if (errno != EAGAIN)
-                       ast_log(LOG_WARNING, "RTP Read error: %s\n", strerror(errno));
                if (errno == EBADF)
                        CRASH;
+               if (errno != EAGAIN) {
+                       ast_log(LOG_WARNING, "RTP Read error: %s.  Hanging up now.\n", strerror(errno));
+                       return NULL;
+               }
                return &null_frame;
        }
 
@@ -453,10 +455,12 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
 
        rtpheader = (unsigned int *)(rtp->rawdata + AST_FRIENDLY_OFFSET);
        if (res < 0) {
-               if (errno != EAGAIN)
-                       ast_log(LOG_WARNING, "RTP Read error: %s\n", strerror(errno));
                if (errno == EBADF)
                        CRASH;
+               if (errno != EAGAIN) {
+                       ast_log(LOG_WARNING, "RTP Read error: %s.  Hanging up now.\n", strerror(errno));
+                       return NULL;
+               }
                return &null_frame;
        }
        if (res < hdrlen) {