From: <ps...@us...> - 2009-07-25 22:31:20
|
Revision: 1579 http://znc.svn.sourceforge.net/znc/?rev=1579&view=rev Author: psychon Date: 2009-07-25 22:31:11 +0000 (Sat, 25 Jul 2009) Log Message: ----------- Fix a bug if a user uses /version /version generates a 005 server reply. We used to cache this reply in the raw buffer and the next user who logs in then received the same 005 reply multiple times. We fix this by adding CBuffer::UpdateExactLine() which does nothing if the exact same line is already in the buffer. The only place where we (currently?) use this is the raw 005 reply. This should fix sf bug #2817124. Modified Paths: -------------- trunk/Buffer.cpp trunk/Buffer.h trunk/IRCSock.cpp trunk/User.h Modified: trunk/Buffer.cpp =================================================================== --- trunk/Buffer.cpp 2009-07-23 16:59:41 UTC (rev 1578) +++ trunk/Buffer.cpp 2009-07-25 22:31:11 UTC (rev 1579) @@ -54,6 +54,15 @@ return AddLine(sPre, sPost, bIncNick); } +int CBuffer::UpdateExactLine(const CString& sPre, const CString& sPost, bool bIncNick) { + for (iterator it = begin(); it != end(); it++) { + if (it->GetPre() == sPre && it->GetPost() == sPost) + return size(); + } + + return AddLine(sPre, sPost, bIncNick); +} + bool CBuffer::GetLine(const CString& sTarget, CString& sRet, unsigned int uIdx) const { if (uIdx >= size()) { return false; Modified: trunk/Buffer.h =================================================================== --- trunk/Buffer.h 2009-07-23 16:59:41 UTC (rev 1578) +++ trunk/Buffer.h 2009-07-25 22:31:11 UTC (rev 1579) @@ -43,6 +43,8 @@ int AddLine(const CString& sPre, const CString& sPost, bool bIncNick = true); /// Same as AddLine, but if there is already a line with sPre it is replaced. int UpdateLine(const CString& sPre, const CString& sPost, bool bIncNick = true); + /// Same as UpdateLine, but does nothing if this exact line already exists + int UpdateExactLine(const CString& sPre, const CString& sPost, bool bIncNick = true); bool GetNextLine(const CString& sTarget, CString& sRet); bool GetLine(const CString& sTarget, CString& sRet, unsigned int uIdx) const; bool IsEmpty() const { return empty(); } Modified: trunk/IRCSock.cpp =================================================================== --- trunk/IRCSock.cpp 2009-07-23 16:59:41 UTC (rev 1578) +++ trunk/IRCSock.cpp 2009-07-25 22:31:11 UTC (rev 1579) @@ -139,7 +139,7 @@ } case 5: ParseISupport(sRest); - m_pUser->AddRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); + m_pUser->UpdateExactRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); break; case 2: case 3: Modified: trunk/User.h =================================================================== --- trunk/User.h 2009-07-23 16:59:41 UTC (rev 1578) +++ trunk/User.h 2009-07-25 22:31:11 UTC (rev 1579) @@ -73,13 +73,16 @@ // Buffers void AddRawBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_RawBuffer.AddLine(sPre, sPost, bIncNick); } + void UpdateRawBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_RawBuffer.UpdateLine(sPre, sPost, bIncNick); } + void UpdateExactRawBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_RawBuffer.UpdateExactLine(sPre, sPost, bIncNick); } + void ClearRawBuffer() { m_RawBuffer.Clear(); } + void AddMotdBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_MotdBuffer.AddLine(sPre, sPost, bIncNick); } + void UpdateMotdBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_MotdBuffer.UpdateLine(sPre, sPost, bIncNick); } + void ClearMotdBuffer() { m_MotdBuffer.Clear(); } + void AddQueryBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_QueryBuffer.AddLine(sPre, sPost, bIncNick); } - void UpdateRawBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_RawBuffer.UpdateLine(sPre, sPost, bIncNick); } - void UpdateMotdBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_MotdBuffer.UpdateLine(sPre, sPost, bIncNick); } void UpdateQueryBuffer(const CString& sPre, const CString& sPost, bool bIncNick = true) { m_QueryBuffer.UpdateLine(sPre, sPost, bIncNick); } - void ClearRawBuffer() { m_RawBuffer.Clear(); } - void ClearMotdBuffer() { m_MotdBuffer.Clear(); } void ClearQueryBuffer() { m_QueryBuffer.Clear(); } // !Buffers This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |