Commit 8f145e4c authored by unknown's avatar unknown

wl1744 - ndb on windows


ndb/config/win-lib.am:
  removed TLS stuff (which I don't know what it is)
ndb/include/kernel/signaldata/UtilLock.hpp:
  Made stuff public
ndb/include/ndb_global.h.in:
  better defines for strcasecmp
ndb/src/common/transporter/Transporter.cpp:
  Use NDB_INVALID_SOCKET
ndb/src/common/util/SocketClient.cpp:
  Use NDB_INVALID_SOCKET
ndb/src/kernel/vm/Callback.hpp:
  Move callback into SimulatedBlock as it for some mysterious reason
    otherwise got sizeof()=0 on windows
ndb/src/kernel/vm/Configuration.cpp:
  Removed extra (bug) semi-colon
ndb/src/kernel/vm/Mutex.cpp:
  Move callback into SimulatedBlock as it for some mysterious reason
    otherwise got sizeof()=0 on windows
ndb/src/kernel/vm/Mutex.hpp:
  Move callback into SimulatedBlock as it for some mysterious reason
    otherwise got sizeof()=0 on windows
ndb/src/kernel/vm/SectionReader.cpp:
  Use correct struct-type
ndb/src/kernel/vm/SectionReader.hpp:
  Use correct struct-type
ndb/src/kernel/vm/SimulatedBlock.cpp:
  Move callback into SimulatedBlock as it for some mysterious reason
    otherwise got sizeof()=0 on windows
ndb/src/kernel/vm/SimulatedBlock.hpp:
  Move callback into SimulatedBlock as it for some mysterious reason
    otherwise got sizeof()=0 on windows
ndb/src/mgmclient/Makefile.am:
  Add mgm client to windoze
ndb/test/src/Makefile.am:
  Fix lib
parent c63ae27e
...@@ -19,8 +19,6 @@ CFG=@name@ - Win32 Debug ...@@ -19,8 +19,6 @@ CFG=@name@ - Win32 Debug
!MESSAGE !MESSAGE
!MESSAGE "@name@ - Win32 Release" (based on "Win32 (x86) Static Library") !MESSAGE "@name@ - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "@name@ - Win32 Debug" (based on "Win32 (x86) Static Library") !MESSAGE "@name@ - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE "@name@ - Win32 TLS_DEBUG" (based on "Win32 (x86) Static Library")
!MESSAGE "@name@ - Win32 TLS" (based on "Win32 (x86) Static Library")
!MESSAGE !MESSAGE
# Begin Project # Begin Project
...@@ -54,7 +52,7 @@ BSC32=bscmake.exe ...@@ -54,7 +52,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LIB32=xilink6.exe -lib LIB32=xilink6.exe -lib
# ADD BASE LIB32 /nologo # ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\lib_release\@name@.lib" # ADD LIB32 /nologo /out:".\lib_release\@name@.lib"
@release_libs@ @release_libs@
!ELSEIF "$(CFG)" == "@name@ - Win32 Debug" !ELSEIF "$(CFG)" == "@name@ - Win32 Debug"
...@@ -81,72 +79,15 @@ BSC32=bscmake.exe ...@@ -81,72 +79,15 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LIB32=xilink6.exe -lib LIB32=xilink6.exe -lib
# ADD BASE LIB32 /nologo # ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\lib_debug\@name@.lib" # ADD LIB32 /nologo /out:".\lib_debug\@name@.lib"
@debug_libs@ @debug_libs@
!ELSEIF "$(CFG)" == "@name@ - Win32 TLS_DEBUG"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "@name@___Win32_TLS_DEBUG"
# PROP BASE Intermediate_Dir "@name@___Win32_TLS_DEBUG"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "@name@___Win32_TLS_DEBUG"
# PROP Intermediate_Dir "@name@___Win32_TLS_DEBUG"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G6 /MTd /W3 /Z7 /Od /Gf /D "WIN32" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_WINDOWS" /FD /c
# SUBTRACT BASE CPP /YX
# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /Gf /D "WIN32" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_WINDOWS" /D "USE_TLS" /FD /c
# ADD BASE CPP @includes@
# ADD CPP @includes@
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"..\lib_debug\@name@_tls.lib"
# ADD LIB32 /nologo /out:"..\lib_debug\@name@_tls.lib"
@tls_debug_libs@
!ELSEIF "$(CFG)" == "@name@ - Win32 TLS"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "@name@___Win32_TLS"
# PROP BASE Intermediate_Dir "@name@___Win32_TLS"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "@name@___Win32_TLS"
# PROP Intermediate_Dir "@name@___Win32_TLS"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G6 /MT /W3 /O2 /D "WIN32" /D "DBUG_OFF" /D "_WINDOWS" /D "NDEBUG" /FD /c
# SUBTRACT BASE CPP /YX
# ADD CPP /nologo /G6 /MT /W3 /O2 /D "WIN32" /D "DBUG_OFF" /D "_WINDOWS" /D "NDEBUG" /D "USE_TLS" /FD /c
# ADD BASE CPP @includes@
# ADD CPP @includes@
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"..\lib_release\@name@_tls.lib"
# ADD LIB32 /nologo /out:"..\lib_release\@name@_tls.lib"
@tls_release_libs@
!ENDIF !ENDIF
# Begin Target # Begin Target
# Name "@name@ - Win32 Release" # Name "@name@ - Win32 Release"
# Name "@name@ - Win32 Debug" # Name "@name@ - Win32 Debug"
# Name "@name@ - Win32 TLS_DEBUG"
# Name "@name@ - Win32 TLS"
# Begin Group "Source Files" # Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
......
...@@ -39,7 +39,7 @@ public: ...@@ -39,7 +39,7 @@ public:
enum RequestInfo { enum RequestInfo {
TryLock = 1 TryLock = 1
}; };
private: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 lockId; Uint32 lockId;
...@@ -63,7 +63,7 @@ class UtilLockConf { ...@@ -63,7 +63,7 @@ class UtilLockConf {
public: public:
STATIC_CONST( SignalLength = 4 ); STATIC_CONST( SignalLength = 4 );
private: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 lockId; Uint32 lockId;
...@@ -95,7 +95,7 @@ public: ...@@ -95,7 +95,7 @@ public:
LockAlreadyHeld = 4 LockAlreadyHeld = 4
}; };
private: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 lockId; Uint32 lockId;
...@@ -119,7 +119,7 @@ class UtilUnlockReq { ...@@ -119,7 +119,7 @@ class UtilUnlockReq {
public: public:
STATIC_CONST( SignalLength = 4 ); STATIC_CONST( SignalLength = 4 );
private: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 lockId; Uint32 lockId;
...@@ -143,7 +143,7 @@ class UtilUnlockConf { ...@@ -143,7 +143,7 @@ class UtilUnlockConf {
public: public:
STATIC_CONST( SignalLength = 3 ); STATIC_CONST( SignalLength = 3 );
private: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 lockId; Uint32 lockId;
...@@ -171,7 +171,7 @@ public: ...@@ -171,7 +171,7 @@ public:
NoSuchLock = 1, NoSuchLock = 1,
NotLockOwner = 2 NotLockOwner = 2
}; };
private: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 lockId; Uint32 lockId;
...@@ -200,7 +200,7 @@ public: ...@@ -200,7 +200,7 @@ public:
STATIC_CONST( SignalLength = 4 ); STATIC_CONST( SignalLength = 4 );
private: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 lockId; Uint32 lockId;
...@@ -229,7 +229,7 @@ public: ...@@ -229,7 +229,7 @@ public:
STATIC_CONST( SignalLength = 4 ); STATIC_CONST( SignalLength = 4 );
private: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 lockId; Uint32 lockId;
...@@ -251,7 +251,7 @@ class UtilCreateLockConf { ...@@ -251,7 +251,7 @@ class UtilCreateLockConf {
public: public:
STATIC_CONST( SignalLength = 3 ); STATIC_CONST( SignalLength = 3 );
private: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 lockId; Uint32 lockId;
...@@ -275,7 +275,7 @@ class UtilDestroyLockReq { ...@@ -275,7 +275,7 @@ class UtilDestroyLockReq {
public: public:
STATIC_CONST( SignalLength = 4 ); STATIC_CONST( SignalLength = 4 );
private: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 lockId; Uint32 lockId;
...@@ -303,7 +303,7 @@ public: ...@@ -303,7 +303,7 @@ public:
STATIC_CONST( SignalLength = 4 ); STATIC_CONST( SignalLength = 4 );
private: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 lockId; Uint32 lockId;
...@@ -325,7 +325,7 @@ class UtilDestroyLockConf { ...@@ -325,7 +325,7 @@ class UtilDestroyLockConf {
public: public:
STATIC_CONST( SignalLength = 3 ); STATIC_CONST( SignalLength = 3 );
private: public:
Uint32 senderData; Uint32 senderData;
Uint32 senderRef; Uint32 senderRef;
Uint32 lockId; Uint32 lockId;
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
#define snprintf _snprintf #define snprintf _snprintf
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
#define HAVE_STRCASECMP #define HAVE_STRCASECMP
#define strcasecmp(a,b) _strcmpi(a,b) #define strcasecmp _strcmpi
#define strncasecmp(a,b) _strncmpi(a,b) #define strncasecmp _strncmpi
#pragma warning(disable: 4503 4786) #pragma warning(disable: 4503 4786)
#else #else
#undef NDB_WIN32 #undef NDB_WIN32
......
...@@ -95,7 +95,7 @@ Transporter::connect_client() { ...@@ -95,7 +95,7 @@ Transporter::connect_client() {
return true; return true;
NDB_SOCKET_TYPE sockfd = m_socket_client->connect(); NDB_SOCKET_TYPE sockfd = m_socket_client->connect();
if (sockfd < 0) if (sockfd == NDB_INVALID_SOCKET)
return false; return false;
// send info about own id // send info about own id
......
...@@ -26,14 +26,14 @@ SocketClient::SocketClient(const char *server_name, unsigned short port, SocketA ...@@ -26,14 +26,14 @@ SocketClient::SocketClient(const char *server_name, unsigned short port, SocketA
m_auth= sa; m_auth= sa;
m_port= port; m_port= port;
m_server_name= strdup(server_name); m_server_name= strdup(server_name);
m_sockfd= -1; m_sockfd= NDB_INVALID_SOCKET;
} }
SocketClient::~SocketClient() SocketClient::~SocketClient()
{ {
if (m_server_name) if (m_server_name)
free(m_server_name); free(m_server_name);
if (m_sockfd >= 0) if (m_sockfd != NDB_INVALID_SOCKET)
NDB_CLOSE_SOCKET(m_sockfd); NDB_CLOSE_SOCKET(m_sockfd);
if (m_auth) if (m_auth)
delete m_auth; delete m_auth;
...@@ -42,7 +42,7 @@ SocketClient::~SocketClient() ...@@ -42,7 +42,7 @@ SocketClient::~SocketClient()
bool bool
SocketClient::init() SocketClient::init()
{ {
if (m_sockfd >= 0) if (m_sockfd != NDB_INVALID_SOCKET)
NDB_CLOSE_SOCKET(m_sockfd); NDB_CLOSE_SOCKET(m_sockfd);
memset(&m_servaddr, 0, sizeof(m_servaddr)); memset(&m_servaddr, 0, sizeof(m_servaddr));
...@@ -63,32 +63,32 @@ SocketClient::init() ...@@ -63,32 +63,32 @@ SocketClient::init()
NDB_SOCKET_TYPE NDB_SOCKET_TYPE
SocketClient::connect() SocketClient::connect()
{ {
if (m_sockfd < 0) if (m_sockfd == NDB_INVALID_SOCKET)
{ {
if (!init()) { if (!init()) {
#ifdef VM_TRACE #ifdef VM_TRACE
ndbout << "SocketClient::connect() failed " << m_server_name << " " << m_port << endl; ndbout << "SocketClient::connect() failed " << m_server_name << " " << m_port << endl;
#endif #endif
return -1; return NDB_INVALID_SOCKET;
} }
} }
const int r = ::connect(m_sockfd, (struct sockaddr*) &m_servaddr, sizeof(m_servaddr)); const int r = ::connect(m_sockfd, (struct sockaddr*) &m_servaddr, sizeof(m_servaddr));
if (r == -1) { if (r == -1) {
NDB_CLOSE_SOCKET(m_sockfd); NDB_CLOSE_SOCKET(m_sockfd);
m_sockfd= -1; m_sockfd= NDB_INVALID_SOCKET;
return -1; return NDB_INVALID_SOCKET;
} }
if (m_auth) { if (m_auth) {
if (!m_auth->client_authenticate(m_sockfd)) if (!m_auth->client_authenticate(m_sockfd))
{ {
NDB_CLOSE_SOCKET(m_sockfd); NDB_CLOSE_SOCKET(m_sockfd);
m_sockfd= -1; m_sockfd= NDB_INVALID_SOCKET;
return -1; return NDB_INVALID_SOCKET;
} }
} }
NDB_SOCKET_TYPE sockfd= m_sockfd; NDB_SOCKET_TYPE sockfd= m_sockfd;
m_sockfd= -1; m_sockfd= NDB_INVALID_SOCKET;
return sockfd; return sockfd;
} }
...@@ -20,12 +20,5 @@ ...@@ -20,12 +20,5 @@
/** /**
* Block callbacks * Block callbacks
*/ */
typedef void (SimulatedBlock::* CallbackFunction)(class Signal*,
Uint32 callbackData,
Uint32 returnCode);
struct Callback {
CallbackFunction m_callbackFunction;
Uint32 m_callbackData;
};
#endif #endif
...@@ -279,7 +279,7 @@ static char * get_and_validate_path(ndb_mgm_configuration_iterator &iter, ...@@ -279,7 +279,7 @@ static char * get_and_validate_path(ndb_mgm_configuration_iterator &iter,
#ifdef NDB_WIN32 #ifdef NDB_WIN32
char* szFilePart; char* szFilePart;
if(!GetFullPathName(path, sizeof(buf2), buf2, &szFilePart) || if(!GetFullPathName(path, sizeof(buf2), buf2, &szFilePart) ||
(GetFileAttributes(buf2) & FILE_ATTRIBUTE_READONLY)); (GetFileAttributes(buf2) & FILE_ATTRIBUTE_READONLY))
#else #else
if((::realpath(path, buf2) == NULL)|| if((::realpath(path, buf2) == NULL)||
(::access(buf2, W_OK) != 0)) (::access(buf2, W_OK) != 0))
......
...@@ -19,48 +19,51 @@ ...@@ -19,48 +19,51 @@
#include "Mutex.hpp" #include "Mutex.hpp"
#include <signaldata/UtilLock.hpp> #include <signaldata/UtilLock.hpp>
MutexManager::MutexManager(class SimulatedBlock & block) SimulatedBlock::MutexManager::MutexManager(class SimulatedBlock & block)
: m_block(block), : m_block(block),
m_activeMutexes(m_mutexPool) { m_activeMutexes(m_mutexPool) {
} }
bool bool
MutexManager::setSize(Uint32 maxNoOfActiveMutexes){ SimulatedBlock::MutexManager::setSize(Uint32 maxNoOfActiveMutexes){
return m_mutexPool.setSize(maxNoOfActiveMutexes); return m_mutexPool.setSize(maxNoOfActiveMutexes);
} }
Uint32 Uint32
MutexManager::getSize() const { SimulatedBlock::MutexManager::getSize() const {
return m_mutexPool.getSize(); return m_mutexPool.getSize();
} }
bool bool
MutexManager::seize(ActiveMutexPtr& ptr){ SimulatedBlock::MutexManager::seize(ActiveMutexPtr& ptr){
return m_activeMutexes.seize(ptr); return m_activeMutexes.seize(ptr);
} }
void void
MutexManager::release(Uint32 activeMutexPtrI){ SimulatedBlock::MutexManager::release(Uint32 activeMutexPtrI){
m_activeMutexes.release(activeMutexPtrI); m_activeMutexes.release(activeMutexPtrI);
} }
void void
MutexManager::getPtr(ActiveMutexPtr& ptr){ SimulatedBlock::MutexManager::getPtr(ActiveMutexPtr& ptr){
m_activeMutexes.getPtr(ptr); m_activeMutexes.getPtr(ptr);
} }
BlockReference BlockReference
MutexManager::reference() const { SimulatedBlock::MutexManager::reference() const {
return m_block.reference(); return m_block.reference();
} }
void void
MutexManager::progError(int line, int err_code, const char* extra) { SimulatedBlock::MutexManager::progError(int line,
int err_code,
const char* extra)
{
m_block.progError(line, err_code, extra); m_block.progError(line, err_code, extra);
} }
void void
MutexManager::create(Signal* signal, ActiveMutexPtr& ptr){ SimulatedBlock::MutexManager::create(Signal* signal, ActiveMutexPtr& ptr){
UtilCreateLockReq * req = (UtilCreateLockReq*)signal->getDataPtrSend(); UtilCreateLockReq * req = (UtilCreateLockReq*)signal->getDataPtrSend();
req->senderData = ptr.i; req->senderData = ptr.i;
...@@ -78,7 +81,7 @@ MutexManager::create(Signal* signal, ActiveMutexPtr& ptr){ ...@@ -78,7 +81,7 @@ MutexManager::create(Signal* signal, ActiveMutexPtr& ptr){
} }
void void
MutexManager::execUTIL_CREATE_LOCK_REF(Signal* signal){ SimulatedBlock::MutexManager::execUTIL_CREATE_LOCK_REF(Signal* signal){
UtilCreateLockRef * ref = (UtilCreateLockRef*)signal->getDataPtr(); UtilCreateLockRef * ref = (UtilCreateLockRef*)signal->getDataPtr();
ActiveMutexPtr ptr; ActiveMutexPtr ptr;
...@@ -91,7 +94,7 @@ MutexManager::execUTIL_CREATE_LOCK_REF(Signal* signal){ ...@@ -91,7 +94,7 @@ MutexManager::execUTIL_CREATE_LOCK_REF(Signal* signal){
} }
void void
MutexManager::execUTIL_CREATE_LOCK_CONF(Signal* signal){ SimulatedBlock::MutexManager::execUTIL_CREATE_LOCK_CONF(Signal* signal){
UtilCreateLockConf * conf = (UtilCreateLockConf*)signal->getDataPtr(); UtilCreateLockConf * conf = (UtilCreateLockConf*)signal->getDataPtr();
ActiveMutexPtr ptr; ActiveMutexPtr ptr;
...@@ -105,7 +108,7 @@ MutexManager::execUTIL_CREATE_LOCK_CONF(Signal* signal){ ...@@ -105,7 +108,7 @@ MutexManager::execUTIL_CREATE_LOCK_CONF(Signal* signal){
void void
MutexManager::destroy(Signal* signal, ActiveMutexPtr& ptr){ SimulatedBlock::MutexManager::destroy(Signal* signal, ActiveMutexPtr& ptr){
UtilDestroyLockReq * req = (UtilDestroyLockReq*)signal->getDataPtrSend(); UtilDestroyLockReq * req = (UtilDestroyLockReq*)signal->getDataPtrSend();
req->senderData = ptr.i; req->senderData = ptr.i;
...@@ -123,7 +126,7 @@ MutexManager::destroy(Signal* signal, ActiveMutexPtr& ptr){ ...@@ -123,7 +126,7 @@ MutexManager::destroy(Signal* signal, ActiveMutexPtr& ptr){
} }
void void
MutexManager::execUTIL_DESTORY_LOCK_REF(Signal* signal){ SimulatedBlock::MutexManager::execUTIL_DESTORY_LOCK_REF(Signal* signal){
UtilDestroyLockRef * ref = (UtilDestroyLockRef*)signal->getDataPtr(); UtilDestroyLockRef * ref = (UtilDestroyLockRef*)signal->getDataPtr();
ActiveMutexPtr ptr; ActiveMutexPtr ptr;
m_activeMutexes.getPtr(ptr, ref->senderData); m_activeMutexes.getPtr(ptr, ref->senderData);
...@@ -135,7 +138,7 @@ MutexManager::execUTIL_DESTORY_LOCK_REF(Signal* signal){ ...@@ -135,7 +138,7 @@ MutexManager::execUTIL_DESTORY_LOCK_REF(Signal* signal){
} }
void void
MutexManager::execUTIL_DESTORY_LOCK_CONF(Signal* signal){ SimulatedBlock::MutexManager::execUTIL_DESTORY_LOCK_CONF(Signal* signal){
UtilDestroyLockConf * conf = (UtilDestroyLockConf*)signal->getDataPtr(); UtilDestroyLockConf * conf = (UtilDestroyLockConf*)signal->getDataPtr();
ActiveMutexPtr ptr; ActiveMutexPtr ptr;
m_activeMutexes.getPtr(ptr, conf->senderData); m_activeMutexes.getPtr(ptr, conf->senderData);
...@@ -148,7 +151,7 @@ MutexManager::execUTIL_DESTORY_LOCK_CONF(Signal* signal){ ...@@ -148,7 +151,7 @@ MutexManager::execUTIL_DESTORY_LOCK_CONF(Signal* signal){
void void
MutexManager::lock(Signal* signal, ActiveMutexPtr& ptr){ SimulatedBlock::MutexManager::lock(Signal* signal, ActiveMutexPtr& ptr){
UtilLockReq * req = (UtilLockReq*)signal->getDataPtrSend(); UtilLockReq * req = (UtilLockReq*)signal->getDataPtrSend();
req->senderData = ptr.i; req->senderData = ptr.i;
...@@ -166,7 +169,7 @@ MutexManager::lock(Signal* signal, ActiveMutexPtr& ptr){ ...@@ -166,7 +169,7 @@ MutexManager::lock(Signal* signal, ActiveMutexPtr& ptr){
} }
void void
MutexManager::trylock(Signal* signal, ActiveMutexPtr& ptr){ SimulatedBlock::MutexManager::trylock(Signal* signal, ActiveMutexPtr& ptr){
UtilLockReq * req = (UtilLockReq*)signal->getDataPtrSend(); UtilLockReq * req = (UtilLockReq*)signal->getDataPtrSend();
req->senderData = ptr.i; req->senderData = ptr.i;
...@@ -184,7 +187,7 @@ MutexManager::trylock(Signal* signal, ActiveMutexPtr& ptr){ ...@@ -184,7 +187,7 @@ MutexManager::trylock(Signal* signal, ActiveMutexPtr& ptr){
} }
void void
MutexManager::execUTIL_LOCK_REF(Signal* signal){ SimulatedBlock::MutexManager::execUTIL_LOCK_REF(Signal* signal){
UtilLockRef * ref = (UtilLockRef*)signal->getDataPtr(); UtilLockRef * ref = (UtilLockRef*)signal->getDataPtr();
ActiveMutexPtr ptr; ActiveMutexPtr ptr;
m_activeMutexes.getPtr(ptr, ref->senderData); m_activeMutexes.getPtr(ptr, ref->senderData);
...@@ -196,7 +199,7 @@ MutexManager::execUTIL_LOCK_REF(Signal* signal){ ...@@ -196,7 +199,7 @@ MutexManager::execUTIL_LOCK_REF(Signal* signal){
} }
void void
MutexManager::execUTIL_LOCK_CONF(Signal* signal){ SimulatedBlock::MutexManager::execUTIL_LOCK_CONF(Signal* signal){
UtilLockConf * conf = (UtilLockConf*)signal->getDataPtr(); UtilLockConf * conf = (UtilLockConf*)signal->getDataPtr();
ActiveMutexPtr ptr; ActiveMutexPtr ptr;
m_activeMutexes.getPtr(ptr, conf->senderData); m_activeMutexes.getPtr(ptr, conf->senderData);
...@@ -210,7 +213,7 @@ MutexManager::execUTIL_LOCK_CONF(Signal* signal){ ...@@ -210,7 +213,7 @@ MutexManager::execUTIL_LOCK_CONF(Signal* signal){
} }
void void
MutexManager::unlock(Signal* signal, ActiveMutexPtr& ptr){ SimulatedBlock::MutexManager::unlock(Signal* signal, ActiveMutexPtr& ptr){
UtilUnlockReq * req = (UtilUnlockReq*)signal->getDataPtrSend(); UtilUnlockReq * req = (UtilUnlockReq*)signal->getDataPtrSend();
req->senderData = ptr.i; req->senderData = ptr.i;
req->senderRef = m_block.reference(); req->senderRef = m_block.reference();
...@@ -227,7 +230,7 @@ MutexManager::unlock(Signal* signal, ActiveMutexPtr& ptr){ ...@@ -227,7 +230,7 @@ MutexManager::unlock(Signal* signal, ActiveMutexPtr& ptr){
} }
void void
MutexManager::execUTIL_UNLOCK_REF(Signal* signal){ SimulatedBlock::MutexManager::execUTIL_UNLOCK_REF(Signal* signal){
UtilUnlockRef * ref = (UtilUnlockRef*)signal->getDataPtr(); UtilUnlockRef * ref = (UtilUnlockRef*)signal->getDataPtr();
ActiveMutexPtr ptr; ActiveMutexPtr ptr;
m_activeMutexes.getPtr(ptr, ref->senderData); m_activeMutexes.getPtr(ptr, ref->senderData);
...@@ -239,7 +242,7 @@ MutexManager::execUTIL_UNLOCK_REF(Signal* signal){ ...@@ -239,7 +242,7 @@ MutexManager::execUTIL_UNLOCK_REF(Signal* signal){
} }
void void
MutexManager::execUTIL_UNLOCK_CONF(Signal* signal){ SimulatedBlock::MutexManager::execUTIL_UNLOCK_CONF(Signal* signal){
UtilUnlockConf * conf = (UtilUnlockConf*)signal->getDataPtr(); UtilUnlockConf * conf = (UtilUnlockConf*)signal->getDataPtr();
ActiveMutexPtr ptr; ActiveMutexPtr ptr;
m_activeMutexes.getPtr(ptr, conf->senderData); m_activeMutexes.getPtr(ptr, conf->senderData);
...@@ -251,8 +254,9 @@ MutexManager::execUTIL_UNLOCK_CONF(Signal* signal){ ...@@ -251,8 +254,9 @@ MutexManager::execUTIL_UNLOCK_CONF(Signal* signal){
} }
void void
Mutex::release(MutexManager& mgr, Uint32 activePtrI, Uint32 mutexId){ Mutex::release(SimulatedBlock::MutexManager& mgr,
MutexManager::ActiveMutexPtr ptr; Uint32 activePtrI, Uint32 mutexId){
SimulatedBlock::MutexManager::ActiveMutexPtr ptr;
ptr.i = activePtrI; ptr.i = activePtrI;
mgr.getPtr(ptr); mgr.getPtr(ptr);
if(ptr.p->m_gsn == 0 && ptr.p->m_mutexId == mutexId){ if(ptr.p->m_gsn == 0 && ptr.p->m_mutexId == mutexId){
...@@ -272,7 +276,8 @@ Mutex::unlock(){ ...@@ -272,7 +276,8 @@ Mutex::unlock(){
if(!m_ptr.isNull()){ if(!m_ptr.isNull()){
m_mgr.getPtr(m_ptr); m_mgr.getPtr(m_ptr);
if(m_ptr.p->m_mutexId == m_mutexId){ if(m_ptr.p->m_mutexId == m_mutexId){
Callback c = { &SimulatedBlock::ignoreMutexUnlockCallback, m_ptr.i }; SimulatedBlock::Callback c =
{ &SimulatedBlock::ignoreMutexUnlockCallback, m_ptr.i };
m_ptr.p->m_callback = c; m_ptr.p->m_callback = c;
m_mgr.unlock(m_signal, m_ptr); m_mgr.unlock(m_signal, m_ptr);
m_ptr.setNull(); // Remove reference m_ptr.setNull(); // Remove reference
......
...@@ -22,63 +22,6 @@ ...@@ -22,63 +22,6 @@
class Mutex; class Mutex;
class MutexManager {
friend class Mutex;
friend class SimulatedBlock;
friend class DbUtil;
public:
MutexManager(class SimulatedBlock &);
bool setSize(Uint32 maxNoOfActiveMutexes);
Uint32 getSize() const ; // Get maxNoOfActiveMutexes
private:
/**
* core interface
*/
struct ActiveMutex {
Uint32 m_gsn; // state
Uint32 m_mutexId;
Uint32 m_mutexKey;
Callback m_callback;
union {
Uint32 nextPool;
Uint32 nextList;
};
Uint32 prevList;
};
typedef Ptr<ActiveMutex> ActiveMutexPtr;
bool seize(ActiveMutexPtr& ptr);
void release(Uint32 activeMutexPtrI);
void getPtr(ActiveMutexPtr& ptr);
void create(Signal*, ActiveMutexPtr&);
void destroy(Signal*, ActiveMutexPtr&);
void lock(Signal*, ActiveMutexPtr&);
void trylock(Signal*, ActiveMutexPtr&);
void unlock(Signal*, ActiveMutexPtr&);
private:
void execUTIL_CREATE_LOCK_REF(Signal* signal);
void execUTIL_CREATE_LOCK_CONF(Signal* signal);
void execUTIL_DESTORY_LOCK_REF(Signal* signal);
void execUTIL_DESTORY_LOCK_CONF(Signal* signal);
void execUTIL_LOCK_REF(Signal* signal);
void execUTIL_LOCK_CONF(Signal* signal);
void execUTIL_UNLOCK_REF(Signal* signal);
void execUTIL_UNLOCK_CONF(Signal* signal);
SimulatedBlock & m_block;
ArrayPool<ActiveMutex> m_mutexPool;
DLList<ActiveMutex> m_activeMutexes;
BlockReference reference() const;
void progError(int line, int err_code, const char* extra = 0);
};
/** /**
* MutexHandle - A "reference" to a mutex * MutexHandle - A "reference" to a mutex
* - Should be used together with Mutex * - Should be used together with Mutex
...@@ -89,7 +32,7 @@ public: ...@@ -89,7 +32,7 @@ public:
MutexHandle(Uint32 id); MutexHandle(Uint32 id);
bool isNull() const; bool isNull() const;
void release(MutexManager & mgr); void release(SimulatedBlock::MutexManager & mgr);
private: private:
const Uint32 m_mutexId; const Uint32 m_mutexId;
...@@ -106,7 +49,7 @@ public: ...@@ -106,7 +49,7 @@ public:
MutexHandle2(); MutexHandle2();
bool isNull() const; bool isNull() const;
void release(MutexManager & mgr); void release(SimulatedBlock::MutexManager & mgr);
private: private:
Uint32 m_activeMutexPtrI; Uint32 m_activeMutexPtrI;
...@@ -117,33 +60,34 @@ private: ...@@ -117,33 +60,34 @@ private:
*/ */
class Mutex { class Mutex {
public: public:
Mutex(Signal*, MutexManager & mgr, MutexHandle &); Mutex(Signal*, SimulatedBlock::MutexManager & mgr, MutexHandle &);
template<Uint32 MutexId> template<Uint32 MutexId>
Mutex(Signal*, MutexManager & mgr, MutexHandle2<MutexId> &); Mutex(Signal*, SimulatedBlock::MutexManager & mgr, MutexHandle2<MutexId> &);
~Mutex(); ~Mutex();
void release(); void release();
bool isNull() const ; bool isNull() const ;
bool lock(Callback & callback); bool lock(SimulatedBlock::Callback & callback);
bool trylock(Callback & callback); bool trylock(SimulatedBlock::Callback & callback);
void unlock(Callback & callback); void unlock(SimulatedBlock::Callback & callback);
void unlock(); // Ignore callback void unlock(); // Ignore callback
bool create(Callback & callback); bool create(SimulatedBlock::Callback & callback);
bool destroy(Callback & callback); bool destroy(SimulatedBlock::Callback & callback);
private: private:
Signal* m_signal; Signal* m_signal;
MutexManager & m_mgr; SimulatedBlock::MutexManager & m_mgr;
const Uint32 m_mutexId; const Uint32 m_mutexId;
Uint32 & m_srcPtrI; Uint32 & m_srcPtrI;
MutexManager::ActiveMutexPtr m_ptr; SimulatedBlock::MutexManager::ActiveMutexPtr m_ptr;
public: public:
static void release(MutexManager&, Uint32 activePtrI, Uint32 mutexId); static void release(SimulatedBlock::MutexManager&,
Uint32 activePtrI, Uint32 mutexId);
}; };
inline inline
...@@ -159,7 +103,7 @@ MutexHandle::isNull() const { ...@@ -159,7 +103,7 @@ MutexHandle::isNull() const {
inline inline
void void
MutexHandle::release(MutexManager & mgr){ MutexHandle::release(SimulatedBlock::MutexManager & mgr){
if(!isNull()){ if(!isNull()){
Mutex::release(mgr, m_activeMutexPtrI, m_mutexId); Mutex::release(mgr, m_activeMutexPtrI, m_mutexId);
m_activeMutexPtrI = RNIL; m_activeMutexPtrI = RNIL;
...@@ -183,7 +127,7 @@ MutexHandle2<MutexId>::isNull() const { ...@@ -183,7 +127,7 @@ MutexHandle2<MutexId>::isNull() const {
template<Uint32 MutexId> template<Uint32 MutexId>
inline inline
void void
MutexHandle2<MutexId>::release(MutexManager & mgr){ MutexHandle2<MutexId>::release(SimulatedBlock::MutexManager & mgr){
if(!isNull()){ if(!isNull()){
Mutex::release(mgr, m_activeMutexPtrI, MutexId); Mutex::release(mgr, m_activeMutexPtrI, MutexId);
m_activeMutexPtrI = RNIL; m_activeMutexPtrI = RNIL;
...@@ -192,7 +136,8 @@ MutexHandle2<MutexId>::release(MutexManager & mgr){ ...@@ -192,7 +136,8 @@ MutexHandle2<MutexId>::release(MutexManager & mgr){
inline inline
Mutex::Mutex(Signal* signal, MutexManager & mgr, MutexHandle & mh) Mutex::Mutex(Signal* signal, SimulatedBlock::MutexManager & mgr,
MutexHandle & mh)
: m_signal(signal), : m_signal(signal),
m_mgr(mgr), m_mgr(mgr),
m_mutexId(mh.m_mutexId), m_mutexId(mh.m_mutexId),
...@@ -204,7 +149,8 @@ Mutex::Mutex(Signal* signal, MutexManager & mgr, MutexHandle & mh) ...@@ -204,7 +149,8 @@ Mutex::Mutex(Signal* signal, MutexManager & mgr, MutexHandle & mh)
template<Uint32 MutexId> template<Uint32 MutexId>
inline inline
Mutex::Mutex(Signal* signal, MutexManager & mgr, MutexHandle2<MutexId> & mh) Mutex::Mutex(Signal* signal, SimulatedBlock::MutexManager & mgr,
MutexHandle2<MutexId> & mh)
: m_signal(signal), : m_signal(signal),
m_mgr(mgr), m_mgr(mgr),
m_mutexId(MutexId), m_mutexId(MutexId),
...@@ -236,7 +182,7 @@ Mutex::isNull() const { ...@@ -236,7 +182,7 @@ Mutex::isNull() const {
inline inline
bool bool
Mutex::lock(Callback & callback){ Mutex::lock(SimulatedBlock::Callback & callback){
if(m_ptr.isNull()){ if(m_ptr.isNull()){
if(m_mgr.seize(m_ptr)){ if(m_mgr.seize(m_ptr)){
m_ptr.p->m_mutexId = m_mutexId; m_ptr.p->m_mutexId = m_mutexId;
...@@ -253,7 +199,7 @@ Mutex::lock(Callback & callback){ ...@@ -253,7 +199,7 @@ Mutex::lock(Callback & callback){
inline inline
bool bool
Mutex::trylock(Callback & callback){ Mutex::trylock(SimulatedBlock::Callback & callback){
if(m_ptr.isNull()){ if(m_ptr.isNull()){
if(m_mgr.seize(m_ptr)){ if(m_mgr.seize(m_ptr)){
m_ptr.p->m_mutexId = m_mutexId; m_ptr.p->m_mutexId = m_mutexId;
...@@ -270,7 +216,7 @@ Mutex::trylock(Callback & callback){ ...@@ -270,7 +216,7 @@ Mutex::trylock(Callback & callback){
inline inline
void void
Mutex::unlock(Callback & callback){ Mutex::unlock(SimulatedBlock::Callback & callback){
if(!m_ptr.isNull()){ if(!m_ptr.isNull()){
m_mgr.getPtr(m_ptr); m_mgr.getPtr(m_ptr);
if(m_ptr.p->m_mutexId == m_mutexId){ if(m_ptr.p->m_mutexId == m_mutexId){
...@@ -285,7 +231,7 @@ Mutex::unlock(Callback & callback){ ...@@ -285,7 +231,7 @@ Mutex::unlock(Callback & callback){
inline inline
bool bool
Mutex::create(Callback & callback){ Mutex::create(SimulatedBlock::Callback & callback){
if(m_ptr.isNull()){ if(m_ptr.isNull()){
if(m_mgr.seize(m_ptr)){ if(m_mgr.seize(m_ptr)){
m_ptr.p->m_mutexId = m_mutexId; m_ptr.p->m_mutexId = m_mutexId;
...@@ -302,7 +248,7 @@ Mutex::create(Callback & callback){ ...@@ -302,7 +248,7 @@ Mutex::create(Callback & callback){
inline inline
bool bool
Mutex::destroy(Callback & callback){ Mutex::destroy(SimulatedBlock::Callback & callback){
if(m_ptr.isNull()){ if(m_ptr.isNull()){
if(m_mgr.seize(m_ptr)){ if(m_mgr.seize(m_ptr)){
m_ptr.p->m_mutexId = m_mutexId; m_ptr.p->m_mutexId = m_mutexId;
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#endif #endif
SectionReader::SectionReader SectionReader::SectionReader
(class SegmentedSectionPtr & ptr, class SectionSegmentPool & pool) (struct SegmentedSectionPtr & ptr, class SectionSegmentPool & pool)
: m_pool(pool) : m_pool(pool)
{ {
if(ptr.p == 0){ if(ptr.p == 0){
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
class SectionReader { class SectionReader {
public: public:
SectionReader(class SegmentedSectionPtr &, SectionReader(struct SegmentedSectionPtr &,
class SectionSegmentPool &); class SectionSegmentPool &);
void reset(); void reset();
......
...@@ -1598,7 +1598,7 @@ SimulatedBlock::sendFragmentedSignal(NodeReceiverGroup rg, ...@@ -1598,7 +1598,7 @@ SimulatedBlock::sendFragmentedSignal(NodeReceiverGroup rg,
} }
} }
Callback SimulatedBlock::TheEmptyCallback = {0, 0}; SimulatedBlock::Callback SimulatedBlock::TheEmptyCallback = {0, 0};
void void
SimulatedBlock::sendFragmentedSignal(BlockReference ref, SimulatedBlock::sendFragmentedSignal(BlockReference ref,
......
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include "ArrayPool.hpp" #include "ArrayPool.hpp"
#include "DLHashTable.hpp" #include "DLHashTable.hpp"
#include "Callback.hpp" #include "Callback.hpp"
#include "Mutex.hpp"
#include "SafeCounter.hpp" #include "SafeCounter.hpp"
#include "MetaData.hpp" #include "MetaData.hpp"
...@@ -104,6 +103,14 @@ public: ...@@ -104,6 +103,14 @@ public:
* *
*/ */
inline void executeFunction(GlobalSignalNumber gsn, Signal* signal); inline void executeFunction(GlobalSignalNumber gsn, Signal* signal);
public:
typedef void (SimulatedBlock::* CallbackFunction)(class Signal*,
Uint32 callbackData,
Uint32 returnCode);
struct Callback {
CallbackFunction m_callbackFunction;
Uint32 m_callbackData;
};
protected: protected:
static Callback TheEmptyCallback; static Callback TheEmptyCallback;
void execute(Signal* signal, Callback & c, Uint32 returnCode); void execute(Signal* signal, Callback & c, Uint32 returnCode);
...@@ -406,6 +413,62 @@ private: ...@@ -406,6 +413,62 @@ private:
DLList<FragmentSendInfo> c_segmentedFragmentSendList; DLList<FragmentSendInfo> c_segmentedFragmentSendList;
public: public:
class MutexManager {
friend class Mutex;
friend class SimulatedBlock;
friend class DbUtil;
public:
MutexManager(class SimulatedBlock &);
bool setSize(Uint32 maxNoOfActiveMutexes);
Uint32 getSize() const ; // Get maxNoOfActiveMutexes
private:
/**
* core interface
*/
struct ActiveMutex {
Uint32 m_gsn; // state
Uint32 m_mutexId;
Uint32 m_mutexKey;
Callback m_callback;
union {
Uint32 nextPool;
Uint32 nextList;
};
Uint32 prevList;
};
typedef Ptr<ActiveMutex> ActiveMutexPtr;
bool seize(ActiveMutexPtr& ptr);
void release(Uint32 activeMutexPtrI);
void getPtr(ActiveMutexPtr& ptr);
void create(Signal*, ActiveMutexPtr&);
void destroy(Signal*, ActiveMutexPtr&);
void lock(Signal*, ActiveMutexPtr&);
void trylock(Signal*, ActiveMutexPtr&);
void unlock(Signal*, ActiveMutexPtr&);
private:
void execUTIL_CREATE_LOCK_REF(Signal* signal);
void execUTIL_CREATE_LOCK_CONF(Signal* signal);
void execUTIL_DESTORY_LOCK_REF(Signal* signal);
void execUTIL_DESTORY_LOCK_CONF(Signal* signal);
void execUTIL_LOCK_REF(Signal* signal);
void execUTIL_LOCK_CONF(Signal* signal);
void execUTIL_UNLOCK_REF(Signal* signal);
void execUTIL_UNLOCK_CONF(Signal* signal);
SimulatedBlock & m_block;
ArrayPool<ActiveMutex> m_mutexPool;
DLList<ActiveMutex> m_activeMutexes;
BlockReference reference() const;
void progError(int line, int err_code, const char* extra = 0);
};
MutexManager c_mutexMgr; MutexManager c_mutexMgr;
void ignoreMutexUnlockCallback(Signal* signal, Uint32 ptrI, Uint32 retVal); void ignoreMutexUnlockCallback(Signal* signal, Uint32 ptrI, Uint32 retVal);
...@@ -688,5 +751,7 @@ BLOCK::addRecSignal(GlobalSignalNumber gsn, ExecSignalLocal f, bool force){ \ ...@@ -688,5 +751,7 @@ BLOCK::addRecSignal(GlobalSignalNumber gsn, ExecSignalLocal f, bool force){ \
addRecSignalImpl(gsn, (ExecFunction)f, force);\ addRecSignalImpl(gsn, (ExecFunction)f, force);\
} }
#include "Mutex.hpp"
#endif #endif
...@@ -24,4 +24,28 @@ ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@ ...@@ -24,4 +24,28 @@ ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
%::SCCS/s.% %::SCCS/s.%
windoze-dsp: windoze-dsp: ndb_mgm.dsp libndbmgmclient.dsp
ndb_mgm.dsp: Makefile \
$(top_srcdir)/ndb/config/win-prg.am \
$(top_srcdir)/ndb/config/win-name \
$(top_srcdir)/ndb/config/win-includes \
$(top_srcdir)/ndb/config/win-sources \
$(top_srcdir)/ndb/config/win-libraries
cat $(top_srcdir)/ndb/config/win-prg.am > $@
@$(top_srcdir)/ndb/config/win-name $@ $(ndbtools_PROGRAMS)
@$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES)
@$(top_srcdir)/ndb/config/win-sources $@ $(ndb_mgm_SOURCES)
@$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD)
libndbmgmclient.dsp: Makefile \
$(top_srcdir)/ndb/config/win-lib.am \
$(top_srcdir)/ndb/config/win-name \
$(top_srcdir)/ndb/config/win-includes \
$(top_srcdir)/ndb/config/win-sources \
$(top_srcdir)/ndb/config/win-libraries
cat $(top_srcdir)/ndb/config/win-lib.am > $@
@$(top_srcdir)/ndb/config/win-name $@ $(noinst_LTLIBRARIES)
@$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES)
@$(top_srcdir)/ndb/config/win-sources $@ $(libndbmgmclient_la_SOURCES)
@$(top_srcdir)/ndb/config/win-libraries $@ LIB
...@@ -32,4 +32,4 @@ libNDBT.dsp: Makefile \ ...@@ -32,4 +32,4 @@ libNDBT.dsp: Makefile \
@$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES)
@$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES)
@$(top_srcdir)/ndb/config/win-sources $@ $(libNDBT_a_SOURCES) @$(top_srcdir)/ndb/config/win-sources $@ $(libNDBT_a_SOURCES)
@$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) @$(top_srcdir)/ndb/config/win-libraries $@ LIB
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment