aboutsummaryrefslogtreecommitdiff
path: root/util.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 /util.cpp
parentb075bbf9862df41cdf5265026ba787b7d0fecb07 (diff)
downloadbitcoin-4ea3f3da1a0c00ea74e85c31a22ea94d18bbdf06.tar.xz
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 'util.cpp')
-rw-r--r--util.cpp55
1 files changed, 32 insertions, 23 deletions
diff --git a/util.cpp b/util.cpp
index 305db5ceeb..f5f2797fec 100644
--- a/util.cpp
+++ b/util.cpp
@@ -11,6 +11,7 @@ bool fDebug = false;
bool fPrintToDebugger = false;
bool fPrintToConsole = false;
char pszSetDataDir[MAX_PATH] = "";
+bool fShutdown = false;
@@ -53,19 +54,6 @@ public:
for (int i = 0; i < CRYPTO_num_locks(); i++)
delete ppmutexOpenSSL[i];
OPENSSL_free(ppmutexOpenSSL);
-
- // Close sockets
- foreach(CNode* pnode, vNodes)
- if (pnode->hSocket != INVALID_SOCKET)
- closesocket(pnode->hSocket);
- if (hListenSocket != INVALID_SOCKET)
- if (closesocket(hListenSocket) == SOCKET_ERROR)
- printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError());
-
-#ifdef __WXMSW__
- // Shutdown Windows Sockets
- WSACleanup();
-#endif
}
}
instance_of_cinit;
@@ -416,16 +404,6 @@ void PrintException(std::exception* pex, const char* pszThread)
-int GetFilesize(FILE* file)
-{
- int nSavePos = ftell(file);
- int nFilesize = -1;
- if (fseek(file, 0, SEEK_END) == 0)
- nFilesize = ftell(file);
- fseek(file, nSavePos, SEEK_SET);
- return nFilesize;
-}
-
void GetDataDir(char* pszDir)
{
// pszDir must be at least MAX_PATH length.
@@ -465,6 +443,37 @@ string GetDataDir()
return pszDir;
}
+int GetFilesize(FILE* file)
+{
+ int nSavePos = ftell(file);
+ int nFilesize = -1;
+ if (fseek(file, 0, SEEK_END) == 0)
+ nFilesize = ftell(file);
+ fseek(file, nSavePos, SEEK_SET);
+ return nFilesize;
+}
+
+void ShrinkDebugFile()
+{
+ // Scroll debug.log if it's getting too big
+ string strFile = GetDataDir() + "/debug.log";
+ FILE* file = fopen(strFile.c_str(), "r");
+ if (file && GetFilesize(file) > 10 * 1000000)
+ {
+ // Restart the file with some of the end
+ char pch[200000];
+ fseek(file, -sizeof(pch), SEEK_END);
+ int nBytes = fread(pch, 1, sizeof(pch), file);
+ fclose(file);
+ if (file = fopen(strFile.c_str(), "w"))
+ {
+ fwrite(pch, 1, nBytes, file);
+ fclose(file);
+ }
+ }
+}
+
+