Ndblist.cpp 24.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/* Copyright (C) 2003 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#include <NdbOut.hpp>
unknown's avatar
unknown committed
18 19 20 21 22
#include <Ndb.hpp>
#include <NdbOperation.hpp>
#include <NdbIndexOperation.hpp>
#include <NdbIndexScanOperation.hpp>
#include <NdbConnection.hpp>
23
#include "NdbApiSignal.hpp"
unknown's avatar
unknown committed
24
#include <NdbRecAttr.hpp>
25 26
#include "NdbUtil.hpp"
#include "API.hpp"
unknown's avatar
unknown committed
27
#include "NdbBlob.hpp"
28 29 30 31

void
Ndb::checkFailedNode()
{
unknown's avatar
unknown committed
32
  DBUG_ENTER("Ndb::checkFailedNode");
unknown's avatar
unknown committed
33
  DBUG_PRINT("enter", ("theNoOfDBnodes: %d", theNoOfDBnodes));
unknown's avatar
unknown committed
34 35 36

  DBUG_ASSERT(theNoOfDBnodes < MAX_NDB_NODES);
  for (int i = 0; i < theNoOfDBnodes; i++){
37
    const NodeId node_id = theDBnodes[i];
unknown's avatar
unknown committed
38
    DBUG_PRINT("info", ("i: %d, node_id: %d", i, node_id));
39
    
unknown's avatar
unknown committed
40
    DBUG_ASSERT(node_id < MAX_NDB_NODES);    
41 42 43 44 45
    if (the_release_ind[node_id] == 1){

      /**
       * Release all connections in idle list (for node)
       */
unknown's avatar
unknown committed
46
      NdbConnection * tNdbCon = theConnectionArray[node_id];
47 48 49 50 51
      theConnectionArray[node_id] = NULL;
      while (tNdbCon != NULL) {
        NdbConnection* tempNdbCon = tNdbCon;
        tNdbCon = tNdbCon->next();
        releaseNdbCon(tempNdbCon);
unknown's avatar
unknown committed
52
      }
53
      the_release_ind[node_id] = 0;
unknown's avatar
unknown committed
54 55 56
    }
  }
  DBUG_VOID_RETURN;
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
}

#if 0
void
NdbImpl::checkInvalidTable(NdbDictionaryImpl * dict){
  Uint32 sz = m_invalidTables.size();
  for(Int32 i = sz - 1; i >= 0; i--){
    NdbTableImpl * tab = m_invalidTables[i];
    m_invalidTables.erase(i);
    dict->tableDropped(* tab);
  }
}

void
NdbImpl::checkErrorCode(Uint32 i, NdbTableImpl * tab){
  switch(i){
  case 241:
  case 283:
  case 284:
  case 285:
  case 1225:
  case 1226:
    
  }
}
#endif

/***************************************************************************
 * int createConIdleList(int aNrOfCon);
 * 
 * Return Value:   Return the number of created connection object 
 *                 if createConIdleList was succesful
 *                 Return -1: In all other case.  
 * Parameters:     aNrOfCon : Number of connections offered to the application.
 * Remark:         Create connection idlelist with NdbConnection objects.
 ***************************************************************************/ 
int 
Ndb::createConIdleList(int aNrOfCon)
{
  for (int i = 0; i < aNrOfCon; i++)
  {
    NdbConnection* tNdbCon = new NdbConnection(this);
    if (tNdbCon == NULL)
    {
      return -1;
    }
    if (theConIdleList == NULL)
    {
      theConIdleList = tNdbCon;
      theConIdleList->next(NULL);
    } else
    {
      tNdbCon->next(theConIdleList);
      theConIdleList = tNdbCon;
    }
112
    tNdbCon->Status(NdbConnection::NotConnected);
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
  }
  theNoOfAllocatedTransactions = aNrOfCon;
  return aNrOfCon; 
}

/***************************************************************************
 * int createOpIdleList(int aNrOfOp);
 *
 * Return Value:   Return the number of created operation object if 
 *                 createOpIdleList was succesful.
 *                 Return -1: In all other case.
 * Parameters:     aNrOfOp:  Number of operations offered to the application. 
 * Remark:         Create  operation idlelist with NdbOperation objects..
 ***************************************************************************/ 
