[prev in list] [next in list] [prev in thread] [next in thread]
List: helix-filesystem-dev
Subject: [Filesystem-dev] CR: http file object reuse bug fix
From: Qiang Luo <qluo () real ! com>
Date: 2011-07-08 20:20:36
Message-ID: 4E176694.4060502 () real ! com
[Download RAW message or body]
This is a MIME-formatted message. If you see this text it means that your
E-mail software does not support MIME-formatted messages.
Overview:
Henry added the new "http file object reuse" feature to the httpfsys.
There can be cases where the scheme will fail if the client
inadvertently reuses the file object for a new url with a different
host. In this CR, we detect such "host change" in function AnalyzeURL()
and close the m_pSocket. The BeginGet() function will take care the rest.
Suggested reviewer: Henry Xing
Branch:
Head, 310, 361
Files modified:
/cvsroot/filesystem/http/httpfsys.cpp
/cvsroot/filesystem/http/httpfsys.h
Please review attached diff.
Thanks,
Qiang
["httpfsys_diff.txt" (text/plain)]
Index: httpfsys.cpp
===================================================================
RCS file: /cvsroot/filesystem/http/httpfsys.cpp,v
retrieving revision 1.109.2.34
diff -u -r1.109.2.34 httpfsys.cpp
--- httpfsys.cpp 8 Jul 2011 10:30:55 -0000 1.109.2.34
+++ httpfsys.cpp 8 Jul 2011 20:18:56 -0000
@@ -1109,6 +1109,7 @@
, m_bDiscardOrphanLFInChunkedData(FALSE)
/*************************/
{
+ m_strLastHost.Empty();
SetSupportsByteRanges(m_bSupportsByteRanges);
}
@@ -9422,7 +9423,18 @@
}
HX_RELEASE(pRequest);
}
- AnalyzeURL(pURL);
+
+ theErr = AnalyzeURL(pURL);
+ if (FAILED(theErr) && m_pSocket)
+ {
+ // if the host changed, we need to close the socket
+ m_pSocket->Close();
+ HX_RELEASE(m_pSocket);
+
+ // mask the error
+ theErr = HXR_OK;
+ }
+
CacheSupport_OpenFile();
if (m_bCached)
{
@@ -9576,8 +9588,11 @@
HX_UNLOCK(m_pMutex);
}
+
HX_RESULT CHTTPFileObject::AnalyzeURL(const char* url)
{
+ HX_RESULT retVal = HXR_OK;
+
char* pTemp = NULL;
_InitializeChunkyRes(url);
@@ -9714,6 +9729,17 @@
m_strHost = pURL;
HX_VECTOR_DELETE(pOrigURL);
- return HXR_OK;
+
+ if (!m_strLastHost.IsEmpty() && m_strHost != m_strLastHost)
+ {
+ // AnalyzeURL() is called from OpenURL
+ // return error since the host is changed
+ retVal = HXR_FAIL;
+ }
+
+ // save none proxied host to the m_strLastHost
+ m_strLastHost = m_strHost;
+
+ return retVal;
}
Index: httpfsys.h
===================================================================
RCS file: /cvsroot/filesystem/http/httpfsys.h,v
retrieving revision 1.40.2.8
diff -u -r1.40.2.8 httpfsys.h
--- httpfsys.h 8 Jul 2011 10:03:00 -0000 1.40.2.8
+++ httpfsys.h 8 Jul 2011 20:18:56 -0000
@@ -914,6 +914,7 @@
UINT32 m_ulBufferAheadAmount;
CHXString m_strHost;
+ CHXString m_strLastHost;
CHXString m_strRequest;
CHXString m_strResource;
CHXString m_strMimeType;
_______________________________________________
Filesystem-dev mailing list
Filesystem-dev@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/filesystem-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic