Below is the list of changes that have just been committed into a local
5.0 repository of mikron. When mikron does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1844 05/03/22 15:48:29 mronstrom@stripped +7 -0
Manual merge
ndb/src/ndbapi/TransporterFacade.hpp
1.27 05/03/22 15:48:22 mronstrom@stripped +0 -1
Manual merge
ndb/src/ndbapi/TransporterFacade.cpp
1.38 05/03/22 15:38:36 mronstrom@stripped +0 -0
Auto merged
ndb/src/ndbapi/Ndbif.cpp
1.28 05/03/22 15:38:35 mronstrom@stripped +0 -0
Auto merged
ndb/src/ndbapi/NdbDictionaryImpl.cpp
1.73 05/03/22 15:38:35 mronstrom@stripped +0 -0
Auto merged
ndb/src/ndbapi/Ndb.cpp
1.47 05/03/22 15:38:35 mronstrom@stripped +0 -0
Auto merged
ndb/include/ndbapi/Ndb.hpp
1.43 05/03/22 15:38:34 mronstrom@stripped +0 -0
Auto merged
BitKeeper/etc/logging_ok
1.306 05/03/22 15:37:52 mronstrom@stripped +0 -0
auto-union
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: mronstrom
# Host: mikael-ronstr-ms-dator.local
# Root: /Users/mikron/wl2405/RESYNC
--- 1.42/ndb/include/ndbapi/Ndb.hpp Tue Mar 22 15:24:33 2005
+++ 1.43/ndb/include/ndbapi/Ndb.hpp Tue Mar 22 15:38:34 2005
@@ -1220,12 +1220,12 @@
/**
* Drop a subscription to an event
*
- * @param eventName
- * unique identifier of the event
+ * @param eventOp
+ * Event operation
*
* @return 0 on success
*/
- int dropEventOperation(NdbEventOperation* eventName);
+ int dropEventOperation(NdbEventOperation* eventOp);
/**
* Wait for an event to occur. Will return as soon as an event
--- 1.46/ndb/src/ndbapi/Ndb.cpp Wed Feb 16 20:37:01 2005
+++ 1.47/ndb/src/ndbapi/Ndb.cpp Tue Mar 22 15:38:35 2005
@@ -173,23 +173,9 @@
tSignal->setData(theMyRef, 2); // Set my block reference
tNdbCon->Status(NdbTransaction::Connecting); // Set status to connecting
Uint32 nodeSequence;
- { // send and receive signal
- Guard guard(tp->theMutexPtr);
- nodeSequence = tp->getNodeSequence(tNode);
- bool node_is_alive = tp->get_node_alive(tNode);
- if (node_is_alive) {
- tReturnCode = tp->sendSignal(tSignal, tNode);
- releaseSignal(tSignal);
- if (tReturnCode != -1) {
- theImpl->theWaiter.m_node = tNode;
- theImpl->theWaiter.m_state = WAIT_TC_SEIZE;
- tReturnCode = receiveResponse();
- }//if
- } else {
- releaseSignal(tSignal);
- tReturnCode = -1;
- }//if
- }
+ tReturnCode= sendRecSignal(tNode, WAIT_TC_SEIZE, tSignal,
+ 0, nodeSequence);
+ releaseSignal(tSignal);
if ((tReturnCode == 0) && (tNdbCon->Status() == NdbTransaction::Connected)) {
//************************************************
// Send and receive was successful
--- 1.72/ndb/src/ndbapi/NdbDictionaryImpl.cpp Thu Mar 3 17:29:20 2005
+++ 1.73/ndb/src/ndbapi/NdbDictionaryImpl.cpp Tue Mar 22 15:38:35 2005
@@ -963,7 +963,13 @@
m_buffer.clear();
// Protected area
- m_transporter->lock_mutex();
+ /*
+ The PollGuard has an implicit call of unlock_and_signal through the
+ ~PollGuard method. This method is called implicitly by the compiler
+ in all places where the object is out of context due to a return,
+ break, continue or simply end of statement block
+ */
+ PollGuard poll_guard(m_transporter, &m_waiter, refToBlock(m_reference));
Uint32 aNodeId;
if (useMasterNodeId) {
if ((m_masterNodeId == 0) ||
@@ -976,7 +982,6 @@
}
if(aNodeId == 0){
m_error.code= 4009;
- m_transporter->unlock_mutex();
DBUG_RETURN(-1);
}
{
@@ -997,21 +1002,15 @@
r = m_transporter->sendSignal(signal, aNodeId);
}
if(r != 0){
- m_transporter->unlock_mutex();
continue;
}
}
m_error.code= 0;
-
- m_waiter.m_node = aNodeId;
- m_waiter.m_state = wst;
-
- m_waiter.wait(theWait);
- m_transporter->unlock_mutex();
+ int ret_val= poll_guard.wait_n_unlock(theWait, aNodeId, wst);
// End of Protected area
- if(m_waiter.m_state == NO_WAIT && m_error.code == 0){
+ if(ret_val == 0 && m_error.code == 0){
// Normal return
DBUG_RETURN(0);
}
@@ -1019,7 +1018,7 @@
/**
* Handle error codes
*/
- if(m_waiter.m_state == WAIT_NODE_FAILURE)
+ if(ret_val == -2) //WAIT_NODE_FAILURE
continue;
if(m_waiter.m_state == WST_WAIT_TIMEOUT)
@@ -3076,26 +3075,28 @@
for (Uint32 i = 0; i < RETRIES; i++) {
m_buffer.clear();
// begin protected
- m_transporter->lock_mutex();
+ /*
+ The PollGuard has an implicit call of unlock_and_signal through the
+ ~PollGuard method. This method is called implicitly by the compiler
+ in all places where the object is out of context due to a return,
+ break, continue or simply end of statement block
+ */
+ PollGuard poll_guard(m_transporter, &m_waiter, refToBlock(m_reference));
Uint16 aNodeId = m_transporter->get_an_alive_node();
if (aNodeId == 0) {
m_error.code= 4009;
- m_transporter->unlock_mutex();
return -1;
}
if (m_transporter->sendSignal(signal, aNodeId) != 0) {
- m_transporter->unlock_mutex();
continue;
}
m_error.code= 0;
- m_waiter.m_node = aNodeId;
- m_waiter.m_state = WAIT_LIST_TABLES_CONF;
- m_waiter.wait(WAITFOR_RESPONSE_TIMEOUT);
- m_transporter->unlock_mutex();
+ int ret_val= poll_guard.wait_n_unlock(WAITFOR_RESPONSE_TIMEOUT,
+ aNodeId, WAIT_LIST_TABLES_CONF);
// end protected
- if (m_waiter.m_state == NO_WAIT && m_error.code == 0)
+ if (ret_val == 0 && m_error.code == 0)
return 0;
- if (m_waiter.m_state == WAIT_NODE_FAILURE)
+ if (ret_val == -2) //WAIT_NODE_FAILURE
continue;
return -1;
}
--- 1.27/ndb/src/ndbapi/Ndbif.cpp Thu Feb 3 11:41:32 2005
+++ 1.28/ndb/src/ndbapi/Ndbif.cpp Tue Mar 22 15:38:35 2005
@@ -334,6 +334,7 @@
const Uint32 tFirstData = *tDataPtr;
const Uint32 tLen = aSignal->getLength();
void * tFirstDataPtr;
+ NdbWaiter *t_waiter;
/*
In order to support 64 bit processes in the application we need to use
@@ -679,12 +680,12 @@
case GSN_LIST_TABLES_CONF:
NdbDictInterface::execSignal(&theDictionary->m_receiver,
aSignal, ptr);
- break;
+ return;
case GSN_SUB_META_DATA:
case GSN_SUB_REMOVE_CONF:
case GSN_SUB_REMOVE_REF:
- break; // ignore these signals
+ return; // ignore these signals
case GSN_SUB_GCP_COMPLETE_REP:
case GSN_SUB_START_CONF:
case GSN_SUB_START_REF:
@@ -693,7 +694,7 @@
case GSN_SUB_STOP_REF:
NdbDictInterface::execSignal(&theDictionary->m_receiver,
aSignal, ptr);
- break;
+ return;
case GSN_DIHNDBTAMPER:
{
@@ -835,11 +836,33 @@
}
default:
goto InvalidSignal;
- }//switch
-
- if (theImpl->theWaiter.m_state == NO_WAIT) {
- // Wake up the thread waiting for response
- NdbCondition_Signal(theImpl->theWaiter.m_condition);
+ }//swich
+
+ t_waiter= &theImpl->theWaiter;
+ if (t_waiter->get_state() == NO_WAIT)
+ {
+ /*
+ If our waiter object is the owner of the "poll rights", then we
+ can simply return, we will return from this routine to the
+ place where external_poll was called. From there it will move
+ the "poll ownership" to a new thread if available.
+
+ If our waiter object doesn't own the "poll rights", then we must
+ signal the thread from where this waiter object called
+ its conditional wait. This will wake up this thread so that it
+ can continue its work.
+ */
+ TransporterFacade *tp= TransporterFacade::instance();
+ if (tp->get_poll_owner() != t_waiter)
+ {
+ /*
+ Wake up the thread waiting for response and remove it from queue
+ of objects waiting for receive completion
+ */
+ ndbout << "Remove t_waiter " << hex << t_waiter << " from queue" << endl;
+ tp->remove_from_cond_wait_queue(t_waiter);
+ t_waiter->cond_signal();
+ }
}//if
return;
@@ -894,7 +917,20 @@
if ((theMinNoOfEventsToWakeUp != 0) &&
(theNoOfCompletedTransactions >= theMinNoOfEventsToWakeUp)) {
theMinNoOfEventsToWakeUp = 0;
- NdbCondition_Signal(theImpl->theWaiter.m_condition);
+ TransporterFacade *tp = TransporterFacade::instance();
+ NdbWaiter *t_waiter= &theImpl->theWaiter;
+ if (tp->get_poll_owner() != t_waiter) {
+ /*
+ When we come here, this is executed by the thread owning the "poll
+ rights". This thread is not where our waiter object belongs.
+ Thus we wake up the thread owning this waiter object but first
+ we must remove it from the conditional wait queue so that we
+ don't assign it as poll owner later on.
+ */
+ ndbout << "Remove t_waiter " << hex << t_waiter << " from queue" << endl;
+ tp->remove_from_cond_wait_queue(t_waiter);
+ t_waiter->cond_signal();
+ }
return;
}//if
} else {
@@ -1153,7 +1189,8 @@
******************************************************************************/
void
Ndb::waitCompletedTransactions(int aMilliSecondsToWait,
- int noOfEventsToWaitFor)
+ int noOfEventsToWaitFor,
+ PollGuard *poll_guard)
{
theImpl->theWaiter.m_state = NO_WAIT;
/**
@@ -1162,22 +1199,24 @@
* (see ReportFailure)
*/
int waitTime = aMilliSecondsToWait;
- NDB_TICKS maxTime = NdbTick_CurrentMillisecond() + (NDB_TICKS)waitTime;
+ NDB_TICKS currTime = NdbTick_CurrentMillisecond();
+ NDB_TICKS maxTime = currTime + (NDB_TICKS)waitTime;
theMinNoOfEventsToWakeUp = noOfEventsToWaitFor;
do {
if (waitTime < 1000) waitTime = 1000;
- NdbCondition_WaitTimeout(theImpl->theWaiter.m_condition,
- (NdbMutex*)theImpl->theWaiter.m_mutex,
- waitTime);
+ poll_guard->wait_for_input(waitTime);
if (theNoOfCompletedTransactions >= (Uint32)noOfEventsToWaitFor) {
break;
}//if
theMinNoOfEventsToWakeUp = noOfEventsToWaitFor;
waitTime = (int)(maxTime - NdbTick_CurrentMillisecond());
} while (waitTime > 0);
- return;
}//Ndb::waitCompletedTransactions()
+void Ndb::cond_signal()
+{
+ NdbCondition_Signal(theImpl->theWaiter.m_condition);
+}
/*****************************************************************************
void sendPreparedTransactions(int forceSend = 0);
@@ -1205,28 +1244,39 @@
int
Ndb::sendPollNdb(int aMillisecondNumber, int minNoOfEventsToWakeup, int forceSend)
{
+ /*
+ The PollGuard has an implicit call of unlock_and_signal through the
+ ~PollGuard method. This method is called implicitly by the compiler
+ in all places where the object is out of context due to a return,
+ break, continue or simply end of statement block
+ */
+ PollGuard pg(TransporterFacade::instance(), &theImpl->theWaiter,
+ theNdbBlockNumber);
+ sendPrepTrans(forceSend);
+ return poll_trans(aMillisecondNumber, minNoOfEventsToWakeup, &pg);
+}
+
+int
+Ndb::poll_trans(int aMillisecondNumber, int minNoOfEventsToWakeup,
+ PollGuard *pg)
+{
NdbTransaction* tConArray[1024];
Uint32 tNoCompletedTransactions;
-
- //theCurrentConnectCounter = 0;
- //theCurrentConnectIndex++;
- TransporterFacade::instance()->lock_mutex();
- sendPrepTrans(forceSend);
if ((minNoOfEventsToWakeup <= 0) ||
((Uint32)minNoOfEventsToWakeup > theNoOfSentTransactions)) {
minNoOfEventsToWakeup = theNoOfSentTransactions;
}//if
if ((theNoOfCompletedTransactions < (Uint32)minNoOfEventsToWakeup) &&
(aMillisecondNumber > 0)) {
- waitCompletedTransactions(aMillisecondNumber, minNoOfEventsToWakeup);
+ waitCompletedTransactions(aMillisecondNumber, minNoOfEventsToWakeup, pg);
tNoCompletedTransactions = pollCompleted(tConArray);
} else {
tNoCompletedTransactions = pollCompleted(tConArray);
}//if
- TransporterFacade::instance()->unlock_mutex();
+ pg->unlock_and_signal();
reportCallback(tConArray, tNoCompletedTransactions);
return tNoCompletedTransactions;
-}//Ndb::sendPollNdb()
+}
/*****************************************************************************
int pollNdb(int aMillisecondNumber, int minNoOfEventsToWakeup);
@@ -1238,27 +1288,16 @@
int
Ndb::pollNdb(int aMillisecondNumber, int minNoOfEventsToWakeup)
{
- NdbTransaction* tConArray[1024];
- Uint32 tNoCompletedTransactions;
-
- //theCurrentConnectCounter = 0;
- //theCurrentConnectIndex++;
- TransporterFacade::instance()->lock_mutex();
- if ((minNoOfEventsToWakeup == 0) ||
- ((Uint32)minNoOfEventsToWakeup > theNoOfSentTransactions)) {
- minNoOfEventsToWakeup = theNoOfSentTransactions;
- }//if
- if ((theNoOfCompletedTransactions < (Uint32)minNoOfEventsToWakeup) &&
- (aMillisecondNumber > 0)) {
- waitCompletedTransactions(aMillisecondNumber, minNoOfEventsToWakeup);
- tNoCompletedTransactions = pollCompleted(tConArray);
- } else {
- tNoCompletedTransactions = pollCompleted(tConArray);
- }//if
- TransporterFacade::instance()->unlock_mutex();
- reportCallback(tConArray, tNoCompletedTransactions);
- return tNoCompletedTransactions;
-}//Ndb::sendPollNdbWithoutWait()
+ /*
+ The PollGuard has an implicit call of unlock_and_signal through the
+ ~PollGuard method. This method is called implicitly by the compiler
+ in all places where the object is out of context due to a return,
+ break, continue or simply end of statement block
+ */
+ PollGuard pg(TransporterFacade::instance(), &theImpl->theWaiter,
+ theNdbBlockNumber);
+ return poll_trans(aMillisecondNumber, minNoOfEventsToWakeup, &pg);
+}
/*****************************************************************************
int receiveOptimisedResponse();
@@ -1272,7 +1311,7 @@
Ndb::receiveResponse(int waitTime){
int tResultCode;
TransporterFacade::instance()->checkForceSend(theNdbBlockNumber);
-
+
theImpl->theWaiter.wait(waitTime);
if(theImpl->theWaiter.m_state == NO_WAIT) {
@@ -1298,7 +1337,8 @@
Ndb::sendRecSignal(Uint16 node_id,
Uint32 aWaitState,
NdbApiSignal* aSignal,
- Uint32 conn_seq)
+ Uint32 conn_seq,
+ Uint32 *ret_conn_seq)
{
/*
In most situations 0 is returned.
@@ -1311,19 +1351,28 @@
*/
int return_code;
+ Uint32 read_conn_seq;
TransporterFacade* tp = TransporterFacade::instance();
- Uint32 send_size = 1; // Always sends one signal only
- tp->lock_mutex();
+ Uint32 send_size = 1; // Always sends one signal only
// Protected area
+ /*
+ The PollGuard has an implicit call of unlock_and_signal through the
+ ~PollGuard method. This method is called implicitly by the compiler
+ in all places where the object is out of context due to a return,
+ break, continue or simply end of statement block
+ */
+ PollGuard poll_guard(tp,&theImpl->theWaiter,theNdbBlockNumber);
+ read_conn_seq= tp->getNodeSequence(node_id);
+ if (ret_conn_seq)
+ *ret_conn_seq= read_conn_seq;
if ((tp->get_node_alive(node_id)) &&
- ((tp->getNodeSequence(node_id) == conn_seq) ||
+ ((read_conn_seq == conn_seq) ||
(conn_seq == 0))) {
if (tp->check_send_size(node_id, send_size)) {
return_code = tp->sendSignal(aSignal, node_id);
if (return_code != -1) {
- theImpl->theWaiter.m_node = node_id;
- theImpl->theWaiter.m_state = aWaitState;
- return_code = receiveResponse();
+ return poll_guard.wait_n_unlock(WAITFOR_RESPONSE_TIMEOUT,node_id,
+ aWaitState, false);
} else {
return_code = -3;
}
@@ -1332,16 +1381,15 @@
}//if
} else {
if ((tp->get_node_stopping(node_id)) &&
- ((tp->getNodeSequence(node_id) == conn_seq) ||
+ ((read_conn_seq == conn_seq) ||
(conn_seq == 0))) {
return_code = -5;
} else {
return_code = -2;
}//if
}//if
- tp->unlock_mutex();
- // End of protected area
return return_code;
+ // End of protected area
}//Ndb::sendRecSignal()
void
--- 1.37/ndb/src/ndbapi/TransporterFacade.cpp Tue Mar 22 15:24:35 2005
+++ 1.38/ndb/src/ndbapi/TransporterFacade.cpp Tue Mar 22 15:38:36 2005
@@ -596,8 +596,7 @@
}
}
-TransporterFacade::TransporterFacade(NdbMgmHandle mgm_handle) :
- m_mgm_handle(mgm_handle),
+TransporterFacade::TransporterFacade() :
theTransporterRegistry(0),
theStopReceive(0),
theSendThread(NULL),
@@ -628,7 +627,7 @@
TransporterFacade::init(Uint32 nodeId, const ndb_mgm_configuration* props)
{
theOwnId = nodeId;
- theTransporterRegistry = new TransporterRegistry(m_mgm_handle,this);
+ theTransporterRegistry = new TransporterRegistry(this);
const int res = IPCConfig::configureTransporters(nodeId,
* props,
--- 1.26/ndb/src/ndbapi/TransporterFacade.hpp Tue Mar 22 15:24:35 2005
+++ 1.27/ndb/src/ndbapi/TransporterFacade.hpp Tue Mar 22 15:48:22 2005
@@ -53,8 +53,7 @@
* (Ndb objects should not be shared by different threads.)
*/
STATIC_CONST( MAX_NO_THREADS = 4711 );
-
- TransporterFacade(NdbMgmHandle mgm_handle);
+ TransporterFacade();
virtual ~TransporterFacade();
bool init(Uint32, const ndb_mgm_configuration *);
@@ -174,7 +173,6 @@
bool isConnected(NodeId aNodeId);
void doStop();
- NdbMgmHandle m_mgm_handle;
TransporterRegistry* theTransporterRegistry;
SocketServer m_socket_server;
int sendPerformedLastInterval;
| Thread |
|---|
| • bk commit into 5.0 tree (mronstrom:1.1844) | mikael | 22 Mar |