bug 447866 - patch pre.1 for empty nsHttpPipeline::TakeSubTransactions r=honzab
authorPatrick McManus <mcmanus@ducksong.com>
Thu, 22 Mar 2012 19:39:28 -0400
changeset 91907 f8656bbf0818126745f41119529b8be3a95bc4ad
parent 91906 1d1614bb7b3924eb336844c06e6d76d23258bc34
child 91908 3dd62d76cc6d73fcfc47f6d5677099cf6aad4c1c
push idunknown
push userunknown
push dateunknown
reviewershonzab
bugs447866
milestone14.0a1
bug 447866 - patch pre.1 for empty nsHttpPipeline::TakeSubTransactions r=honzab
netwerk/protocol/http/nsHttpConnection.cpp
netwerk/protocol/http/nsHttpPipeline.cpp
--- a/netwerk/protocol/http/nsHttpConnection.cpp
+++ b/netwerk/protocol/http/nsHttpConnection.cpp
@@ -222,23 +222,26 @@ nsHttpConnection::StartSpdy()
         // as the first stream.
         mSpdySession = new SpdySession(mTransaction,
                                        mSocketTransport,
                                        mPriority);
         LOG(("nsHttpConnection::StartSpdy moves single transaction %p "
              "into SpdySession %p\n", mTransaction.get(), mSpdySession.get()));
     }
     else {
-        NS_ABORT_IF_FALSE(!list.IsEmpty(), "sub transaction list empty");
-        
         PRInt32 count = list.Length();
 
         LOG(("nsHttpConnection::StartSpdy moving transaction list len=%d "
              "into SpdySession %p\n", count, mSpdySession.get()));
 
+        if (!count) {
+            mTransaction->Close(NS_ERROR_ABORT);
+            return;
+        }
+
         for (PRInt32 index = 0; index < count; ++index) {
             if (!mSpdySession) {
                 mSpdySession = new SpdySession(list[index],
                                                mSocketTransport,
                                                mPriority);
             }
             else {
                 // AddStream() cannot fail
@@ -525,17 +528,17 @@ nsHttpConnection::DontReuse()
         mSpdySession->DontReuse();
 }
 
 bool
 nsHttpConnection::CanReuse()
 {
     bool canReuse;
     
-    if (mUsingSpdy)
+    if (mSpdySession)
         canReuse = mSpdySession->CanReuse();
     else
         canReuse = IsKeepAlive();
     
     canReuse = canReuse && (IdleTime() < mIdleTimeout) && IsAlive();
 
     // An idle persistent connection should not have data waiting to be read
     // before a request is sent. Data here is likely a 408 timeout response
@@ -555,17 +558,18 @@ nsHttpConnection::CanReuse()
 
 bool
 nsHttpConnection::CanDirectlyActivate()
 {
     // return true if a new transaction can be addded to ths connection at any
     // time through Activate(). In practice this means this is a healthy SPDY
     // connection with room for more concurrent streams.
     
-    return UsingSpdy() && CanReuse() && mSpdySession->RoomForMoreStreams();
+    return UsingSpdy() && CanReuse() &&
+        mSpdySession && mSpdySession->RoomForMoreStreams();
 }
 
 PRIntervalTime
 nsHttpConnection::IdleTime()
 {
     return mSpdySession ?
         mSpdySession->IdleTime() : (PR_IntervalNow() - mLastReadTime);
 }
--- a/netwerk/protocol/http/nsHttpPipeline.cpp
+++ b/netwerk/protocol/http/nsHttpPipeline.cpp
@@ -368,22 +368,16 @@ nsresult
 nsHttpPipeline::TakeSubTransactions(
     nsTArray<nsRefPtr<nsAHttpTransaction> > &outTransactions)
 {
     LOG(("nsHttpPipeline::TakeSubTransactions [this=%p]\n", this));
 
     if (mResponseQ.Length() || mRequestIsPartial)
         return NS_ERROR_ALREADY_OPENED;
 
-    // request queue could be empty if it was already canceled, in which
-    // case it is safe to treat this as a case without any
-    // sub-transactions.
-    if (!mRequestQ.Length())
-        return NS_ERROR_NOT_IMPLEMENTED;
-
     PRInt32 i, count = mRequestQ.Length();
     for (i = 0; i < count; ++i) {
         nsAHttpTransaction *trans = Request(i);
         outTransactions.AppendElement(trans);
         NS_RELEASE(trans);
     }
     mRequestQ.Clear();