int 
Ndb::createOpIdleList(int aNrOfOp)
{ 
  for (int i = 0; i < aNrOfOp; i++){
    NdbOperation* tOp = new NdbOperation(this);
    if ( tOp == NULL ){
      return -1;
    }
    if (theOpIdleList == NULL){
      theOpIdleList = tOp;
      theOpIdleList->next(NULL);
    } else{
      tOp->next(theOpIdleList);
      theOpIdleList = tOp;
    }
  }
  return aNrOfOp; 
}

/***************************************************************************
 * NdbBranch* NdbBranch();
 *
 * Return Value:   Return a NdbBranch if the  getNdbBranch was successful.
 *                Return NULL : In all other case.  
 * Remark:         Get a NdbBranch from theBranchList and return the object .
 ***************************************************************************/ 
NdbBranch*
Ndb::getNdbBranch()
{
  NdbBranch*    tNdbBranch;
  if ( theBranchList == NULL )
  {
    tNdbBranch = new NdbBranch;
    if (tNdbBranch == NULL)
    {
      return NULL;
    }
    tNdbBranch->theNext = NULL;
  } else
  {
    tNdbBranch = theBranchList;
    theBranchList = tNdbBranch->theNext;
    tNdbBranch->theNext = NULL;
  }
  return tNdbBranch;
}

/***************************************************************************
 * NdbCall* NdbCall();
 *
 * Return Value:   Return a NdbCall if the  getNdbCall was successful.
 *                Return NULL : In all other case.  
 * Remark:         Get a NdbCall from theCallList and return the object .
 ***************************************************************************/ 
NdbCall*
Ndb::getNdbCall()
{
  NdbCall*      tNdbCall;
  if ( theCallList == NULL )
  {
    tNdbCall = new NdbCall;
    if (tNdbCall == NULL)
    {
      return NULL;
    }
    tNdbCall->theNext = NULL;
  } else
  {
    tNdbCall = theCallList;
    theCallList = tNdbCall->theNext;
    tNdbCall->theNext = NULL;
  }
  return tNdbCall;
}

/***************************************************************************
 * NdbConnection* getNdbCon();
 *
 * Return Value:   Return a connection if the  getNdbCon was successful.
 *                Return NULL : In all other case.  
 * Remark:         Get a connection from theConIdleList and return the object .
 ***************************************************************************/ 
NdbConnection*
Ndb::getNdbCon()
{
  NdbConnection*        tNdbCon;
  if ( theConIdleList == NULL ) {
    if (theNoOfAllocatedTransactions < theMaxNoOfTransactions) {
      tNdbCon = new NdbConnection(this);
      if (tNdbCon == NULL) {
        return NULL;
      }//if
      theNoOfAllocatedTransactions++;
    } else {
      ndbout << "theNoOfAllocatedTransactions = " << theNoOfAllocatedTransactions << " theMaxNoOfTransactions = " << theMaxNoOfTransactions << endl;
      return NULL;
    }//if
    tNdbCon->next(NULL);
  } else
  {
    tNdbCon = theConIdleList;
    theConIdleList = tNdbCon->next();
    tNdbCon->next(NULL);
  }
  tNdbCon->theMagicNumber = 0x37412619;
  return tNdbCon;
}

/***************************************************************************
 * NdbLabel* getNdbLabel();
 *
 * Return Value:   Return a NdbLabel if the  getNdbLabel was successful.
 *                 Return NULL : In all other case.  
 * Remark:         Get a NdbLabel from theLabelList and return the object .
 ***************************************************************************/ 
NdbLabel*
Ndb::getNdbLabel()
{
  NdbLabel*     tNdbLabel;
  if ( theLabelList == NULL )
  {
    tNdbLabel = new NdbLabel;
    if (tNdbLabel == NULL)
    {
      return NULL;
    }
    tNdbLabel->theNext = NULL;
  } else
  {
    tNdbLabel = theLabelList;
    theLabelList = tNdbLabel->theNext;
    tNdbLabel->theNext = NULL;
  }
  return tNdbLabel;
}

/***************************************************************************
 * NdbScanReceiver* getNdbScanRec()
 * 
 * Return Value:  Return a NdbScanReceiver
 *                Return NULL : In all other case.  
 * Remark:        Get a NdbScanReceiver from theScanRecList and return the 
 *                object .
 ****************************************************************************/ 
