From 4eb45634f1b06f6fb421f92e1bdc04f0a97e854e Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 18 Feb 2011 19:06:48 +0000 Subject: [PATCH] .CtrlLib: removed slow animation debugging mode, .Web: refactored global error string in Socket git-svn-id: svn://ultimatepp.org/upp/trunk@3224 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlLib/CtrlUtil.cpp | 3 +-- uppsrc/Web/socket.cpp | 42 +++++-------------------------------- 2 files changed, 6 insertions(+), 39 deletions(-) diff --git a/uppsrc/CtrlLib/CtrlUtil.cpp b/uppsrc/CtrlLib/CtrlUtil.cpp index 65ace41c7..d0a12eec4 100644 --- a/uppsrc/CtrlLib/CtrlUtil.cpp +++ b/uppsrc/CtrlLib/CtrlUtil.cpp @@ -1,11 +1,10 @@ #include "CtrlLib.h" - NAMESPACE_UPP #define LLOG(x) // RLOG(x) -#define SLOWANIMATION _DBG_ +// #define SLOWANIMATION #define IMAGECLASS CtrlImg #define IMAGEFILE diff --git a/uppsrc/Web/socket.cpp b/uppsrc/Web/socket.cpp index 258ad2325..f65555e9b 100644 --- a/uppsrc/Web/socket.cpp +++ b/uppsrc/Web/socket.cpp @@ -792,51 +792,19 @@ String Socket::PeekUntil(char term, int timeout_msec, int maxlen) return s; } -static String& SockErrorText() -{ - static StaticCriticalSection csect; - CriticalSection::Lock lock(csect); - static Index thread_index; - static Array thread_errors; - static Vector error_ticks; - int t = msecs(); - if(thread_index.GetCount() >= 1000) { - for(int i = thread_index.GetCount(); --i >= 0;) - if(t - error_ticks[i] >= 60000) { - thread_index.Remove(i); - thread_errors.Remove(i); - error_ticks.Remove(i); - } - } -#ifdef PLATFORM_WIN32 - uintptr_t tid = GetCurrentThreadId(); -#else - #ifdef _MULTITHREADED - uintptr_t tid = (uintptr_t)Thread::GetCurrentId(); - #else - uintptr_t tid = 0; - #endif -#endif - int f = thread_index.Find(tid); - if(f < 0) { - f = thread_index.GetCount(); - thread_index.Add(tid); - thread_errors.Add(); - error_ticks.Add(); - } - error_ticks[f] = t; - return thread_errors[f]; -} +static thread__ char s_errortext[512]; +static thread__ int s_errortextlen; String Socket::GetErrorText() { - return SockErrorText(); + return String(s_errortext, s_errortextlen); } void Socket::SetErrorText(String text) { SLOG("Socket::SetLastErrorText = " << text); - SockErrorText() = text; + s_errortextlen = min(text.GetLength(), 511); + memcpy(s_errortext, ~text, s_errortextlen + 1); } void Socket::SetSockError(SOCKET socket, const char *context)