コード例 #1
0
void
UdrGuaControlConnection::actOnSystemMessage(
  short                  messageNum,
  IpcMessageBufferPtr    sysMsg,
  IpcMessageObjSize      sysMsgLen,
  short                  clientFileNumber,
  const GuaProcessHandle &clientPhandle,
  GuaConnectionToClient  *connection)
{
  const char * moduleName = "UdrGuaControlConnection::actOnSystemMessage";

  switch (messageNum)
  {
    case ZSYS_VAL_SMSG_OPEN:
      {
        if (udrGlob_->verbose_ &&
            udrGlob_->traceLevel_ >= TRACE_IPMS &&
            udrGlob_->showMain_)
        {
          ServerDebug(
           "[UdrServ (%s)] A new connection %p is opened to the Server.",
           moduleName,
           connection);
        }

        // Create a new message stream. Link the connection.
        // Then call receive on it to bring it into receiving mode.
        UdrServerControlStream *newControlStream =
          new (udrGlob_->getIpcHeap())
            UdrServerControlStream(udrGlob_->getIpcEnvironment(),
                                   udrGlob_,
                                   UDR_STREAM_SERVER_CONTROL,
                                   UdrServerControlStreamVersionNumber);
        newControlStream->addRecipient(connection);
        newControlStream->receive(FALSE);
      }
      break;

    default:
      // do nothing for all other kinds of system messages
      break;
  } // switch

  // The parent class already handles the job of closing all connections
  // who lost their client process by failed processes, failed CPUs and
  // failed systems or networks. Check here that we die if all our
  // requestors go away, but don't die if the first system message is
  // something other than an OPEN message.
  if (getNumRequestors() == 0 AND initialized_)
  {
    NAExit(0);
  }
  else if (NOT initialized_ AND getNumRequestors() > 0)
  {
    // the first requestor came in
    initialized_ = TRUE;
  }

} // UdrGuaControlConnection::actOnSystemMessage()
コード例 #2
0
void EspGuaControlConnection::actOnSystemMessage(
       short                  messageNum,
       IpcMessageBufferPtr    sysMsg,
       IpcMessageObjSize      sysMsgLen,
       short                  clientFileNumber,
       const GuaProcessHandle &clientPhandle,
       GuaConnectionToClient  *connection)
{
  switch (messageNum)
    {
    case ZSYS_VAL_SMSG_OPEN:
      if (initialized_)
	{
	  // This an OPEN message for a connection that isn't the
	  // initial control connection. Create a new message stream and
	  // attach it to the newly created connection.
	  EspNewIncomingConnectionStream *newStream = new(getEnv()->getHeap())
	    EspNewIncomingConnectionStream(getEnv(),espFragInstanceDir_);

	  ex_assert(connection != NULL,
                    "Must create connection for open sys msg");
	  newStream->addRecipient(connection);
          newStream->receive(FALSE);

	  // now abandon the new object, it will find its way to the right
	  // send bottom TCB on its own
	  // (a memory leak would result if the client would open our $RECEIVE
	  // w/o sending corresponding ESP level open requests)
	}
      break;

    case ZSYS_VAL_SMSG_CPUDOWN:
    case ZSYS_VAL_SMSG_REMOTECPUDOWN:
    case ZSYS_VAL_SMSG_CLOSE:
    case ZSYS_VAL_SMSG_NODEDOWN:
      // Somebody closed us or went down. Was it master executor?
      // Note that GuaReceiveControlConnection::getConnection returns
      // the master executor connection.
      if (getConnection() == connection)
      {
        // Master is gone, stop this process and let the OS cleanup.
        if (getEnv()->getLogEspGotCloseMsg())
        {
          /*
          Coverage notes: to test this code in a dev regression requires
          changing $TRAF_VAR/ms.env, so I made a manual test on
          May 11, 2012 to verify this code.
          */
          char myName[20];
          memset(myName, '\0', sizeof(myName));
          getEnv()->getMyOwnProcessId(IPC_DOM_GUA_PHANDLE).toAscii(
                                                    myName, sizeof(myName));
          char buf[500];
          char *sysMsgName = NULL;
          switch (messageNum)
          {
          case ZSYS_VAL_SMSG_CPUDOWN:
            sysMsgName = (char *) "CPUDOWN";
            break;
          case ZSYS_VAL_SMSG_REMOTECPUDOWN:
            sysMsgName = (char *) "REMOTECPUDOWN";
            break;
          case ZSYS_VAL_SMSG_CLOSE:
            sysMsgName = (char *) "CLOSE";
            break;
          case ZSYS_VAL_SMSG_NODEDOWN:
            sysMsgName = (char *) "NODEDOWN";
            break;
          }
          str_sprintf(buf, 
                      "System %s message causes %s to exit.",
                            sysMsgName, myName);
          SQLMXLoggingArea::logExecRtInfo(__FILE__, 
                                          __LINE__, buf, 0);
        }
        getEnv()->stopIpcEnvironment();
      }
      // Otherwise, do a search thru all
      // downloaded fragment entries and check whether their
      // client is still using them. The IPC layer will wake
      // up the scheduler so the actual release can take place.
      espFragInstanceDir_->releaseOrphanEntries();
      break;

    default:
      // do nothing for all other kinds of system messages
      break;
    } // switch


  // The parent class already handles the job of closing all connections
  // who lost their client process by failed processes, failed CPUs and
  // failed systems or networks. Check here that we die if all our
  // requestors go away, but don't die if the first system message is
  // something other than an OPEN message.
  if (getNumRequestors() == 0 AND initialized_)
    {
      // ABORT("Lost connection to client");
      // losing the client is not a reason to panic, the client may
      // have voluntarily decided to exit without freeing its resources
      NAExit(0);
    }
  else if (NOT initialized_ AND getNumRequestors() > 0)
    {
      // the first requestor came in
      initialized_ = TRUE;
    }
}