unknown's avatar
unknown committed
271
NdbReceiver*
272 273
Ndb::getNdbScanRec()
{
unknown's avatar
unknown committed
274
  NdbReceiver*      tNdbScanRec;
275 276
  if ( theScanList == NULL )
  {
unknown's avatar
unknown committed
277
    tNdbScanRec = new NdbReceiver(this);
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
    if (tNdbScanRec == NULL)
    {
      return NULL;
    }
    tNdbScanRec->next(NULL);
  } else
  {
    tNdbScanRec = theScanList;
    theScanList = tNdbScanRec->next();
    tNdbScanRec->next(NULL);
  }

  return tNdbScanRec;
}

/***************************************************************************
 * NdbSubroutine* getNdbSubroutine();
 *
 * Return Value: Return a NdbSubroutine if the  getNdbSubroutine was successful.
 *                Return NULL : In all other case.  
 * Remark:    Get a NdbSubroutine from theSubroutineList and return the object .
 ***************************************************************************/ 
NdbSubroutine*
Ndb::getNdbSubroutine()
{
  NdbSubroutine*        tNdbSubroutine;
  if ( theSubroutineList == NULL )
  {
    tNdbSubroutine = new NdbSubroutine;
    if (tNdbSubroutine == NULL)
    {
      return NULL;
    }
    tNdbSubroutine->theNext = NULL;
  } else
  {
    tNdbSubroutine = theSubroutineList;
    theSubroutineList = tNdbSubroutine->theNext;
    tNdbSubroutine->theNext = NULL;
  }
  return tNdbSubroutine;
}

/***************************************************************************
NdbOperation* getOperation();

Return Value:   Return theOpList : if the  getOperation was succesful.
                Return NULL : In all other case.  
Remark:         Get an operation from theOpIdleList and return the object .
***************************************************************************/ 
NdbOperation*
Ndb::getOperation()
{
  NdbOperation* tOp = theOpIdleList;
  if (tOp != NULL ) {
    NdbOperation* tOpNext = tOp->next();
    tOp->next(NULL);
    theOpIdleList = tOpNext;
    return tOp;
  } else {
    tOp = new NdbOperation(this);
    if (tOp != NULL)
      tOp->next(NULL);
  }
  return tOp;
}

/***************************************************************************
NdbScanOperation* getScanOperation();

Return Value:   Return theOpList : if the  getScanOperation was succesful.
                Return NULL : In all other case.  
Remark:         Get an operation from theScanOpIdleList and return the object .
***************************************************************************/ 
unknown's avatar
unknown committed
352
NdbIndexScanOperation*
353 354
Ndb::getScanOperation()
{
unknown's avatar
unknown committed
355
  NdbIndexScanOperation* tOp = theScanOpIdleList;
356
  if (tOp != NULL ) {
unknown's avatar
unknown committed
357
    NdbIndexScanOperation* tOpNext = (NdbIndexScanOperation*)tOp->next();
358 359 360 361
    tOp->next(NULL);
    theScanOpIdleList = tOpNext;
    return tOp;
  } else {
unknown's avatar
unknown committed
362
    tOp = new NdbIndexScanOperation(this);
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
    if (tOp != NULL)
      tOp->next(NULL);
  }
  return tOp;
}

/***************************************************************************
NdbIndexOperation* getIndexOperation();

Return Value:   Return theOpList : if the  getIndexOperation was succesful.
                Return NULL : In all other case.  
Remark:         Get an operation from theIndexOpIdleList and return the object .
***************************************************************************/ 
NdbIndexOperation*
Ndb::getIndexOperation()
{
  NdbIndexOperation* tOp = theIndexOpIdleList;
  if (tOp != NULL ) {
    NdbIndexOperation* tOpNext = (NdbIndexOperation*) tOp->next();
    tOp->next(NULL);
    theIndexOpIdleList = tOpNext;
    return tOp;
  } else {
    tOp = new NdbIndexOperation(this);
    if (tOp != NULL)
      tOp->next(NULL);
  }
  return tOp;
}

/***************************************************************************
NdbRecAttr* getRecAttr();

Return Value:   Return a reference to a receive attribute object.
                Return NULL if it's not possible to get a receive attribute object.
***************************************************************************/
NdbRecAttr*
Ndb::getRecAttr()
{
  NdbRecAttr* tRecAttr;
  tRecAttr = theRecAttrIdleList;
  if (tRecAttr != NULL) {
    NdbRecAttr* tRecAttrNext = tRecAttr->next();
    tRecAttr->init();
    theRecAttrIdleList = tRecAttrNext;
    return tRecAttr;
  } else {
    tRecAttr = new NdbRecAttr;
    if (tRecAttr == NULL)
      return NULL;
    tRecAttr->next(NULL);
  }//if
  tRecAttr->init();
  return tRecAttr;
}

