]> granicus.if.org Git - rtmpdump/commitdiff
Fix rtmpt read hangs
authorhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Wed, 16 Mar 2011 12:11:21 +0000 (12:11 +0000)
committerhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Wed, 16 Mar 2011 12:11:21 +0000 (12:11 +0000)
git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@561 400ebc74-4327-4243-bc38-086b20814532

librtmp/rtmp.c

index e2925a72688f807ee61fa4d6e0a05e791b9c8ac5..3042c7f0327ffbbed59a27b810ed7b09d2b00fa5 100644 (file)
@@ -877,7 +877,13 @@ RTMP_Connect1(RTMP *r, RTMPPacket *cp)
       r->m_clientID.av_val = NULL;
       r->m_clientID.av_len = 0;
       HTTP_Post(r, RTMPT_OPEN, "", 1);
-      HTTP_read(r, 1);
+      if (HTTP_read(r, 1) != 0)
+       {
+         r->m_msgCounter = 0;
+         RTMP_Log(RTMP_LOGDEBUG, "%s, Could not connect for handshake", __FUNCTION__);
+         RTMP_Close(r);
+         return 0;
+       }
       r->m_msgCounter = 0;
     }
   RTMP_Log(RTMP_LOGDEBUG, "%s, ... connected, handshaking", __FUNCTION__);
@@ -1284,7 +1290,12 @@ ReadN(RTMP *r, char *buffer, int n)
                      return 0;
                    }
                }
-             HTTP_read(r, 0);
+             if (HTTP_read(r, 0) == -1)
+               {
+                 RTMP_Log(RTMP_LOGDEBUG, "%s, No valid HTTP response found", __FUNCTION__);
+                 RTMP_Close(r);
+                 return 0;
+               }
            }
          if (r->m_resplen && !r->m_sb.sb_size)
            RTMPSockBuf_Fill(&r->m_sb);
@@ -3670,7 +3681,7 @@ HTTP_read(RTMP *r, int fill)
   if (fill)
     RTMPSockBuf_Fill(&r->m_sb);
   if (r->m_sb.sb_size < 144)
-    return -1;
+    return -2;
   if (strncmp(r->m_sb.sb_start, "HTTP/1.1 200 ", 13))
     return -1;
   ptr = r->m_sb.sb_start + sizeof("HTTP/1.1 200");