aboutsummaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-11-18 19:19:41 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-11-18 19:19:41 +0000
commitc5c7911dab8732861affbe66849a100da62f7464 (patch)
treebfbb16bc8fbcb4911a24a5e32f9f4c3c280f392c /util.h
parentb349e3dca89dfff5fe70669f9fd3f3a1ec60a498 (diff)
downloadbitcoin-c5c7911dab8732861affbe66849a100da62f7464.tar.xz
bugfix Db::open/close and zombie sockets bugs fix double-close of socket handle,
keep databases open, close db cursors, initial block download in batches of 500 blocks, fix misc warnings, subver linux-test8 git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@40 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'util.h')
-rw-r--r--util.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/util.h b/util.h
index ddac449441..9366e66e93 100644
--- a/util.h
+++ b/util.h
@@ -57,9 +57,11 @@ inline T& REF(const T& val)
#ifdef __WXMSW__
#define MSG_NOSIGNAL 0
#define MSG_DONTWAIT 0
+#ifndef UINT64_MAX
#define UINT64_MAX _UI64_MAX
#define INT64_MAX _I64_MAX
#define INT64_MIN _I64_MIN
+#endif
#else
#define WSAGetLastError() errno
#define WSAEWOULDBLOCK EWOULDBLOCK
@@ -67,7 +69,7 @@ inline T& REF(const T& val)
#define WSAEINTR EINTR
#define WSAEINPROGRESS EINPROGRESS
#define WSAEADDRINUSE EADDRINUSE
-#define closesocket(s) close(s)
+#define WSAENOTSOCK EBADF
#define INVALID_SOCKET (SOCKET)(~0)
#define SOCKET_ERROR -1
typedef u_int SOCKET;
@@ -80,6 +82,23 @@ typedef u_int SOCKET;
#define Beep(n1,n2) (0)
#endif
+inline int myclosesocket(SOCKET& hSocket)
+{
+ if (hSocket == INVALID_SOCKET)
+ return WSAENOTSOCK;
+#ifdef __WXMSW__
+ int ret = closesocket(hSocket);
+#else
+ int ret = close(hSocket);
+#endif
+ hSocket = INVALID_SOCKET;
+ return ret;
+}
+#define closesocket(s) myclosesocket(s)
+
+
+
+
@@ -149,7 +168,7 @@ public:
bool TryEnter() { return mutex.TryLock() == wxMUTEX_NO_ERROR; }
#endif
public:
- char* pszFile;
+ const char* pszFile;
int nLine;
};