/***************************************************************************
NdbApiSignal* getSignal();

Return Value:   Return a reference to a signal object.
                Return NULL if not possible to get a signal object.
***************************************************************************/
NdbApiSignal*
Ndb::getSignal()
{
  NdbApiSignal* tSignal = theSignalIdleList;
  if (tSignal != NULL){
    NdbApiSignal* tSignalNext = tSignal->next();
    tSignal->next(NULL);
    theSignalIdleList = tSignalNext;
  } else {
    tSignal = new NdbApiSignal(theMyRef);
    cnewSignals++;
    if (tSignal != NULL)
      tSignal->next(NULL);
  }
  cgetSignals++;
  return tSignal;
}

unknown's avatar
unknown committed
443 444 445 446 447 448 449 450 451 452 453 454 455
NdbBlob*
Ndb::getNdbBlob()
{
  NdbBlob* tBlob = theNdbBlobIdleList;
  if (tBlob != NULL) {
    theNdbBlobIdleList = tBlob->theNext;
    tBlob->init();
  } else {
    tBlob = new NdbBlob;
  }
  return tBlob;
}

456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
/***************************************************************************
void releaseNdbBranch(NdbBranch* aNdbBranch);

Parameters:     NdbBranch: The NdbBranch object.
Remark:         Add a NdbBranch object into the Branch idlelist.
***************************************************************************/
void
Ndb::releaseNdbBranch(NdbBranch* aNdbBranch)
{
  aNdbBranch->theNext = theBranchList;
  theBranchList = aNdbBranch;
}

/***************************************************************************
void releaseNdbCall(NdbCall* aNdbCall);

Parameters:     NdbBranch: The NdbBranch object.
Remark:         Add a NdbBranch object into the Branch idlelist.
***************************************************************************/
void
Ndb::releaseNdbCall(NdbCall* aNdbCall)
{
  aNdbCall->theNext = theCallList;
  theCallList = aNdbCall;
}

/***************************************************************************
void releaseNdbCon(NdbConnection* aNdbCon);

Parameters:     aNdbCon: The NdbConnection object.
Remark:         Add a Connection object into the signal idlelist.
***************************************************************************/
void
Ndb::releaseNdbCon(NdbConnection* aNdbCon)
{
  aNdbCon->next(theConIdleList);
  aNdbCon->theMagicNumber = 0xFE11DD;
  theConIdleList = aNdbCon;
}

/***************************************************************************
void releaseNdbLabel(NdbLabel* aNdbLabel);

Parameters:     NdbLabel: The NdbLabel object.
Remark:         Add a NdbLabel object into the Label idlelist.
***************************************************************************/
void
Ndb::releaseNdbLabel(NdbLabel* aNdbLabel)
{
  aNdbLabel->theNext = theLabelList;
  theLabelList = aNdbLabel;
}

/***************************************************************************
void releaseNdbScanRec(NdbScanReceiver* aNdbScanRec);

Parameters:     aNdbScanRec: The NdbScanReceiver object.
Remark:         Add a NdbScanReceiver object into the Scan idlelist.
***************************************************************************/
void
unknown's avatar
unknown committed
516
Ndb::releaseNdbScanRec(NdbReceiver* aNdbScanRec)
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
{
  aNdbScanRec->next(theScanList);
  theScanList = aNdbScanRec;
}

/***************************************************************************
void releaseNdbSubroutine(NdbSubroutine* aNdbSubroutine);

Parameters:     NdbSubroutine: The NdbSubroutine object.
Remark:         Add a NdbSubroutine object into theSubroutine idlelist.
***************************************************************************/
void
Ndb::releaseNdbSubroutine(NdbSubroutine* aNdbSubroutine)
{
  aNdbSubroutine->theNext = theSubroutineList;
  theSubroutineList = aNdbSubroutine;
}

/***************************************************************************
void releaseOperation(NdbOperation* anOperation);

Parameters:     anOperation : The released NdbOperation object.
Remark:         Add a NdbOperation object into the signal idlelist.
***************************************************************************/
void
Ndb::releaseOperation(NdbOperation* anOperation)
{
  if(anOperation->m_tcReqGSN == GSN_TCKEYREQ){
    anOperation->next(theOpIdleList);
    anOperation->theNdbCon = NULL;
    anOperation->theMagicNumber = 0xFE11D0;
    theOpIdleList = anOperation;
  } else {
    assert(anOperation->m_tcReqGSN == GSN_TCINDXREQ);
    anOperation->next(theIndexOpIdleList);
    anOperation->theNdbCon = NULL;
    anOperation->theMagicNumber = 0xFE11D1;
    theIndexOpIdleList = (NdbIndexOperation*)anOperation;
  }
}

