void TaoClientTask::requestShutdown() { // Need to put a Mutex on the call stack // Pass the shut down to itself OsServerTask::requestShutdown(); yield(); if (mpConnectionSocket) { TaoMessage msg = TaoMessage(TaoMessage::REQUEST_PROVIDER, TaoMessage::SHUTDOWN, 0, 0, (TaoObjHandle)mpConnectionSocket, 0, ""); postMessage(msg); } if(mpTransport) { osPrintf("---- TaoClientTask::initInstance: stoping transport\n"); mpTransport->stopListening(); // shut down the transport task mpTransport->requestShutdown(); // shut down the transport task } }
int TaoTransportAgent::run(void* runArg) { UtlString remoteHostName; UtlString viaProtocol; UtlString fromIpAddress; while (mpSocket && mpSocket->isOk() && !isShuttingDown()) { char buffer[DEF_TAO_MAX_SOCKET_SIZE]; unsigned long bytesRead; unsigned long cookie ; unsigned long length ; memset(buffer, 0, (DEF_TAO_MAX_SOCKET_SIZE * sizeof(char))); // Look for our next message, it should start with a '1234ABCD' marker bytesRead = mpSocket->read((char*) &cookie, sizeof(unsigned long)) ; while ((bytesRead > 0) && (cookie != 0x1234ABCD)) { osPrintf("<<**>> Invalid data read from socket, trying to resynchronize...\n") ; bytesRead = readUntilDone(mpSocket, (char*) &cookie, sizeof(unsigned long)) ; } // Okay, now read length if (bytesRead > 0) { bytesRead = readUntilDone(mpSocket, (char*) &length, sizeof(unsigned long)) ; } // Finally read data if (bytesRead > 0) { bytesRead = readUntilDone(mpSocket, buffer, length) ; if (bytesRead != length) { osPrintf("<<**>> TaoTransportAgent READ MISMATCH %lu != %lu\n", bytesRead, length) ; bytesRead = 0 ; } } if(bytesRead > 0) { TaoMessage msg = TaoMessage(UtlString(buffer)); msg.setSocket((TaoObjHandle)this); //stores pointer to this class mpServer->postMessage(msg); } else if(bytesRead <= 0 || !mpSocket->isOk()) { // The socket has gone sour close down the client mpSocket->getRemoteHostName(&remoteHostName); osPrintf("Shutting down TaoTransportAgent: %s due to failed socket\n", remoteHostName.data()); break; } } #ifdef TEST_PRINT osPrintf("TaoTransportAgent: %s/%s exiting\r\n", remoteHostName.data(), viaName.data()); #endif return(0); }