aboutsummaryrefslogtreecommitdiff
path: root/irc.cpp
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-12-11 16:49:21 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-12-11 16:49:21 +0000
commit4ea3f3da1a0c00ea74e85c31a22ea94d18bbdf06 (patch)
tree4f9bb0b8598035b704a8abe08a292e8465e7c1c6 /irc.cpp
parentb075bbf9862df41cdf5265026ba787b7d0fecb07 (diff)
retry IRC if name in use,
resize to fit ubuntu's giant default font, scroll debug.log, pause gen during initial block download git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@44 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'irc.cpp')
-rw-r--r--irc.cpp23
1 files changed, 16 insertions, 7 deletions
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;