/***************************************************************************
void releaseScanOperation(NdbScanOperation* aScanOperation);

Parameters:     aScanOperation : The released NdbScanOperation object.
Remark:         Add a NdbScanOperation object into the signal idlelist.
***************************************************************************/
void
unknown's avatar
unknown committed
565
Ndb::releaseScanOperation(NdbIndexScanOperation* aScanOperation)
566 567 568 569
{
  aScanOperation->next(theScanOpIdleList);
  aScanOperation->theNdbCon = NULL;
  aScanOperation->theMagicNumber = 0xFE11D2;
unknown's avatar
unknown committed
570
  theScanOpIdleList = aScanOperation;
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
}

/***************************************************************************
void releaseRecAttr(NdbRecAttr* aRecAttr);

Parameters:     aRecAttr : The released NdbRecAttr object.
Remark:         Add a NdbRecAttr object into the RecAtt idlelist.
***************************************************************************/
void
Ndb::releaseRecAttr(NdbRecAttr* aRecAttr)
{
  aRecAttr->release();
  aRecAttr->next(theRecAttrIdleList);
  theRecAttrIdleList = aRecAttr;
}

/***************************************************************************
void releaseSignal(NdbApiSignal* aSignal);

Parameters:     aSignal : The released NdbApiSignal object.
Remark:         Add a NdbApiSignal object into the signal idlelist.
***************************************************************************/
void
Ndb::releaseSignal(NdbApiSignal* aSignal)
{
#if defined VM_TRACE
  // Check that signal is not null
  assert(aSignal != NULL);
599
#if 0
600 601 602 603 604 605
  // Check that signal is not already in list
  NdbApiSignal* tmp = theSignalIdleList;
  while (tmp != NULL){
    assert(tmp != aSignal);
    tmp = tmp->next();
  }
606
#endif
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
#endif
  creleaseSignals++;
  aSignal->next(theSignalIdleList);
  theSignalIdleList = aSignal;
}

void
Ndb::releaseSignalsInList(NdbApiSignal** pList){
  NdbApiSignal* tmp;
  while (*pList != NULL){
    tmp = *pList;
    *pList = (*pList)->next();
    releaseSignal(tmp);
  }
}

unknown's avatar
unknown committed
623 624 625 626 627 628 629 630
void
Ndb::releaseNdbBlob(NdbBlob* aBlob)
{
  aBlob->release();
  aBlob->theNext = theNdbBlobIdleList;
  theNdbBlobIdleList = aBlob;
}

631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652
/***************************************************************************
void freeOperation();

Remark:         Always release the first item in the free list
***************************************************************************/
void
Ndb::freeOperation()
{
  NdbOperation* tOp = theOpIdleList;
  theOpIdleList = theOpIdleList->next();
  delete tOp;
}

/***************************************************************************
void freeScanOperation();

Remark:         Always release the first item in the free list
***************************************************************************/
void
Ndb::freeScanOperation()
{
  NdbScanOperation* tOp = theScanOpIdleList;
unknown's avatar
unknown committed
653
  theScanOpIdleList = (NdbIndexScanOperation *) theScanOpIdleList->next();
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703
  delete tOp;
}

/***************************************************************************
void freeIndexOperation();

Remark:         Always release the first item in the free list
***************************************************************************/
void
Ndb::freeIndexOperation()
{
  NdbIndexOperation* tOp = theIndexOpIdleList;
  theIndexOpIdleList = (NdbIndexOperation *) theIndexOpIdleList->next();
  delete tOp;
}

/***************************************************************************
void freeNdbBranch();

Remark:         Always release the first item in the free list
***************************************************************************/
void
Ndb::freeNdbBranch()
{
  NdbBranch* tNdbBranch = theBranchList;
  theBranchList = theBranchList->theNext;
  delete tNdbBranch;
}

/***************************************************************************
void freeNdbCall();

Remark:         Always release the first item in the free list
***************************************************************************/
void
Ndb::freeNdbCall()
{
  NdbCall* tNdbCall = theCallList;
  theCallList = theCallList->theNext;
  delete tNdbCall;
}

