.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
This commit is contained in:
cxl 2011-02-18 19:06:48 +00:00
parent 0729119acf
commit 4eb45634f1
2 changed files with 6 additions and 39 deletions

View file

@ -1,11 +1,10 @@
#include "CtrlLib.h"
NAMESPACE_UPP
#define LLOG(x) // RLOG(x)
#define SLOWANIMATION _DBG_
// #define SLOWANIMATION
#define IMAGECLASS CtrlImg
#define IMAGEFILE <CtrlLib/Ctrl.iml>

View file

@ -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<uintptr_t> thread_index;
static Array<String> thread_errors;
static Vector<int> 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)