bug 752648 - fix regression with restarting due to tls intolerance r=honzab

--HG--
extra : rebase_source : 8155ae4c221df4c5931816fb8773123cc37dd148
This commit is contained in:
Patrick McManus 2012-05-14 13:25:28 -04:00
Родитель c2b17d4018
Коммит 285f985254
7 изменённых файлов: 28 добавлений и 7 удалений

Просмотреть файл

@ -66,7 +66,7 @@ class SpdySession : public nsAHttpTransaction
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSAHTTPTRANSACTION NS_DECL_NSAHTTPTRANSACTION
NS_DECL_NSAHTTPCONNECTION NS_DECL_NSAHTTPCONNECTION(mConnection)
NS_DECL_NSAHTTPSEGMENTREADER NS_DECL_NSAHTTPSEGMENTREADER
NS_DECL_NSAHTTPSEGMENTWRITER NS_DECL_NSAHTTPSEGMENTWRITER

Просмотреть файл

@ -153,9 +153,13 @@ public:
// Read and write class of transaction that is carried on this connection // Read and write class of transaction that is carried on this connection
virtual nsAHttpTransaction::Classifier Classification() = 0; virtual nsAHttpTransaction::Classifier Classification() = 0;
virtual void Classify(nsAHttpTransaction::Classifier newclass) = 0; virtual void Classify(nsAHttpTransaction::Classifier newclass) = 0;
// The number of transaction bytes written out on this HTTP Connection, does
// not count CONNECT tunnel setup
virtual PRInt64 BytesWritten() = 0;
}; };
#define NS_DECL_NSAHTTPCONNECTION \ #define NS_DECL_NSAHTTPCONNECTION(fwdObject) \
nsresult OnHeadersAvailable(nsAHttpTransaction *, nsHttpRequestHead *, nsHttpResponseHead *, bool *reset); \ nsresult OnHeadersAvailable(nsAHttpTransaction *, nsHttpRequestHead *, nsHttpResponseHead *, bool *reset); \
nsresult ResumeSend(); \ nsresult ResumeSend(); \
nsresult ResumeRecv(); \ nsresult ResumeRecv(); \
@ -176,6 +180,8 @@ public:
nsISocketTransport *Transport(); \ nsISocketTransport *Transport(); \
PRUint32 CancelPipeline(nsresult originalReason); \ PRUint32 CancelPipeline(nsresult originalReason); \
nsAHttpTransaction::Classifier Classification(); \ nsAHttpTransaction::Classifier Classification(); \
void Classify(nsAHttpTransaction::Classifier); void Classify(nsAHttpTransaction::Classifier); \
PRInt64 BytesWritten() \
{ return fwdObject ? (fwdObject)->BytesWritten() : 0; }
#endif // nsAHttpConnection_h__ #endif // nsAHttpConnection_h__

Просмотреть файл

@ -79,6 +79,7 @@ nsHttpConnection::nsHttpConnection()
, mCurrentBytesRead(0) , mCurrentBytesRead(0)
, mMaxBytesRead(0) , mMaxBytesRead(0)
, mTotalBytesRead(0) , mTotalBytesRead(0)
, mTotalBytesWritten(0)
, mKeepAlive(true) // assume to keep-alive by default , mKeepAlive(true) // assume to keep-alive by default
, mKeepAliveMask(true) , mKeepAliveMask(true)
, mSupportsPipelining(false) // assume low-grade server , mSupportsPipelining(false) // assume low-grade server
@ -1194,8 +1195,11 @@ nsHttpConnection::OnReadSegment(const char *buf,
mSocketOutCondition = rv; mSocketOutCondition = rv;
else if (*countRead == 0) else if (*countRead == 0)
mSocketOutCondition = NS_BASE_STREAM_CLOSED; mSocketOutCondition = NS_BASE_STREAM_CLOSED;
else else {
mSocketOutCondition = NS_OK; // reset condition mSocketOutCondition = NS_OK; // reset condition
if (!mProxyConnectInProgress)
mTotalBytesWritten += *countRead;
}
return mSocketOutCondition; return mSocketOutCondition;
} }

Просмотреть файл

@ -182,6 +182,8 @@ public:
// When the connection is active this is called every second // When the connection is active this is called every second
void ReadTimeoutTick(); void ReadTimeoutTick();
PRInt64 BytesWritten() { return mTotalBytesWritten; }
private: private:
// called to cause the underlying socket to start speaking SSL // called to cause the underlying socket to start speaking SSL
nsresult ProxyStartSSL(); nsresult ProxyStartSSL();
@ -239,6 +241,7 @@ private:
PRInt64 mCurrentBytesRead; // data read per activation PRInt64 mCurrentBytesRead; // data read per activation
PRInt64 mMaxBytesRead; // max read in 1 activation PRInt64 mMaxBytesRead; // max read in 1 activation
PRInt64 mTotalBytesRead; // total data read PRInt64 mTotalBytesRead; // total data read
PRInt64 mTotalBytesWritten; // does not include CONNECT tunnel
nsRefPtr<nsIAsyncInputStream> mInputOverflow; nsRefPtr<nsIAsyncInputStream> mInputOverflow;

Просмотреть файл

@ -379,7 +379,7 @@ private:
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSAHTTPCONNECTION NS_DECL_NSAHTTPCONNECTION(mConn)
nsConnectionHandle(nsHttpConnection *conn) { NS_ADDREF(mConn = conn); } nsConnectionHandle(nsHttpConnection *conn) { NS_ADDREF(mConn = conn); }
virtual ~nsConnectionHandle(); virtual ~nsConnectionHandle();

Просмотреть файл

@ -53,7 +53,7 @@ class nsHttpPipeline : public nsAHttpConnection
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSAHTTPCONNECTION NS_DECL_NSAHTTPCONNECTION(mConnection)
NS_DECL_NSAHTTPTRANSACTION NS_DECL_NSAHTTPTRANSACTION
NS_DECL_NSAHTTPSEGMENTREADER NS_DECL_NSAHTTPSEGMENTREADER

Просмотреть файл

@ -725,7 +725,15 @@ nsHttpTransaction::Close(nsresult reason)
// mReceivedData == FALSE. (see bug 203057 for more info.) // mReceivedData == FALSE. (see bug 203057 for more info.)
// //
if (reason == NS_ERROR_NET_RESET || reason == NS_OK) { if (reason == NS_ERROR_NET_RESET || reason == NS_OK) {
if (!mReceivedData && (!mSentData || connReused || mPipelinePosition)) {
// reallySentData is meant to separate the instances where data has
// been sent by this transaction but buffered at a higher level while
// a TLS session (perhaps via a tunnel) is setup.
bool reallySentData =
mSentData && (!mConnection || mConnection->BytesWritten());
if (!mReceivedData &&
(!reallySentData || connReused || mPipelinePosition)) {
// if restarting fails, then we must proceed to close the pipe, // if restarting fails, then we must proceed to close the pipe,
// which will notify the channel that the transaction failed. // which will notify the channel that the transaction failed.