/***************************************************************************
void freeNdbScanRec();

Remark:         Always release the first item in the free list
***************************************************************************/
void
Ndb::freeNdbScanRec()
{
unknown's avatar
unknown committed
704
  NdbReceiver* tNdbScanRec = theScanList;
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774
  theScanList = theScanList->next();
  delete tNdbScanRec;
}

/***************************************************************************
void freeNdbCon();

Remark:         Always release the first item in the free list
***************************************************************************/
void
Ndb::freeNdbCon()
{
  NdbConnection* tNdbCon = theConIdleList;
  theConIdleList = theConIdleList->next();
  delete tNdbCon;
}

/***************************************************************************
void freeNdbLabel();

Remark:         Always release the first item in the free list
***************************************************************************/
void
Ndb::freeNdbLabel()
{
  NdbLabel* tNdbLabel = theLabelList;
  theLabelList = theLabelList->theNext;
  delete tNdbLabel;
}

/***************************************************************************
void freeNdbSubroutine();

Remark:         Always release the first item in the free list
***************************************************************************/
void
Ndb::freeNdbSubroutine()
{
  NdbSubroutine* tNdbSubroutine = theSubroutineList;
  theSubroutineList = theSubroutineList->theNext;
  delete tNdbSubroutine;
}

/***************************************************************************
void freeRecAttr();

Remark:         Always release the first item in the free list
***************************************************************************/
void
Ndb::freeRecAttr()
{
  NdbRecAttr* tRecAttr = theRecAttrIdleList;
  theRecAttrIdleList = theRecAttrIdleList->next();
  delete tRecAttr;
}

/***************************************************************************
void freeSignal();

Remark:         Delete  a signal object from the signal idlelist.
***************************************************************************/
void
Ndb::freeSignal()
{
  NdbApiSignal* tSignal = theSignalIdleList;
  theSignalIdleList = tSignal->next();
  delete tSignal;
  cfreeSignals++;
}

unknown's avatar
unknown committed
775 776 777 778 779 780 781 782
void
Ndb::freeNdbBlob()
{
  NdbBlob* tBlob = theNdbBlobIdleList;
  theNdbBlobIdleList = tBlob->theNext;
  delete tBlob;
}

783 784 785 786 787 788 789 790 791 792
/****************************************************************************
int releaseConnectToNdb(NdbConnection* aConnectConnection);

Return Value:   -1 if error 
Parameters:     aConnectConnection : Seized schema connection to DBTC
Remark:         Release and disconnect from DBTC a connection and seize it to theConIdleList.
*****************************************************************************/
void
Ndb::releaseConnectToNdb(NdbConnection* a_con)     
{
793
  DBUG_ENTER("Ndb::releaseConnectToNdb");
794 795 796 797 798 799 800
  NdbApiSignal          tSignal(theMyRef);
  int                   tConPtr;

// I need to close the connection irrespective of whether I
// manage to reach NDB or not.

  if (a_con == NULL)
801
    DBUG_VOID_RETURN;
802 803 804 805 806 807 808

  Uint32 node_id = a_con->getConnectedNodeId();
  Uint32 conn_seq = a_con->theNodeSequence;
  tSignal.setSignal(GSN_TCRELEASEREQ);
  tSignal.setData((tConPtr = a_con->getTC_ConnectPtr()), 1);
  tSignal.setData(theMyRef, 2);
  tSignal.setData(a_con->ptr2int(), 3); 
809
  a_con->Status(NdbConnection::DisConnecting);
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831
  a_con->theMagicNumber = 0x37412619;
  int ret_code = sendRecSignal(node_id,
                               WAIT_TC_RELEASE,
                               &tSignal,
                               conn_seq);
  if (ret_code == 0) {
    ;
  } else if (ret_code == -1) {
    TRACE_DEBUG("Time-out when TCRELEASE sent");
  } else if (ret_code == -2) {
    TRACE_DEBUG("Node failed when TCRELEASE sent");
  } else if (ret_code == -3) {
    TRACE_DEBUG("Send failed when TCRELEASE sent");
  } else if (ret_code == -4) {
    TRACE_DEBUG("Send buffer full when TCRELEASE sent");
  } else if (ret_code == -5) {
    TRACE_DEBUG("Node stopping when TCRELEASE sent");
  } else {
    ndbout << "Impossible return from sendRecSignal when TCRELEASE" << endl;
    abort();
  }//if
  releaseNdbCon(a_con);
832
  DBUG_VOID_RETURN;
833 834
}