Commit dba31904 authored by unknown's avatar unknown

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1

into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1-new


tests/mysql_client_test.c:
  Auto merged
parents 951dacdc 2a48132e
......@@ -785,12 +785,14 @@ INSERT INTO t1 VALUES
(1,'blah','464','aaa','fkc1c9ilc20x0hgae7lx6j09','ERR','ERR Имри.Афимим.Аеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ад.Д имдимримрад.Адимримримрмдиримримримр м.Дадимфшьмримд им.Адимимрн имадми','ИМРИ.АФИМИМ.АЕИМИМРИМДМРИМРМРИРОР',3,'2005-06-01 17:30:43','1234567890'),
(2,'blah','464','aaa','haxpl2ilc20x00bj4tt2m5ti','11','11 g','G',3,'2005-06-02 22:43:10','1234567890');
--disable_warnings
CREATE TABLE t2 (
`msisdn` varchar(15) NOT NULL default '',
`operator_id` int(11) NOT NULL default '0',
`created` datetime NOT NULL default '0000-00-00 00:00:00',
UNIQUE KEY `PK_user` (`msisdn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--enable_warnings
INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25');
......
......@@ -36,8 +36,16 @@
#define MAKE_VERSION(A,B,C) (((A) << 16) | ((B) << 8) | ((C) << 0))
#define NDB_VERSION_D MAKE_VERSION(NDB_VERSION_MAJOR, NDB_VERSION_MINOR, NDB_VERSION_BUILD)
#define NDB_VERSION_STRING (getVersionString(NDB_VERSION, NDB_VERSION_STATUS))
#define NDB_VERSION_STRING_BUF_SZ 100
#ifdef __cplusplus
extern "C"
#else
extern
#endif
char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ];
#define NDB_VERSION_STRING (getVersionString(NDB_VERSION, NDB_VERSION_STATUS, \
ndb_version_string_buf, \
sizeof(ndb_version_string_buf)))
#define NDB_VERSION ndbGetOwnVersion()
......
......@@ -31,7 +31,7 @@
#define NDB_NONBLOCK FNDELAY
#define NDB_SOCKET_TYPE int
#define NDB_INVALID_SOCKET -1
#define NDB_CLOSE_SOCKET(x) close(x)
#define _NDB_CLOSE_SOCKET(x) close(x)
/**
* socklen_t not defined in the header files of OSE
......@@ -52,7 +52,7 @@ typedef int socklen_t;
#define EWOULDBLOCK WSAEWOULDBLOCK
#define NDB_SOCKET_TYPE SOCKET
#define NDB_INVALID_SOCKET INVALID_SOCKET
#define NDB_CLOSE_SOCKET(x) closesocket(x)
#define _NDB_CLOSE_SOCKET(x) closesocket(x)
#else
......@@ -64,7 +64,7 @@ typedef int socklen_t;
#define NDB_NONBLOCK O_NONBLOCK
#define NDB_SOCKET_TYPE int
#define NDB_INVALID_SOCKET -1
#define NDB_CLOSE_SOCKET(x) ::close(x)
#define _NDB_CLOSE_SOCKET(x) ::close(x)
#define InetErrno errno
......@@ -89,6 +89,12 @@ extern "C" {
*/
int Ndb_getInAddr(struct in_addr * dst, const char *address);
#ifdef DBUG_OFF
#define NDB_CLOSE_SOCKET(fd) _NDB_CLOSE_SOCKET(fd)
#else
int NDB_CLOSE_SOCKET(int fd);
#endif
#ifdef __cplusplus
}
#endif
......
......@@ -238,6 +238,8 @@ public:
};
Vector<Transporter_interface> m_transporter_interface;
void add_transporter_interface(const char *interf, unsigned short port);
struct in_addr get_connect_address(NodeId node_id) const;
protected:
private:
......
......@@ -41,7 +41,13 @@ public:
protected:
friend class SocketServer;
friend void* sessionThread_C(void*);
Session(NDB_SOCKET_TYPE sock): m_socket(sock){ m_stop = m_stopped = false;}
Session(NDB_SOCKET_TYPE sock): m_socket(sock)
{
DBUG_ENTER("SocketServer::Session");
DBUG_PRINT("enter",("NDB_SOCKET: %d", m_socket));
m_stop = m_stopped = false;
DBUG_VOID_RETURN;
}
bool m_stop; // Has the session been ordered to stop?
bool m_stopped; // Has the session stopped?
......
......@@ -28,6 +28,7 @@
const char *opt_connect_str= 0;\
my_bool opt_ndb_optimized_node_selection
bool opt_endinfo= 0;
my_bool opt_ndb_shm;
#define OPT_NDB_CONNECTSTRING 'c'
......@@ -93,6 +94,7 @@ ndb_std_get_one_option(int optid,
{
DBUG_PUSH(argument);
}
opt_endinfo= 1;
break;
case 'V':
ndb_std_print_version();
......
......@@ -30,7 +30,8 @@ extern "C" {
Uint32 makeVersion(Uint32 major, Uint32 minor, Uint32 build);
const char* getVersionString(Uint32 version, const char * status);
const char* getVersionString(Uint32 version, const char * status,
char *buf, unsigned sz);
void ndbPrintVersion();
Uint32 ndbGetOwnVersion();
......
......@@ -31,6 +31,7 @@ LogHandler::LogHandler() :
m_last_message[0]= 0;
m_last_log_time= 0;
m_now= 0;
m_last_level= (Logger::LoggerLevel)-1;
}
LogHandler::~LogHandler()
......
......@@ -47,6 +47,8 @@
ConfigRetriever::ConfigRetriever(const char * _connect_string,
Uint32 version, Uint32 node_type)
{
DBUG_ENTER("ConfigRetriever::ConfigRetriever");
m_version = version;
m_node_type = node_type;
_ownNodeId= 0;
......@@ -55,23 +57,26 @@ ConfigRetriever::ConfigRetriever(const char * _connect_string,
if (m_handle == 0) {
setError(CR_ERROR, "Unable to allocate mgm handle");
return;
DBUG_VOID_RETURN;
}
if (ndb_mgm_set_connectstring(m_handle, _connect_string))
{
setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle));
return;
DBUG_VOID_RETURN;
}
resetError();
DBUG_VOID_RETURN;
}
ConfigRetriever::~ConfigRetriever()
{
DBUG_ENTER("ConfigRetriever::~ConfigRetriever");
if (m_handle) {
ndb_mgm_disconnect(m_handle);
ndb_mgm_destroy_handle(&m_handle);
}
DBUG_VOID_RETURN;
}
Uint32
......@@ -131,16 +136,14 @@ ConfigRetriever::getConfig() {
}
ndb_mgm_configuration *
ConfigRetriever::getConfig(NdbMgmHandle m_handle){
ConfigRetriever::getConfig(NdbMgmHandle m_handle)
{
ndb_mgm_configuration * conf = ndb_mgm_get_configuration(m_handle,m_version);
if(conf == 0){
if(conf == 0)
{
setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle));
return 0;
}
ndb_mgm_disconnect(m_handle);
return conf;
}
......
......@@ -114,7 +114,10 @@ IPCConfig::addRemoteNodeId(NodeId nodeId){
* Returns no of transporters configured
*/
int
IPCConfig::configureTransporters(TransporterRegistry * theTransporterRegistry){
IPCConfig::configureTransporters(TransporterRegistry * theTransporterRegistry)
{
DBUG_ENTER("IPCConfig::configureTransporters");
int noOfTransportersCreated = 0;
Uint32 noOfConnections;
......@@ -276,7 +279,7 @@ IPCConfig::configureTransporters(TransporterRegistry * theTransporterRegistry){
continue;
}
}
return noOfTransportersCreated;
DBUG_RETURN(noOfTransportersCreated);
}
/**
......
......@@ -23,33 +23,37 @@
NdbMutex* NdbMutex_Create(void)
{
DBUG_ENTER("NdbMutex_Create");
NdbMutex* pNdbMutex;
int result;
pNdbMutex = (NdbMutex*)NdbMem_Allocate(sizeof(NdbMutex));
DBUG_PRINT("info",("NdbMem_Allocate 0x%lx",pNdbMutex));
if (pNdbMutex == NULL)
return NULL;
DBUG_RETURN(NULL);
result = pthread_mutex_init(pNdbMutex, NULL);
assert(result == 0);
return pNdbMutex;
DBUG_RETURN(pNdbMutex);
}
int NdbMutex_Destroy(NdbMutex* p_mutex)
{
DBUG_ENTER("NdbMutex_Destroy");
int result;
if (p_mutex == NULL)
return -1;
DBUG_RETURN(-1);
result = pthread_mutex_destroy(p_mutex);
free(p_mutex);
DBUG_PRINT("info",("NdbMem_Free 0x%lx",p_mutex));
NdbMem_Free(p_mutex);
return result;
DBUG_RETURN(result);
}
......
......@@ -54,6 +54,15 @@ Ndb_getInAddr(struct in_addr * dst, const char *address) {
return -1; //DBUG_RETURN(-1);
}
#ifndef DBUG_OFF
extern "C"
int NDB_CLOSE_SOCKET(int fd)
{
DBUG_PRINT("info", ("NDB_CLOSE_SOCKET(%d)", fd));
return _NDB_CLOSE_SOCKET(fd);
}
#endif
#if 0
int
Ndb_getInAddr(struct in_addr * dst, const char *address) {
......
......@@ -56,6 +56,7 @@ ndb_thread_wrapper(void* _ss){
void *ret;
struct NdbThread * ss = (struct NdbThread *)_ss;
ret= (* ss->func)(ss->object);
DBUG_POP();
NdbThread_Exit(ret);
}
/* will never be reached */
......@@ -70,6 +71,7 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
const char* p_thread_name,
NDB_THREAD_PRIO thread_prio)
{
DBUG_ENTER("NdbThread_Create");
struct NdbThread* tmpThread;
int result;
pthread_attr_t thread_attr;
......@@ -77,11 +79,13 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
(void)thread_prio; /* remove warning for unused parameter */
if (p_thread_func == NULL)
return 0;
DBUG_RETURN(NULL);
tmpThread = (struct NdbThread*)NdbMem_Allocate(sizeof(struct NdbThread));
if (tmpThread == NULL)
return NULL;
DBUG_RETURN(NULL);
DBUG_PRINT("info",("thread_name: %s", p_thread_name));
strnmov(tmpThread->thread_name,p_thread_name,sizeof(tmpThread->thread_name));
......@@ -108,16 +112,20 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func,
assert(result==0);
pthread_attr_destroy(&thread_attr);
return tmpThread;
DBUG_PRINT("exit",("ret: %lx", tmpThread));
DBUG_RETURN(tmpThread);
}
void NdbThread_Destroy(struct NdbThread** p_thread)
{
if (*p_thread != NULL){
DBUG_ENTER("NdbThread_Destroy");
if (*p_thread != NULL){
DBUG_PRINT("enter",("*p_thread: %lx", * p_thread));
free(* p_thread);
* p_thread = 0;
}
DBUG_VOID_RETURN;
}
......
......@@ -74,6 +74,7 @@ Transporter::Transporter(TransporterRegistry &t_reg,
m_connected = false;
m_timeOutMillis = 1000;
m_connect_address.s_addr= 0;
if (isServer)
m_socket_client= 0;
else
......@@ -98,6 +99,13 @@ Transporter::connect_server(NDB_SOCKET_TYPE sockfd) {
DBUG_RETURN(true); // TODO assert(0);
}
{
struct sockaddr addr;
SOCKET_SIZE_TYPE addrlen= sizeof(addr);
int r= getpeername(sockfd, &addr, &addrlen);
m_connect_address= ((struct sockaddr_in *)&addr)->sin_addr;
}
bool res = connect_server_impl(sockfd);
if(res){
m_connected = true;
......@@ -164,6 +172,13 @@ Transporter::connect_client() {
g_eventLogger.warning("Unable to verify transporter compatability with node %d", nodeId);
}
{
struct sockaddr addr;
SOCKET_SIZE_TYPE addrlen= sizeof(addr);
int r= getpeername(sockfd, &addr, &addrlen);
m_connect_address= ((struct sockaddr_in *)&addr)->sin_addr;
}
bool res = connect_client_impl(sockfd);
if(res){
m_connected = true;
......
......@@ -122,6 +122,7 @@ protected:
private:
SocketClient *m_socket_client;
struct in_addr m_connect_address;
protected:
Uint32 getErrorCount();
......
......@@ -51,6 +51,12 @@ extern int g_ndb_shm_signum;
#include <EventLogger.hpp>
extern EventLogger g_eventLogger;
struct in_addr
TransporterRegistry::get_connect_address(NodeId node_id) const
{
return theTransporters[node_id]->m_connect_address;
}
SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd)
{
DBUG_ENTER("SocketServer::Session * TransporterService::newSession");
......@@ -70,7 +76,9 @@ SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd)
TransporterRegistry::TransporterRegistry(void * callback,
unsigned _maxTransporters,
unsigned sizeOfLongSignalMemory) {
unsigned sizeOfLongSignalMemory)
{
DBUG_ENTER("TransporterRegistry::TransporterRegistry");
nodeIdSpecified = false;
maxTransporters = _maxTransporters;
......@@ -107,9 +115,13 @@ TransporterRegistry::TransporterRegistry(void * callback,
theOSEReceiver = 0;
theOSEJunkSocketSend = 0;
theOSEJunkSocketRecv = 0;
DBUG_VOID_RETURN;
}
TransporterRegistry::~TransporterRegistry() {
TransporterRegistry::~TransporterRegistry()
{
DBUG_ENTER("TransporterRegistry::~TransporterRegistry");
removeAll();
......@@ -129,6 +141,8 @@ TransporterRegistry::~TransporterRegistry() {
theOSEReceiver = 0;
}
#endif
DBUG_VOID_RETURN;
}
void
......
......@@ -141,7 +141,10 @@ split(char * buf, char ** name, char ** value){
bool
ParserImpl::run(Context * ctx, const class Properties ** pDst,
volatile bool * stop) const {
volatile bool * stop) const
{
DBUG_ENTER("ParserImpl::run");
* pDst = 0;
bool ownStop = false;
if(stop == 0)
......@@ -153,24 +156,24 @@ ParserImpl::run(Context * ctx, const class Properties ** pDst,
ctx->m_currentToken = input.gets(ctx->m_tokenBuffer, sz);
if(Eof(ctx->m_currentToken)){
ctx->m_status = Parser<Dummy>::Eof;
return false;
DBUG_RETURN(false);
}
if(ctx->m_currentToken[0] == 0){
ctx->m_status = Parser<Dummy>::NoLine;
return false;
DBUG_RETURN(false);
}
if(Empty(ctx->m_currentToken)){
ctx->m_status = Parser<Dummy>::EmptyLine;
return false;
DBUG_RETURN(false);
}
trim(ctx->m_currentToken);
ctx->m_currentCmd = matchCommand(ctx, ctx->m_currentToken, m_rows);
if(ctx->m_currentCmd == 0){
ctx->m_status = Parser<Dummy>::UnknownCommand;
return false;
DBUG_RETURN(false);
}
Properties * p = new Properties();
......@@ -200,19 +203,19 @@ ParserImpl::run(Context * ctx, const class Properties ** pDst,
tmp = input.gets(buf, sz);
} while((! * stop) && !Eof(tmp) && !Empty(tmp));
}
return false;
DBUG_RETURN(false);
}
if(* stop){
delete p;
ctx->m_status = Parser<Dummy>::ExternalStop;
return false;
DBUG_RETURN(false);
}
if(!checkMandatory(ctx, p)){
ctx->m_status = Parser<Dummy>::MissingMandatoryArgument;
delete p;
return false;
DBUG_RETURN(false);
}
/**
......@@ -229,7 +232,7 @@ ParserImpl::run(Context * ctx, const class Properties ** pDst,
ctx->m_status = Parser<Dummy>::Ok;
* pDst = p;
return true;
DBUG_RETURN(true);
}
const ParserImpl::DummyRow*
......
......@@ -57,6 +57,8 @@ SocketClient::init()
return false;
}
DBUG_PRINT("info",("NDB_SOCKET: %d", m_sockfd));
return true;
}
......
......@@ -64,6 +64,8 @@ SocketServer::tryBind(unsigned short port, const char * intface) {
return false;
}
DBUG_PRINT("info",("NDB_SOCKET: %d", sock));
const int on = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(const char*)&on, sizeof(on)) == -1) {
......@@ -104,6 +106,8 @@ SocketServer::setup(SocketServer::Service * service,
DBUG_RETURN(false);
}
DBUG_PRINT("info",("NDB_SOCKET: %d", sock));
const int on = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(const char*)&on, sizeof(on)) == -1) {
......
......@@ -38,22 +38,24 @@ Uint32 makeVersion(Uint32 major, Uint32 minor, Uint32 build) {
}
const char * getVersionString(Uint32 version, const char * status) {
char buff[100];
char ndb_version_string_buf[NDB_VERSION_STRING_BUF_SZ];
const char * getVersionString(Uint32 version, const char * status,
char *buf, unsigned sz)
{
if (status && status[0] != 0)
basestring_snprintf(buff, sizeof(buff),
basestring_snprintf(buf, sz,
"Version %d.%d.%d (%s)",
getMajor(version),
getMinor(version),
getBuild(version),
status);
else
basestring_snprintf(buff, sizeof(buff),
basestring_snprintf(buf, sz,
"Version %d.%d.%d",
getMajor(version),
getMinor(version),
getBuild(version));
return strdup(buff);
return buf;
}
typedef enum {
......
......@@ -257,8 +257,8 @@ private:
void hbReceivedLab(Signal* signal);
void sendCmRegrefLab(Signal* signal, BlockReference ref,
CmRegRef::ErrorCode);
void systemErrorBecauseOtherNodeFailed(Signal* signal, NodeId);
void systemErrorLab(Signal* signal,
void systemErrorBecauseOtherNodeFailed(Signal* signal, Uint32 line, NodeId);
void systemErrorLab(Signal* signal, Uint32 line,
const char* message = NULL);
void prepFailReqLab(Signal* signal);
void prepFailConfLab(Signal* signal);
......
......@@ -76,7 +76,7 @@ void Qmgr::execCM_HEARTBEAT(Signal* signal)
void Qmgr::execCM_NODEINFOREF(Signal* signal)
{
jamEntry();
systemErrorLab(signal);
systemErrorLab(signal, __LINE__);
return;
}//Qmgr::execCM_NODEINFOREF()
......@@ -121,7 +121,7 @@ void Qmgr::execCONTINUEB(Signal* signal)
default:
jam();
// ZCOULD_NOT_OCCUR_ERROR;
systemErrorLab(signal);
systemErrorLab(signal, __LINE__);
return;
break;
}//switch
......@@ -593,7 +593,7 @@ void Qmgr::execCM_REGCONF(Signal* signal)
jam();
char buf[128];
BaseString::snprintf(buf,sizeof(buf),"incompatible version own=0x%x other=0x%x, shutting down", NDB_VERSION, cmRegConf->presidentVersion);
systemErrorLab(signal, buf);
systemErrorLab(signal, __LINE__, buf);
return;
}
......@@ -688,7 +688,7 @@ void Qmgr::execCM_REGREF(Signal* signal)
switch (TrefuseReason) {
case CmRegRef::ZINCOMPATIBLE_VERSION:
jam();
systemErrorLab(signal, "incompatible version, connection refused by running ndb node");
systemErrorLab(signal, __LINE__, "incompatible version, connection refused by running ndb node");
break;
case CmRegRef::ZBUSY:
case CmRegRef::ZBUSY_TO_PRES:
......@@ -1751,7 +1751,7 @@ void Qmgr::execAPI_FAILCONF(Signal* signal)
if (failedNodePtr.p->rcv[0] == failedNodePtr.p->rcv[1]) {
jam();
systemErrorLab(signal);
systemErrorLab(signal, __LINE__);
} else {
jam();
failedNodePtr.p->rcv[0] = 0;
......@@ -1763,7 +1763,7 @@ void Qmgr::execAPI_FAILCONF(Signal* signal)
ndbout << "failedNodePtr.p->failState = "
<< (Uint32)(failedNodePtr.p->failState) << endl;
#endif
systemErrorLab(signal);
systemErrorLab(signal, __LINE__);
}//if
return;
}//Qmgr::execAPI_FAILCONF()
......@@ -1780,7 +1780,7 @@ void Qmgr::execNDB_FAILCONF(Signal* signal)
failedNodePtr.p->failState = NORMAL;
} else {
jam();
systemErrorLab(signal);
systemErrorLab(signal, __LINE__);
}//if
if (cpresident == getOwnNodeId()) {
jam();
......@@ -1931,20 +1931,13 @@ void Qmgr::execAPI_REGREQ(Signal* signal)
#endif
bool compatability_check;
switch(getNodeInfo(apiNodePtr.i).getType()){
NodeInfo::NodeType type= getNodeInfo(apiNodePtr.i).getType();
switch(type){
case NodeInfo::API:
compatability_check = ndbCompatible_ndb_api(NDB_VERSION, version);
if (!compatability_check)
infoEvent("Connection attempt from api or mysqld id=%d with %s "
"incompatible with %s", apiNodePtr.i,
getVersionString(version,""), NDB_VERSION_STRING);
break;
case NodeInfo::MGM:
compatability_check = ndbCompatible_ndb_mgmt(NDB_VERSION, version);
if (!compatability_check)
infoEvent("Connection attempt from management server id=%d with %s "
"incompatible with %s", apiNodePtr.i,
getVersionString(version,""), NDB_VERSION_STRING);
break;
case NodeInfo::REP:
// compatability_check = ndbCompatible_ndb_api(NDB_VERSION, version);
......@@ -1953,13 +1946,19 @@ void Qmgr::execAPI_REGREQ(Signal* signal)
case NodeInfo::INVALID:
default:
sendApiRegRef(signal, ref, ApiRegRef::WrongType);
infoEvent("Invalid connection attempt with type %d",
getNodeInfo(apiNodePtr.i).getType());
infoEvent("Invalid connection attempt with type %d", type);
return;
}
if (!compatability_check) {
jam();
char buf[NDB_VERSION_STRING_BUF_SZ];
infoEvent("Connection attempt from %s id=%d with %s "
"incompatible with %s",
type == NodeInfo::API ? "api or mysqld" : "management server",
apiNodePtr.i,
getVersionString(version,"",buf,sizeof(buf)),
NDB_VERSION_STRING);
apiNodePtr.p->phase = ZAPI_INACTIVE;
sendApiRegRef(signal, ref, ApiRegRef::UnsupportedVersion);
return;
......@@ -2085,7 +2084,7 @@ void Qmgr::failReportLab(Signal* signal, Uint16 aFailedNode,
ptrCheckGuard(failedNodePtr, MAX_NODES, nodeRec);
if (failedNodePtr.i == getOwnNodeId()) {
jam();
systemErrorLab(signal);
systemErrorLab(signal, __LINE__);
return;
}//if
......@@ -2093,7 +2092,7 @@ void Qmgr::failReportLab(Signal* signal, Uint16 aFailedNode,
ptrCheckGuard(myNodePtr, MAX_NDB_NODES, nodeRec);
if (myNodePtr.p->phase != ZRUNNING) {
jam();
systemErrorLab(signal);
systemErrorLab(signal, __LINE__);
return;
}//if
TnoFailedNodes = cnoFailedNodes;
......@@ -2172,7 +2171,7 @@ void Qmgr::execPREP_FAILREQ(Signal* signal)
ptrCheckGuard(myNodePtr, MAX_NDB_NODES, nodeRec);
if (myNodePtr.p->phase != ZRUNNING) {
jam();
systemErrorLab(signal);
systemErrorLab(signal, __LINE__);
return;
}//if
......@@ -2675,7 +2674,7 @@ void Qmgr::execREAD_NODESREQ(Signal* signal)
ReadNodesConf::SignalLength, JBB);
}//Qmgr::execREAD_NODESREQ()
void Qmgr::systemErrorBecauseOtherNodeFailed(Signal* signal,
void Qmgr::systemErrorBecauseOtherNodeFailed(Signal* signal, Uint32 line,
NodeId failedNodeId) {
jam();
......@@ -2687,11 +2686,11 @@ void Qmgr::systemErrorBecauseOtherNodeFailed(Signal* signal,
"Node was shutdown during startup because node %d failed",
failedNodeId);
progError(__LINE__, ERR_SR_OTHERNODEFAILED, buf);
progError(line, ERR_SR_OTHERNODEFAILED, buf);
}
void Qmgr::systemErrorLab(Signal* signal, const char * message)
void Qmgr::systemErrorLab(Signal* signal, Uint32 line, const char * message)
{
jam();
// Broadcast that this node is failing to other nodes
......@@ -2699,7 +2698,7 @@ void Qmgr::systemErrorLab(Signal* signal, const char * message)
// If it's known why shutdown occured
// an error message has been passed to this function
progError(__LINE__, 0, message);
progError(line, 0, message);
return;
}//Qmgr::systemErrorLab()
......@@ -2867,7 +2866,7 @@ Uint16 Qmgr::translateDynamicIdToNodeId(Signal* signal, UintR TdynamicId)
}//for
if (TtdiNodeId == ZNIL) {
jam();
systemErrorLab(signal);
systemErrorLab(signal, __LINE__);
}//if
return TtdiNodeId;
}//Qmgr::translateDynamicIdToNodeId()
......
......@@ -143,6 +143,7 @@ extern "C"
NdbMgmHandle
ndb_mgm_create_handle()
{
DBUG_ENTER("ndb_mgm_create_handle");
NdbMgmHandle h =
(NdbMgmHandle)my_malloc(sizeof(ndb_mgm_handle),MYF(MY_WME));
h->connected = 0;
......@@ -162,17 +163,20 @@ ndb_mgm_create_handle()
h->logfile = 0;
#endif
return h;
DBUG_PRINT("exit",("ret: %lx", h));
DBUG_RETURN(h);
}
extern "C"
int
ndb_mgm_set_connectstring(NdbMgmHandle handle, const char * mgmsrv)
{
handle->cfg.~LocalConfig();
new (&(handle->cfg)) LocalConfig;
if (!handle->cfg.init(mgmsrv, 0) ||
handle->cfg.ids.size() == 0)
{
handle->cfg.~LocalConfig();
new (&(handle->cfg)) LocalConfig;
handle->cfg.init(0, 0); /* reset the LocalCongig */
SET_ERROR(handle, NDB_MGM_ILLEGAL_CONNECT_STRING, "");
......@@ -189,8 +193,11 @@ extern "C"
void
ndb_mgm_destroy_handle(NdbMgmHandle * handle)
{
DBUG_ENTER("ndb_mgm_destroy_handle");
if(!handle)
return;
DBUG_PRINT("enter",("*handle: %lx", *handle));
if((* handle)->connected){
ndb_mgm_disconnect(* handle);
}
......@@ -203,6 +210,7 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle)
(*handle)->cfg.~LocalConfig();
my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR));
* handle = 0;
DBUG_VOID_RETURN;
}
/*****************************************************************************
......@@ -251,6 +259,9 @@ static const Properties *
ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply,
const char *cmd, const Properties *cmd_args)
{
DBUG_ENTER("ndb_mgm_call");
DBUG_PRINT("enter",("handle->socket: %d, cmd: %s",
handle->socket, cmd));
SocketOutputStream out(handle->socket);
SocketInputStream in(handle->socket, handle->read_timeout);
......@@ -310,6 +321,8 @@ ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply,
/**
* Print some info about why the parser returns NULL
*/
DBUG_PRINT("info",("ctx.status: %d, ctx.m_currentToken: %s",
ctx.m_status, ctx.m_currentToken));
//ndbout << " status=" << ctx.m_status << ", curr="
//<< ctx.m_currentToken << endl;
}
......@@ -321,9 +334,9 @@ ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply,
p->print(handle->logfile, "IN: ");
}
#endif
return p;
DBUG_RETURN(p);
#else
return parser.parse(ctx, session);
DBUG_RETURN(parser.parse(ctx, session));
#endif
}
......
......@@ -455,11 +455,13 @@ static int do_event_thread;
static void*
event_thread_run(void* m)
{
DBUG_ENTER("event_thread_run");
NdbMgmHandle handle= *(NdbMgmHandle*)m;
int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 };
int fd = ndb_mgm_listen_event(handle, filter);
if (fd > 0)
if (fd != NDB_INVALID_SOCKET)
{
do_event_thread= 1;
char *tmp= 0;
......@@ -468,20 +470,26 @@ event_thread_run(void* m)
do {
if (tmp == 0) NdbSleep_MilliSleep(10);
if((tmp = in.gets(buf, 1024)))
ndbout << tmp;
{
const char ping_token[]= "<PING>";
if (memcmp(ping_token,tmp,sizeof(ping_token)-1))
ndbout << tmp;
}
} while(do_event_thread);
NDB_CLOSE_SOCKET(fd);
}
else
{
do_event_thread= -1;
}
return NULL;
DBUG_RETURN(NULL);
}
bool
CommandInterpreter::connect()
{
DBUG_ENTER("CommandInterpreter::connect");
if(!m_connected)
{
if(!ndb_mgm_connect(m_mgmsrv, try_reconnect-1, 5, 1))
......@@ -512,8 +520,19 @@ CommandInterpreter::connect()
do_event_thread == 0 ||
do_event_thread == -1)
{
printf("Warning, event thread startup failed, degraded printouts as result\n");
DBUG_PRINT("info",("Warning, event thread startup failed, "
"degraded printouts as result, errno=%d",
errno));
printf("Warning, event thread startup failed, "
"degraded printouts as result, errno=%d\n", errno);
do_event_thread= 0;
if (m_event_thread)
{
void *res;
NdbThread_WaitFor(m_event_thread, &res);
NdbThread_Destroy(&m_event_thread);
}
ndb_mgm_disconnect(m_mgmsrv2);
}
}
else
......@@ -521,6 +540,8 @@ CommandInterpreter::connect()
printf("Warning, event connect failed, degraded printouts as result\n");
}
m_connected= true;
DBUG_PRINT("info",("Connected to Management Server at: %s:%d",
host,port));
if (m_verbose)
{
printf("Connected to Management Server at: %s:%d\n",
......@@ -528,12 +549,13 @@ CommandInterpreter::connect()
}
}
}
return m_connected;
DBUG_RETURN(m_connected);
}
bool
CommandInterpreter::disconnect()
{
DBUG_ENTER("CommandInterpreter::disconnect");
if (m_event_thread) {
void *res;
do_event_thread= 0;
......@@ -550,7 +572,7 @@ CommandInterpreter::disconnect()
}
m_connected= false;
}
return true;
DBUG_RETURN(true);
}
//*****************************************************************************
......
......@@ -44,7 +44,9 @@ static Ndb_mgmclient* com;
extern "C"
void
handler(int sig){
handler(int sig)
{
DBUG_ENTER("handler");
switch(sig){
case SIGPIPE:
/**
......@@ -54,6 +56,7 @@ handler(int sig){
com->disconnect();
break;
}
DBUG_VOID_RETURN;
}
NDB_STD_OPTS_VARS;
......@@ -166,7 +169,8 @@ int main(int argc, char** argv){
com->execute(opt_execute_str,_try_reconnect, &ret);
}
delete com;
ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
return ret;
}
......@@ -571,10 +571,11 @@ MgmtSrvr::check_start()
bool
MgmtSrvr::start(BaseString &error_string)
{
DBUG_ENTER("MgmtSrvr::start");
if (_props == NULL) {
if (!check_start()) {
error_string.append("MgmtSrvr.cpp: check_start() failed.");
return false;
DBUG_RETURN(false);
}
}
theFacade= TransporterFacade::theFacadeInstance= new TransporterFacade();
......@@ -582,12 +583,12 @@ MgmtSrvr::start(BaseString &error_string)
if(theFacade == 0) {
DEBUG("MgmtSrvr.cpp: theFacade is NULL.");
error_string.append("MgmtSrvr.cpp: theFacade is NULL.");
return false;
DBUG_RETURN(false);
}
if ( theFacade->start_instance
(_ownNodeId, (ndb_mgm_configuration*)_config->m_configValues) < 0) {
DEBUG("MgmtSrvr.cpp: TransporterFacade::start_instance < 0.");
return false;
DBUG_RETURN(false);
}
MGM_REQUIRE(_blockNumber == 1);
......@@ -603,7 +604,7 @@ MgmtSrvr::start(BaseString &error_string)
error_string.append("MgmtSrvr.cpp: _blockNumber is -1.");
theFacade->stop_instance();
theFacade = 0;
return false;
DBUG_RETURN(false);
}
_ownReference = numberToRef(_blockNumber, _ownNodeId);
......@@ -625,7 +626,7 @@ MgmtSrvr::start(BaseString &error_string)
"MgmtSrvr_Service",
NDB_THREAD_PRIO_LOW);
return true;
DBUG_RETURN(true);
}
......@@ -639,6 +640,7 @@ MgmtSrvr::~MgmtSrvr()
if(theFacade != 0){
theFacade->stop_instance();
delete theFacade;
theFacade = 0;
}
......@@ -2124,6 +2126,24 @@ MgmtSrvr::getNodeType(NodeId nodeId) const
return nodeTypes[nodeId];
}
const char *MgmtSrvr::get_connect_address(Uint32 node_id)
{
if (m_connect_address[node_id].s_addr == 0 &&
theFacade && theFacade->theTransporterRegistry &&
theFacade->theClusterMgr &&
getNodeType(node_id) == NDB_MGM_NODE_TYPE_NDB)
{
const ClusterMgr::Node &node=
theFacade->theClusterMgr->getNodeInfo(node_id);
if (node.connected)
{
m_connect_address[node_id]=
theFacade->theTransporterRegistry->get_connect_address(node_id);
}
}
return inet_ntoa(m_connect_address[node_id]);
}
void
MgmtSrvr::get_connected_nodes(NodeBitmask &connected_nodes) const
{
......@@ -2583,19 +2603,6 @@ MgmtSrvr::repCommand(Uint32* repReqId, Uint32 request, bool waitCompleted)
}
/*****************************************************************************
* Area 51 ???
*****************************************************************************/
MgmtSrvr::Area51
MgmtSrvr::getStuff()
{
Area51 ret;
ret.theFacade = theFacade;
ret.theRegistry = theFacade->theTransporterRegistry;
return ret;
}
NodeId
MgmtSrvr::getPrimaryNode() const {
#if 0
......
......@@ -60,6 +60,7 @@ public:
}
void add_listener(const Event_listener&);
void check_listeners();
void update_max_log_level(const LogLevel&);
void update_log_level(const LogLevel&);
......@@ -508,7 +509,7 @@ public:
int setDbParameter(int node, int parameter, const char * value, BaseString&);
const char *get_connect_address(Uint32 node_id) { return inet_ntoa(m_connect_address[node_id]); }
const char *get_connect_address(Uint32 node_id);
void get_connected_nodes(NodeBitmask &connected_nodes) const;
SocketServer *get_socket_server() { return m_socket_server; }
......@@ -764,16 +765,6 @@ private:
int send(class NdbApiSignal* signal, Uint32 node, Uint32 node_type);
ConfigRetriever *m_config_retriever;
public:
/**
* This method does not exist
*/
struct Area51 {
class TransporterFacade * theFacade;
class TransporterRegistry * theRegistry;
};
Area51 getStuff();
};
inline
......
......@@ -253,15 +253,19 @@ ParserRow<MgmApiSession> commands[] = {
};
MgmApiSession::MgmApiSession(class MgmtSrvr & mgm, NDB_SOCKET_TYPE sock)
: SocketServer::Session(sock), m_mgmsrv(mgm) {
: SocketServer::Session(sock), m_mgmsrv(mgm)
{
DBUG_ENTER("MgmApiSession::MgmApiSession");
m_input = new SocketInputStream(sock);
m_output = new SocketOutputStream(sock);
m_parser = new Parser_t(commands, *m_input, true, true, true);
m_allocated_resources= new MgmtSrvr::Allocated_resources(m_mgmsrv);
DBUG_VOID_RETURN;
}
MgmApiSession::~MgmApiSession()
{
DBUG_ENTER("MgmApiSession::~MgmApiSession");
if (m_input)
delete m_input;
if (m_output)
......@@ -270,10 +274,19 @@ MgmApiSession::~MgmApiSession()
delete m_parser;
if (m_allocated_resources)
delete m_allocated_resources;
if(m_socket != NDB_INVALID_SOCKET)
{
NDB_CLOSE_SOCKET(m_socket);
m_socket= NDB_INVALID_SOCKET;
}
DBUG_VOID_RETURN;
}
void
MgmApiSession::runSession() {
MgmApiSession::runSession()
{
DBUG_ENTER("MgmApiSession::runSession");
Parser_t::Context ctx;
while(!m_stop) {
m_parser->run(ctx, *this);
......@@ -301,8 +314,13 @@ MgmApiSession::runSession() {
break;
}
}
if(m_socket >= 0)
if(m_socket != NDB_INVALID_SOCKET)
{
NDB_CLOSE_SOCKET(m_socket);
m_socket= NDB_INVALID_SOCKET;
}
DBUG_VOID_RETURN;
}
#ifdef MGM_GET_CONFIG_BACKWARDS_COMPAT
......@@ -1236,7 +1254,7 @@ Ndb_mgmd_event_service::log(int eventType, const Uint32* theData, NodeId nodeId)
Uint32 threshold;
LogLevel::EventCategory cat;
Logger::LoggerLevel severity;
int i;
int i, n;
DBUG_ENTER("Ndb_mgmd_event_service::log");
DBUG_PRINT("enter",("eventType=%d, nodeid=%d", eventType, nodeId));
......@@ -1248,28 +1266,30 @@ Ndb_mgmd_event_service::log(int eventType, const Uint32* theData, NodeId nodeId)
Vector<NDB_SOCKET_TYPE> copy;
m_clients.lock();
for(i = m_clients.size() - 1; i >= 0; i--){
if(threshold <= m_clients[i].m_logLevel.getLogLevel(cat)){
if(m_clients[i].m_socket != NDB_INVALID_SOCKET &&
println_socket(m_clients[i].m_socket,
MAX_WRITE_TIMEOUT, m_text) == -1){
copy.push_back(m_clients[i].m_socket);
for(i = m_clients.size() - 1; i >= 0; i--)
{
if(threshold <= m_clients[i].m_logLevel.getLogLevel(cat))
{
int fd= m_clients[i].m_socket;
if(fd != NDB_INVALID_SOCKET &&
println_socket(fd, MAX_WRITE_TIMEOUT, m_text) == -1)
{
copy.push_back(fd);
m_clients.erase(i, false);
}
}
}
m_clients.unlock();
for(i = 0; (unsigned)i < copy.size(); i++){
NDB_CLOSE_SOCKET(copy[i]);
}
if ((n= (int)copy.size()))
{
for(i= 0; i < n; i++)
NDB_CLOSE_SOCKET(copy[i]);
if(copy.size()){
LogLevel tmp; tmp.clear();
m_clients.lock();
for(i = 0; (unsigned)i < m_clients.size(); i++){
for(i= m_clients.size() - 1; i >= 0; i--)
tmp.set_max(m_clients[i].m_logLevel);
}
m_clients.unlock();
update_log_level(tmp);
}
......@@ -1297,9 +1317,48 @@ Ndb_mgmd_event_service::update_log_level(const LogLevel &tmp)
}
void
Ndb_mgmd_event_service::add_listener(const Event_listener& client){
Ndb_mgmd_event_service::check_listeners()
{
int i, n= 0;
DBUG_ENTER("Ndb_mgmd_event_service::check_listeners");
m_clients.lock();
for(i= m_clients.size() - 1; i >= 0; i--)
{
int fd= m_clients[i].m_socket;
DBUG_PRINT("info",("%d %d",i,fd));
char buf[1];
buf[0]=0;
if (fd != NDB_INVALID_SOCKET &&
println_socket(fd,MAX_WRITE_TIMEOUT,"<PING>") == -1)
{
NDB_CLOSE_SOCKET(fd);
m_clients.erase(i, false);
n=1;
}
}
if (n)
{
LogLevel tmp; tmp.clear();
for(i= m_clients.size() - 1; i >= 0; i--)
tmp.set_max(m_clients[i].m_logLevel);
update_log_level(tmp);
}
m_clients.unlock();
DBUG_VOID_RETURN;
}
void
Ndb_mgmd_event_service::add_listener(const Event_listener& client)
{
DBUG_ENTER("Ndb_mgmd_event_service::add_listener");
DBUG_PRINT("enter",("client.m_socket: %d", client.m_socket));
check_listeners();
m_clients.push_back(client);
update_max_log_level(client.m_logLevel);
DBUG_VOID_RETURN;
}
void
......
......@@ -53,16 +53,16 @@ const char progname[] = "mgmtsrvr";
* @struct MgmGlobals
* @brief Global Variables used in the management server
******************************************************************************/
/** Command line arguments */
static int opt_daemon; // NOT bool, bool need not be int
static int opt_non_interactive;
static int opt_interactive;
static const char * opt_config_filename= 0;
struct MgmGlobals {
MgmGlobals();
~MgmGlobals();
/** Command line arguments */
int daemon; // NOT bool, bool need not be int
int non_interactive;
int interactive;
const char * config_filename;
/** Stuff found in environment or in local config */
NodeId localNodeId;
bool use_specific_ip;
......@@ -77,7 +77,7 @@ struct MgmGlobals {
};
int g_no_nodeid_checks= 0;
static MgmGlobals glob;
static MgmGlobals *glob= 0;
/******************************************************************************
* Function prototypes
......@@ -108,14 +108,14 @@ static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_mgmd"),
{ "config-file", 'f', "Specify cluster configuration file",
(gptr*) &glob.config_filename, (gptr*) &glob.config_filename, 0,
(gptr*) &opt_config_filename, (gptr*) &opt_config_filename, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "daemon", 'd', "Run ndb_mgmd in daemon mode (default)",
(gptr*) &glob.daemon, (gptr*) &glob.daemon, 0,
(gptr*) &opt_daemon, (gptr*) &opt_daemon, 0,
GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 },
{ "interactive", OPT_INTERACTIVE,
"Run interactive. Not supported but provided for testing purposes",
(gptr*) &glob.interactive, (gptr*) &glob.interactive, 0,
(gptr*) &opt_interactive, (gptr*) &opt_interactive, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "no-nodeid-checks", OPT_NO_NODEID_CHECKS,
"Do not provide any node id checks",
......@@ -123,13 +123,13 @@ static struct my_option my_long_options[] =
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "nodaemon", OPT_NO_DAEMON,
"Don't run as daemon, but don't read from stdin",
(gptr*) &glob.non_interactive, (gptr*) &glob.non_interactive, 0,
(gptr*) &opt_non_interactive, (gptr*) &opt_non_interactive, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
#if NDB_VERSION_MAJOR <= 4
{ "config-file", 'c',
"-c provided for backwards compatability, will be removed in 5.0."
" Use -f instead",
(gptr*) &glob.config_filename, (gptr*) &glob.config_filename, 0,
(gptr*) &opt_config_filename, (gptr*) &opt_config_filename, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
#endif
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
......@@ -167,6 +167,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
int main(int argc, char** argv)
{
NDB_INIT(argv[0]);
glob= new MgmGlobals;
/**
* OSE specific. Enable shared ownership of file system resources.
......@@ -186,40 +187,40 @@ int main(int argc, char** argv)
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error);
if (glob.interactive ||
glob.non_interactive) {
glob.daemon= 0;
if (opt_interactive ||
opt_non_interactive) {
opt_daemon= 0;
}
glob.socketServer = new SocketServer();
glob->socketServer = new SocketServer();
MgmApiService * mapi = new MgmApiService();
glob.mgmObject = new MgmtSrvr(glob.socketServer,
glob.config_filename,
glob->mgmObject = new MgmtSrvr(glob->socketServer,
opt_config_filename,
opt_connect_str);
if (glob.mgmObject->init())
if (glob->mgmObject->init())
goto error_end;
my_setwd(NdbConfig_get_path(0), MYF(0));
glob.localNodeId= glob.mgmObject->getOwnNodeId();
if (glob.localNodeId == 0) {
glob->localNodeId= glob->mgmObject->getOwnNodeId();
if (glob->localNodeId == 0) {
goto error_end;
}
glob.port= glob.mgmObject->getPort();
glob->port= glob->mgmObject->getPort();
if (glob.port == 0)
if (glob->port == 0)
goto error_end;
glob.interface_name = 0;
glob.use_specific_ip = false;
glob->interface_name = 0;
glob->use_specific_ip = false;
if(!glob.use_specific_ip){
if(!glob->use_specific_ip){
int count= 5; // no of retries for tryBind
while(!glob.socketServer->tryBind(glob.port, glob.interface_name)){
while(!glob->socketServer->tryBind(glob->port, glob->interface_name)){
if (--count > 0) {
NdbSleep_MilliSleep(1000);
continue;
......@@ -228,33 +229,33 @@ int main(int argc, char** argv)
"Please check if the port is already used,\n"
"(perhaps a ndb_mgmd is already running),\n"
"and if you are executing on the correct computer",
(glob.interface_name ? glob.interface_name : "*"), glob.port);
(glob->interface_name ? glob->interface_name : "*"), glob->port);
goto error_end;
}
free(glob.interface_name);
glob.interface_name = 0;
free(glob->interface_name);
glob->interface_name = 0;
}
if(!glob.socketServer->setup(mapi, glob.port, glob.interface_name)){
if(!glob->socketServer->setup(mapi, glob->port, glob->interface_name)){
ndbout_c("Unable to setup management port: %d!\n"
"Please check if the port is already used,\n"
"(perhaps a ndb_mgmd is already running),\n"
"and if you are executing on the correct computer",
glob.port);
glob->port);
delete mapi;
goto error_end;
}
if(!glob.mgmObject->check_start()){
if(!glob->mgmObject->check_start()){
ndbout_c("Unable to check start management server.");
ndbout_c("Probably caused by illegal initial configuration file.");
goto error_end;
}
if (glob.daemon) {
if (opt_daemon) {
// Become a daemon
char *lockfile= NdbConfig_PidFileName(glob.localNodeId);
char *logfile= NdbConfig_StdoutFileName(glob.localNodeId);
char *lockfile= NdbConfig_PidFileName(glob->localNodeId);
char *logfile= NdbConfig_StdoutFileName(glob->localNodeId);
NdbAutoPtr<char> tmp_aptr1(lockfile), tmp_aptr2(logfile);
if (NdbDaemon_Make(lockfile, logfile, 0) == -1) {
......@@ -268,7 +269,7 @@ int main(int argc, char** argv)
#endif
{
BaseString error_string;
if(!glob.mgmObject->start(error_string)){
if(!glob->mgmObject->start(error_string)){
ndbout_c("Unable to start management server.");
ndbout_c("Probably caused by illegal initial configuration file.");
ndbout_c(error_string.c_str());
......@@ -276,8 +277,8 @@ int main(int argc, char** argv)
}
}
//glob.mgmObject->saveConfig();
mapi->setMgm(glob.mgmObject);
//glob->mgmObject->saveConfig();
mapi->setMgm(glob->mgmObject);
char msg[256];
BaseString::snprintf(msg, sizeof(msg),
......@@ -286,16 +287,16 @@ int main(int argc, char** argv)
g_eventLogger.info(msg);
BaseString::snprintf(msg, 256, "Id: %d, Command port: %d",
glob.localNodeId, glob.port);
glob->localNodeId, glob->port);
ndbout_c(msg);
g_eventLogger.info(msg);
g_StopServer = false;
glob.socketServer->startServer();
glob->socketServer->startServer();
#if ! defined NDB_OSE && ! defined NDB_SOFTOSE
if(glob.interactive) {
CommandInterpreter com(* glob.mgmObject);
if(opt_interactive) {
CommandInterpreter com(* glob->mgmObject);
while(com.readAndExecute());
} else
#endif
......@@ -305,22 +306,22 @@ int main(int argc, char** argv)
}
g_eventLogger.info("Shutting down server...");
glob.socketServer->stopServer();
glob.socketServer->stopSessions();
glob->socketServer->stopServer();
glob->socketServer->stopSessions(true);
g_eventLogger.info("Shutdown complete");
delete glob;
ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
return 0;
error_end:
delete glob;
ndb_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
return 1;
}
MgmGlobals::MgmGlobals(){
// Default values
port = 0;
config_filename = NULL;
interface_name = 0;
daemon = 1;
non_interactive = 0;
interactive = 0;
socketServer = 0;
mgmObject = 0;
}
......
......@@ -64,16 +64,21 @@ ClusterMgr::ClusterMgr(TransporterFacade & _facade):
theStop(0),
theFacade(_facade)
{
DBUG_ENTER("ClusterMgr::ClusterMgr");
ndbSetOwnVersion();
clusterMgrThreadMutex = NdbMutex_Create();
noOfAliveNodes= 0;
noOfConnectedNodes= 0;
theClusterMgrThread= 0;
DBUG_VOID_RETURN;
}
ClusterMgr::~ClusterMgr(){
ClusterMgr::~ClusterMgr()
{
DBUG_ENTER("ClusterMgr::~ClusterMgr");
doStop();
NdbMutex_Destroy(clusterMgrThreadMutex);
DBUG_VOID_RETURN;
}
void
......@@ -152,7 +157,6 @@ ClusterMgr::doStop( ){
if (theClusterMgrThread) {
NdbThread_WaitFor(theClusterMgrThread, &status);
NdbThread_Destroy(&theClusterMgrThread);
theClusterMgrThread= 0;
}
NdbMutex_Unlock(clusterMgrThreadMutex);
DBUG_VOID_RETURN;
......@@ -468,6 +472,8 @@ ClusterMgr::reportNodeFailed(NodeId nodeId){
ArbitMgr::ArbitMgr(TransporterFacade & _fac)
: theFacade(_fac)
{
DBUG_ENTER("ArbitMgr::ArbitMgr");
theThreadMutex = NdbMutex_Create();
theInputCond = NdbCondition_Create();
theInputMutex = NdbMutex_Create();
......@@ -485,13 +491,17 @@ ArbitMgr::ArbitMgr(TransporterFacade & _fac)
memset(&theChooseReq1, 0, sizeof(theChooseReq1));
memset(&theChooseReq2, 0, sizeof(theChooseReq2));
memset(&theStopOrd, 0, sizeof(theStopOrd));
DBUG_VOID_RETURN;
}
ArbitMgr::~ArbitMgr()
{
DBUG_ENTER("ArbitMgr::~ArbitMgr");
NdbMutex_Destroy(theThreadMutex);
NdbCondition_Destroy(theInputCond);
NdbMutex_Destroy(theInputMutex);
DBUG_VOID_RETURN;
}
// Start arbitrator thread. This is kernel request.
......@@ -508,7 +518,7 @@ ArbitMgr::doStart(const Uint32* theData)
sendSignalToThread(aSignal);
void* value;
NdbThread_WaitFor(theThread, &value);
theThread = NULL;
NdbThread_Destroy(&theThread);
theState = StateInit;
theInputFull = false;
}
......@@ -547,7 +557,7 @@ ArbitMgr::doStop(const Uint32* theData)
sendSignalToThread(aSignal);
void* value;
NdbThread_WaitFor(theThread, &value);
theThread = NULL;
NdbThread_Destroy(&theThread);
theState = StateInit;
}
NdbMutex_Unlock(theThreadMutex);
......
......@@ -395,12 +395,10 @@ TransporterFacade::doStop(){
if (theReceiveThread) {
NdbThread_WaitFor(theReceiveThread, &status);
NdbThread_Destroy(&theReceiveThread);
theReceiveThread= 0;
}
if (theSendThread) {
NdbThread_WaitFor(theSendThread, &status);
NdbThread_Destroy(&theSendThread);
theSendThread= 0;
}
DBUG_VOID_RETURN;
}
......@@ -435,7 +433,7 @@ void TransporterFacade::threadMainSend(void)
theTransporterRegistry->stopSending();
m_socket_server.stopServer();
m_socket_server.stopSessions();
m_socket_server.stopSessions(true);
theTransporterRegistry->stop_clients();
}
......@@ -477,6 +475,8 @@ TransporterFacade::TransporterFacade() :
theReceiveThread(NULL),
m_fragmented_signal_id(0)
{
DBUG_ENTER("TransporterFacade::TransporterFacade");
theOwnId = 0;
theMutexPtr = NdbMutex_Create();
......@@ -493,11 +493,15 @@ TransporterFacade::TransporterFacade() :
m_max_trans_id = 0;
theClusterMgr = new ClusterMgr(* this);
DBUG_VOID_RETURN;
}
bool
TransporterFacade::init(Uint32 nodeId, const ndb_mgm_configuration* props)
{
DBUG_ENTER("TransporterFacade::init");
theOwnId = nodeId;
theTransporterRegistry = new TransporterRegistry(this);
......@@ -506,7 +510,7 @@ TransporterFacade::init(Uint32 nodeId, const ndb_mgm_configuration* props)
* theTransporterRegistry);
if(res <= 0){
TRP_DEBUG( "configureTransporters returned 0 or less" );
return false;
DBUG_RETURN(false);
}
ndb_mgm_configuration_iterator iter(* props, CFG_SECTION_NODE);
......@@ -524,7 +528,7 @@ TransporterFacade::init(Uint32 nodeId, const ndb_mgm_configuration* props)
iter.first();
if(iter.find(CFG_NODE_ID, nodeId)){
TRP_DEBUG( "Node info missing from config." );
return false;
DBUG_RETURN(false);
}
Uint32 rank = 0;
......@@ -553,7 +557,7 @@ TransporterFacade::init(Uint32 nodeId, const ndb_mgm_configuration* props)
if (!theTransporterRegistry->start_service(m_socket_server)){
ndbout_c("Unable to start theTransporterRegistry->start_service");
return false;
DBUG_RETURN(false);
}
theReceiveThread = NdbThread_Create(runReceiveResponse_C,
......@@ -573,7 +577,7 @@ TransporterFacade::init(Uint32 nodeId, const ndb_mgm_configuration* props)
signalLogger.logOn(true, 0, SignalLoggerManager::LogInOut);
#endif
return true;
DBUG_RETURN(true);
}
......@@ -694,8 +698,10 @@ TransporterFacade::open(void* objRef,
DBUG_RETURN(r);
}
TransporterFacade::~TransporterFacade(){
TransporterFacade::~TransporterFacade()
{
DBUG_ENTER("TransporterFacade::~TransporterFacade");
NdbMutex_Lock(theMutexPtr);
delete theClusterMgr;
delete theArbitMgr;
......@@ -705,6 +711,7 @@ TransporterFacade::~TransporterFacade(){
#ifdef API_TRACE
signalLogger.setOutputStream(0);
#endif
DBUG_VOID_RETURN;
}
void
......
......@@ -251,8 +251,9 @@ main(int argc, char** argv)
const BackupFormat::FileHeader & tmp = metaData.getFileHeader();
const Uint32 version = tmp.NdbVersion;
char buf[NDB_VERSION_STRING_BUF_SZ];
ndbout << "Ndb version in backup files: "
<< getVersionString(version, 0) << endl;
<< getVersionString(version, 0, buf, sizeof(buf)) << endl;
/**
* check wheater we can restore the backup (right version).
......
......@@ -306,24 +306,28 @@ static void set_param_int64(Item_param *param, uchar **pos, ulong len)
static void set_param_float(Item_param *param, uchar **pos, ulong len)
{
float data;
#ifndef EMBEDDED_LIBRARY
if (len < 4)
return;
#endif
float data;
float4get(data,*pos);
#else
data= *(float*) *pos;
#endif
param->set_double((double) data);
*pos+= 4;
}
static void set_param_double(Item_param *param, uchar **pos, ulong len)
{
double data;
#ifndef EMBEDDED_LIBRARY
if (len < 8)
return;
#endif
double data;
float8get(data,*pos);
#else
data= *(double*) *pos;
#endif
param->set_double((double) data);
*pos+= 8;
}
......
......@@ -437,19 +437,20 @@ then
/sbin/chkconfig --add mysql
fi
# Create a MySQL user. Do not report any problems if it already
# exists. This is redhat specific and should be handled more portable
useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" %{mysqld_user} 2> /dev/null || true
# Create a MySQL user and group. Do not report any problems if it already
# exists.
groupadd -r -c "MySQL server" %{mysqld_user} 2> /dev/null || true
useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" -g %{mysqld_user} %{mysqld_user} 2> /dev/null || true
# Change permissions so that the user that will run the MySQL daemon
# owns all database files.
chown -R %{mysqld_user} $mysql_datadir
chown -R %{mysqld_user}:%{mysqld_user} $mysql_datadir
# Initiate databases
%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user}
# Change permissions again to fix any new files.
chown -R %{mysqld_user} $mysql_datadir
chown -R %{mysqld_user}:%{mysqld_user} $mysql_datadir
# Fix permissions for the permission database so that only the user
# can read them.
......@@ -667,6 +668,11 @@ fi
# itself - note that they must be ordered by date (important when
# merging BK trees)
%changelog
* Fri Jul 15 2005 Lenz Grimmer <lenz@mysql.com>
- create a "mysql" user group and assign the mysql user account to that group
in the server postinstall section. (BUG 10984)
* Tue Jun 14 2005 Lenz Grimmer <lenz@mysql.com>
- Do not build statically on i386 by default, only when adding either "--with
......
......@@ -166,6 +166,14 @@ DIE_UNLESS(stmt == 0);\
#define mytest_r(x) if (x) {myerror(NULL);DIE_UNLESS(FALSE);}
/* A workaround for Sun Forte 5.6 on Solaris x86 */
static int cmp_double(double *a, double *b)
{
return *a == *b;
}
/* Print the error message */
static void print_error(const char *msg)
......@@ -1396,7 +1404,7 @@ static void test_prepare()
DIE_UNLESS(real_data == o_real_data);
DIE_UNLESS(length[5] == 4);
DIE_UNLESS(double_data == o_double_data);
DIE_UNLESS(cmp_double(&double_data, &o_double_data));
DIE_UNLESS(length[6] == 8);
DIE_UNLESS(strcmp(data, str_data) == 0);
......@@ -9583,7 +9591,7 @@ static void test_bug3035()
uint32 uint32_val;
longlong int64_val;
ulonglong uint64_val;
double double_val, udouble_val;
double double_val, udouble_val, double_tmp;
char longlong_as_string[22], ulonglong_as_string[22];
/* mins and maxes */
......@@ -9727,7 +9735,8 @@ static void test_bug3035()
DIE_UNLESS(int64_val == int64_min);
DIE_UNLESS(uint64_val == uint64_min);
DIE_UNLESS(double_val == (longlong) uint64_min);
DIE_UNLESS(udouble_val == ulonglong2double(uint64_val));
double_tmp= ulonglong2double(uint64_val);
DIE_UNLESS(cmp_double(&udouble_val, &double_tmp));
DIE_UNLESS(!strcmp(longlong_as_string, "0"));
DIE_UNLESS(!strcmp(ulonglong_as_string, "0"));
......@@ -9743,7 +9752,8 @@ static void test_bug3035()
DIE_UNLESS(int64_val == int64_max);
DIE_UNLESS(uint64_val == uint64_max);
DIE_UNLESS(double_val == (longlong) uint64_val);
DIE_UNLESS(udouble_val == ulonglong2double(uint64_val));
double_tmp= ulonglong2double(uint64_val);
DIE_UNLESS(cmp_double(&udouble_val, &double_tmp));
DIE_UNLESS(!strcmp(longlong_as_string, "-1"));
DIE_UNLESS(!strcmp(ulonglong_as_string, "18446744073709551615"));
......
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