From 0bbbee96b742e4ad0fd5e1d3c33e4bd2247e4445 Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Fri, 11 Dec 2009 16:49:21 +0000 Subject: retry IRC if name in use, resize to fit ubuntu's giant default font, scroll debug.log, pause gen during initial block download --- irc.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'irc.cpp') diff --git a/irc.cpp b/irc.cpp index 8ac38380eb..8e8510859f 100644 --- a/irc.cpp +++ b/irc.cpp @@ -121,20 +121,20 @@ bool RecvLineIRC(SOCKET hSocket, string& strLine) } } -bool RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL) +int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL) { loop { string strLine; if (!RecvLineIRC(hSocket, strLine)) - return false; + return 0; printf("IRC %s\n", strLine.c_str()); if (psz1 && strLine.find(psz1) != -1) - return true; + return 1; if (psz2 && strLine.find(psz2) != -1) - return true; + return 2; if (psz3 && strLine.find(psz3) != -1) - return true; + return 3; } } @@ -159,6 +159,7 @@ void ThreadIRCSeed(void* parg) SetThreadPriority(THREAD_PRIORITY_NORMAL); int nErrorWait = 10; int nRetryWait = 10; + bool fNameInUse = false; bool fTOR = (fUseProxy && addrProxy.port == htons(9050)); while (!fShutdown) @@ -194,7 +195,7 @@ void ThreadIRCSeed(void* parg) } string strMyName; - if (addrLocalHost.IsRoutable() && !fUseProxy) + if (addrLocalHost.IsRoutable() && !fUseProxy && !fNameInUse) strMyName = EncodeAddress(addrLocalHost); else strMyName = strprintf("x%u", GetRand(1000000000)); @@ -203,10 +204,18 @@ void ThreadIRCSeed(void* parg) Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str()); Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str()); - if (!RecvUntil(hSocket, " 004 ")) + int nRet = RecvUntil(hSocket, " 004 ", " 433 "); + if (nRet != 1) { closesocket(hSocket); hSocket = INVALID_SOCKET; + if (nRet == 2) + { + printf("IRC name already in use\n"); + fNameInUse = true; + Wait(10); + continue; + } nErrorWait = nErrorWait * 11 / 10; if (Wait(nErrorWait += 60)) continue; -- cgit v1.2.3