Boolean SSLSocket::incompleteSecureReadOccurred(Sint32 retCode) { Sint32 err = SSL_get_error(static_cast<SSL*>(_SSLConnection), retCode); Boolean isIncompleteRead = ((err == SSL_ERROR_SYSCALL) && (_sslReadErrno == EAGAIN || _sslReadErrno == EINTR)) || (err == SSL_ERROR_WANT_READ) || (err == SSL_ERROR_WANT_WRITE); if (Tracer::isTraceOn()) { unsigned long rc = ERR_get_error (); char buff[256]; ERR_error_string_n (rc, buff, sizeof (buff)); // added in OpenSSL 0.9.6 PEG_TRACE((TRC_SSL, Tracer::LEVEL4, "In SSLSocket::incompleteSecureReadOccurred : err = %d %s", err, buff)); if (!isIncompleteRead && retCode < 0) { PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL4, "In SSLSocket::incompleteSecureReadOccurred : err = %d %s", err, buff)); } } return isIncompleteRead; }
ProviderModule* DefaultProviderManager::_lookupModule( const String& moduleFileName) { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::_lookupModule"); // lock the providerTable mutex AutoMutex lock(_providerTableMutex); // look up provider module in cache ProviderModule* module = 0; if (_modules.lookup(moduleFileName, module)) { // found provider module in cache PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Found Provider Module %s in Provider Manager Cache", (const char*)moduleFileName.getCString())); } else { // provider module not found in cache, create provider module PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Creating Provider Module %s", (const char*)moduleFileName.getCString())); module = new ProviderModule(moduleFileName); // insert provider module in module table _modules.insert(moduleFileName, module); } PEG_METHOD_EXIT(); return module; }
AutoFileLock::AutoFileLock(const char* fileName) { // Repeat createFile, if there is a sharing violation. do { _hFile = CreateFile (fileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); }while ((GetLastError() == ERROR_SHARING_VIOLATION)); // If this conditon succeeds, There is an error opening the file. Hence // returning from here as Lock can not be acquired. if((_hFile == INVALID_HANDLE_VALUE) && (GetLastError() != ERROR_ALREADY_EXISTS) && (GetLastError() != ERROR_SUCCESS)) { PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1, "AutoFileLock: Failed to open lock file '%s', error code %d.", fileName, GetLastError())); return; } OVERLAPPED l={0,0,0,0,0}; if(LockFileEx(_hFile,LOCKFILE_EXCLUSIVE_LOCK, 0, 0, 0, &l) == 0) { PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1, "AutoFileLock: Failed to Acquire lock on file %s, error code %d.", fileName, GetLastError())); CloseHandle(_hFile); _hFile = INVALID_HANDLE_VALUE; } }
void DefaultProviderManager::_unloadProvider(ProviderMessageHandler* provider) { // // NOTE: It is the caller's responsibility to make sure that the // provider->status.getStatusMutex() mutex is locked before calling // this method. // PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::_unloadProvider"); if (provider->status.numCurrentOperations() > 0) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Provider cannot be unloaded due to pending operations: %s", (const char*)provider->getName().getCString())); } else { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Terminating Provider %s", (const char*)provider->getName().getCString())); provider->terminate(); // unload provider module PEGASUS_ASSERT(provider->status.getModule() != 0); PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL3, "Unloading provider module: %s", (const char*)provider->getName().getCString())); provider->status.getModule()->unloadModule(); PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3, "DefaultProviderManager: Unloaded provider %s", (const char*)provider->getName().getCString())); // NOTE: The "delete provider->status.getCIMOMHandle()" operation // was moved to be called after the unloadModule() call above // as part of a fix for bugzilla 3669. For some providers // run out-of-process on Windows platforms (i.e. running // the cimserver with the forceProviderProcesses config option // set to "true"), deleting the provider's CIMOMHandle before // unloading the provider library caused the unload mechanism // to deadlock, making that provider unavailable and preventing // the cimserver from shutting down. It should NOT be moved back // above the unloadModule() call. See bugzilla 3669 for details. // delete the cimom handle PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Destroying provider's CIMOMHandle: %s", (const char*)provider->getName().getCString())); delete provider->status.getCIMOMHandle(); // set provider status to uninitialized provider->status.setInitialized(false); } PEG_METHOD_EXIT(); }
void DefaultProviderManager::unloadIdleProviders() { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::unloadIdleProviders"); try { struct timeval now; Time::gettimeofday(&now); // Make a copy of the table so it is not locked during provider calls Array<ProviderMessageHandler*> providerList; { AutoMutex lock(_providerTableMutex); for (ProviderTable::Iterator i = _providers.start(); i != 0; i++) { providerList.append(i.value()); } } for (Uint32 i = 0; i < providerList.size(); i++) { ProviderMessageHandler* provider = providerList[i]; AutoMutex lock(provider->status.getStatusMutex()); if (!provider->status.isInitialized()) { continue; } struct timeval providerTime = {0, 0}; provider->status.getLastOperationEndTime(&providerTime); PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, "provider->status.isIdle() returns: %s", (const char*)CIMValue(provider->status.isIdle()) .toString().getCString())); if (provider->status.isIdle() && ((now.tv_sec - providerTime.tv_sec) > ((Sint32)PEGASUS_PROVIDER_IDLE_TIMEOUT_SECONDS))) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL3, "Unloading idle provider: %s", (const char*)provider->getName().getCString())); _unloadProvider(provider); } } } catch (...) { PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL1, "Caught unexpected exception in unloadIdleProviders."); } PEG_METHOD_EXIT(); }
void CIMExportClient::exportIndication( const String& url, const CIMInstance& instanceName, const ContentLanguageList& contentLanguages) { PEG_METHOD_ENTER (TRC_EXPORT_CLIENT, "CIMExportClient::exportIndication()"); try { // encode request CIMRequestMessage* request = new CIMExportIndicationRequestMessage( String::EMPTY, url, instanceName, QueueIdStack(), String::EMPTY, String::EMPTY); request->operationContext.set (ContentLanguageListContainer(contentLanguages)); PEG_TRACE ((TRC_INDICATION_GENERATION, Tracer::LEVEL4, "Exporting %s Indication for destination %s:%d%s", (const char*)(instanceName.getClassName().getString(). getCString()), (const char*)(_connectHost.getCString()), _connectPortNumber, (const char*)(url.getCString()))); Message* message = _doRequest(request, CIM_EXPORT_INDICATION_RESPONSE_MESSAGE); PEG_TRACE ((TRC_INDICATION_GENERATION, Tracer::LEVEL4, "%s Indication for destination %s:%d%s exported successfully", (const char*)(instanceName.getClassName().getString(). getCString()), (const char*)(_connectHost.getCString()), _connectPortNumber, (const char*)(url.getCString()))); CIMExportIndicationResponseMessage* response = (CIMExportIndicationResponseMessage*)message; AutoPtr<CIMExportIndicationResponseMessage> ap(response); } catch (const Exception& e) { PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1, "Failed to export indication: %s", (const char*)e.getMessage().getCString())); throw; } catch (...) { PEG_TRACE_CSTRING (TRC_DISCARDED_DATA, Tracer::LEVEL1, "Failed to export indication"); throw; } PEG_METHOD_EXIT(); }
//async request handler method invoked on a seperate thread per provider //through the async request executor. CIMException DefaultProviderManager::_asyncRequestCallback( void *callbackPtr, AsyncRequestExecutor::AsyncRequestMsg* request) { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::_asyncRequestCallback"); CIMException responseException; //extract the parameters UnloadProviderRequest* my_request = dynamic_cast<UnloadProviderRequest*>(request); if(my_request != NULL) { PEGASUS_ASSERT(0 != callbackPtr); DefaultProviderManager *dpmPtr = static_cast<DefaultProviderManager*>(callbackPtr); ProviderMessageHandler* provider = dynamic_cast<ProviderMessageHandler*>(my_request->_provider); try { AutoMutex lock(provider->status.getStatusMutex()); //unload the provider if (provider->status.isInitialized()) { dpmPtr->_unloadProvider(provider); } else { PEGASUS_ASSERT(0); } } catch (CIMException& e) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,"CIMException: %s", (const char*)e.getMessage().getCString())); responseException = e; } catch (Exception& e) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,"Exception: %s", (const char*)e.getMessage().getCString())); responseException = CIMException(CIM_ERR_FAILED, e.getMessage()); } catch (PEGASUS_STD(exception)& e) { responseException = CIMException(CIM_ERR_FAILED, e.what()); } catch (...) { PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL1, "Exception: Unknown"); responseException = PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, "Unknown error."); } }
/** Update the specified property name and value in the current config file. */ Boolean ConfigFileHandler::updateCurrentValue( const CIMName& name, const String& value, Boolean unset) { // Remove the old property name and value from the table if (_currentConfig->table.contains(name.getString())) { if (!_currentConfig->table.remove(name.getString())) { return false; } } if (!unset) { // Store the new property name and value in to the table if (!_currentConfig->table.insert(name.getString(), value)) { return false; } } try { // Store the new property in current config file. _currentConfFile->save(_currentConfig); } catch (CannotRenameFile& e) { // // Back up creation failed // FUTURE: Log this message in a log file. // PEG_TRACE((TRC_CONFIG, Tracer::LEVEL1, "Backup configuration file creation failed: %s", (const char*)e.getMessage().getCString())); return false; } catch (CannotOpenFile& cof) { PEG_TRACE((TRC_CONFIG, Tracer::LEVEL1, "Setting permissions on current configuration file failed: %s", (const char*)cof.getMessage().getCString())); return false; } // // The current config file would now been created, // so set the flag to true. // _currentFileExist = true; return true; }
SCMOClass ProviderAgent::_scmoClassCache_GetClass( const CIMNamespaceName& nameSpace, const CIMName& className) { PEG_METHOD_ENTER(TRC_PROVIDERAGENT, "ProviderAgent::_scmoClassCache_GetClass"); // create message ProvAgtGetScmoClassRequestMessage* message = new ProvAgtGetScmoClassRequestMessage( XmlWriter::getNextMessageId(), nameSpace, className, QueueIdStack()); // Send the request for the SCMOClass to the server _providerAgent->_writeResponse(message); delete message; // Wait for semaphore signaled by _readAndProcessRequest() if (!_scmoClassDelivered.time_wait( PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS)) { PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1, "Timed-out waiting for SCMOClass for " "Name Space Name '%s' Class Name '%s'", (const char*)nameSpace.getString().getCString(), (const char*)className.getString().getCString())); PEG_METHOD_EXIT(); return SCMOClass("",""); } if ( 0 == _transferSCMOClass) { PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1, "No SCMOClass received for Name Space Name '%s' Class Name '%s'", (const char*)nameSpace.getString().getCString(), (const char*)className.getString().getCString())); PEG_METHOD_EXIT(); return SCMOClass("",""); } // Create a local copy. SCMOClass ret = SCMOClass(*_transferSCMOClass); // Delete the transferred instance. delete _transferSCMOClass; _transferSCMOClass = 0; PEG_METHOD_EXIT(); return ret; }
void CIMExportRequestDispatcher::handleEnqueue(Message* message) { PEG_METHOD_ENTER(TRC_EXP_REQUEST_DISP, "CIMExportRequestDispatcher::handleEnqueue"); PEGASUS_ASSERT(message != 0); switch (message->getType()) { case CIM_EXPORT_INDICATION_REQUEST_MESSAGE: { CIMExportIndicationResponseMessage* response = _handleExportIndicationRequest( (CIMExportIndicationRequestMessage*) message); PEG_TRACE(( TRC_HTTP, Tracer::LEVEL4, "_CIMExportRequestDispatcher::handleEnqueue(message) - " "message->getCloseConnect() returned %d", message->getCloseConnect())); response->setCloseConnect(message->getCloseConnect()); MessageQueue* queue = MessageQueue::lookup(response->dest); PEGASUS_ASSERT(queue != 0); queue->enqueue(response); break; } default: PEGASUS_UNREACHABLE(PEGASUS_ASSERT(0);) break; }
virtual FILE* openFile( const char* path, int mode) { FILE* fhandle = NULL; switch (mode) { case 'r': fhandle = fopen(path, "r"); break; case 'w': fhandle = fopen(path, "w"); break; case 'a': fhandle = fopen(path, "a+"); break; default: PEGASUS_ASSERT(fhandle); break; } if(!fhandle) { PEG_TRACE((TRC_SERVER, Tracer::LEVEL1, "Open of file %s in mode %c failed: %s",path,mode, (const char*) PEGASUS_SYSTEM_ERRORMSG.getCString())); } return fhandle; }
void CMPIProvider::terminate() { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPIProvider::terminate()"); if (_status == INITIALIZED) { try { _terminate(true); PEGASUS_ASSERT(unloadStatus == CMPI_RC_OK); } catch (...) { PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL1, "Exception caught in CMPIProviderFacade::Terminate for %s", (const char*)getName().getCString())); throw; } } // Provider's cleanup method called successfully, if there are still any // pending operations with provider then we were asked to cleanup forcibly, // don't uninitialize provider. if (_current_operations.get() == 0) { _status = UNINITIALIZED; } PEG_METHOD_EXIT(); }
/** This method should be called after the consumer is terminated and the * module is unloaded. Note that we cannot test for a loaded condition, * since the _module reference here may still exist (if more than one * consumer is using the module). * Simply test whether the consumer is initialized. * If it was terminated properly, initialized will be false and the _module * ref count will be decremented. */ void DynamicConsumer::reset() { PEG_METHOD_ENTER(TRC_LISTENER, "DynamicConsumer::reset"); if (_initialized) { throw Exception( MessageLoaderParms( "DynListener.DynamicConsumer.CONSUMER_INVALID_STATE", "Error: The consumer is not in the correct state to " "perform the operation.")); } // do not delete it, that is taken care of in ConsumerModule itself _module = 0; // ATTN: attempting to delete this causes an exception -- why?? _consumer = 0; PEG_TRACE((TRC_LISTENER,Tracer::LEVEL4, "Deleting %d outstanding requests for %s", _eventqueue.size(), (const char*)_name.getCString())); //delete outstanding requests IndicationDispatchEvent* event = 0; for (Uint32 i = 0; i < _eventqueue.size(); i++) { event = _eventqueue.remove_front(); delete event; } PEG_METHOD_EXIT(); }
void DynamicConsumer::terminate(void) { PEG_METHOD_ENTER(TRC_LISTENER, "DynamicConsumer::terminate"); if (_initialized) { //terminate consumer try { DynamicConsumerFacade::terminate(); } catch (...) { PEG_TRACE((TRC_LISTENER,Tracer::LEVEL1, "Exception caught in DynamicConsumerFacade::Terminate for %s", (const char*)_name.getCString())); throw; } //update status _initialized = false; _dieNow = false; } PEG_METHOD_EXIT(); }
/** Initializes the consumer. * Caller assumes responsibility for catching exceptions thrown by this method. */ void DynamicConsumer::initialize() { PEG_METHOD_ENTER(TRC_LISTENER, "DynamicConsumer::initialize"); if (!_initialized) { try { //there is no cimom handle in the listener, so pass null CIMOMHandle* handle = 0; DynamicConsumerFacade::initialize(*(handle)); updateIdleTimer(); _initialized = true; PEG_TRACE_CSTRING( TRC_LISTENER, Tracer::LEVEL3, "Successfully initialized consumer."); } catch (...) { PEG_TRACE((TRC_LISTENER,Tracer::LEVEL1, "Exception caught in DynamicConsumerFacade::initialize for %s", (const char*)_name.getCString())); throw; } } PEG_METHOD_EXIT(); }
MessageQueue::MessageQueue(const char* name) : _queueId(getNextQueueId()) { // // Copy the name: // PEG_METHOD_ENTER(TRC_MESSAGEQUEUESERVICE,"MessageQueue::MessageQueue()"); if (!name) { name = ""; } _name = new char[strlen(name) + 1]; strcpy(_name, name); PEG_TRACE((TRC_MESSAGEQUEUESERVICE, Tracer::LEVEL3, "MessageQueue::MessageQueue name = %s, queueId = %u", name, _queueId)); // // Insert into queue table: // AutoMutex autoMut(q_table_mut); while (!_queueTable.insert(_queueId, this)) ; PEG_METHOD_EXIT(); }
Boolean ShutdownService::waitUntilNoMoreRequests(Boolean requestPending) { Uint32 waitTime = _shutdownTimeout; // maximum wait time in seconds const Uint32 waitInterval = 1; // one second wait interval Uint32 requestCount; // // Loop and wait one second until either there is no more requests // or until timeout expires. // while (waitTime > 0) { requestCount = _cimserver->getOutstandingRequestCount(); if (requestCount <= (requestPending ? 1 : 0)) { return true; } PEG_TRACE(( TRC_SHUTDOWN, Tracer::LEVEL4, "ShutdownService waiting for outstanding CIM operations to " "complete. Request count: %d", requestCount)); Threads::sleep(waitInterval * 1000); waitTime -= waitInterval; } return _cimserver->getOutstandingRequestCount() <= (requestPending ? 1 : 0); }
Message* ProviderAgent::_processRequest(CIMRequestMessage* request) { PEG_METHOD_ENTER(TRC_PROVIDERAGENT, "ProviderAgent::_processRequest"); Message* response = 0; try { // Forward the request to the ProviderManager response = _providerManagerRouter.processMessage(request); } catch (Exception& e) { PEG_TRACE((TRC_PROVIDERAGENT, Tracer::LEVEL1, "Caught exception while processing request: %s", (const char*)e.getMessage().getCString())); CIMResponseMessage* cimResponse = request->buildResponse(); cimResponse->cimException = PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, e.getMessage()); response = cimResponse; } catch (...) { PEG_TRACE_CSTRING(TRC_PROVIDERAGENT, Tracer::LEVEL1, "Caught exception while processing request."); CIMResponseMessage* cimResponse = request->buildResponse(); cimResponse->cimException = PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, String::EMPTY); response = cimResponse; } PEG_METHOD_EXIT(); return response; }
Boolean System::isPrivilegedUser(const String& userName) { #if defined(PEGASUS_OS_PASE) CString user = userName.getCString(); // this function only can be found in PASE environment return umeIsPrivilegedUser((const char *)user); #else struct passwd pwd; struct passwd *result; const unsigned int PWD_BUFF_SIZE = 1024; char pwdBuffer[PWD_BUFF_SIZE]; if (getpwnam_r( userName.getCString(), &pwd, pwdBuffer, PWD_BUFF_SIZE, &result) != 0) { PEG_TRACE(( TRC_OS_ABSTRACTION, Tracer::LEVEL1, "getpwnam_r failure : %s", strerror(errno))); } // Check if the requested entry was found. If not return false. if ( result != NULL ) { // Check if the uid is 0. if ( pwd.pw_gid == 0 || pwd.pw_uid == 0 ) { return true; } } return false; #endif }
ProviderOperationCounter DefaultProviderManager::_getProvider( const String& moduleFileName, const String& moduleName, const String& providerName) { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::_getProvider"); ProviderMessageHandler* pr = _lookupProvider(moduleName, providerName); if (!pr->status.isInitialized()) { _initProvider(pr, moduleFileName); } AutoMutex lock(pr->status.getStatusMutex()); if (!pr->status.isInitialized()) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, "provider initialization failed"); } ProviderOperationCounter poc(pr); PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4,"Returning Provider %s", (const char*)providerName.getCString())); PEG_METHOD_EXIT(); return poc; }
ClientCIMOMHandleAccessController(Mutex& lock) : _lock(lock) { try { // assume default client timeout if (!_lock.timed_lock(PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS)) { throw CIMException(CIM_ERR_ACCESS_DENIED, MessageLoaderParms( "Provider.CIMOMHandle.CIMOMHANDLE_TIMEOUT", "Timeout waiting for CIMOMHandle")); } } catch (Exception& e) { PEG_TRACE((TRC_CIMOM_HANDLE, Tracer::LEVEL2, "Unexpected Exception: %s", (const char*)e.getMessage().getCString())); throw; } catch (...) { PEG_TRACE_CSTRING(TRC_CIMOM_HANDLE, Tracer::LEVEL2, "Unexpected exception"); throw; } }
void EnumerationContext::setClientClosed() { PEGASUS_DEBUG_ASSERT(valid()); _clientClosed = true; _processing = false; #ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL3, "setClientClosed. ContextId=%s ", *Str(getContextId()) )); #endif // Clear any existing responses out of the cache. They will never // be used. _responseCache.clear(); if (!_providersComplete) { // Signal that cache size has dropped. signalProviderWaitCondition(); } #ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE trace(); #endif }
/* Test interoperation timer against current time. Return true if timed out or timer set 0 zero indicating that the timer is not active. Returns bool true if timer not zero and Interoperation timer is greater than interoperation timeout (i.e timed out). */ bool EnumerationContext::isTimedOut(Uint64 currentTime) { PEGASUS_DEBUG_ASSERT(valid()); if (_operationTimerUsec == 0) { return false; } bool timedOut = _operationTimerUsec <= currentTime; #ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4, "isTimedOut Timer. ContextId=%s timer(sec)=%lu" " current(sec)=%lu time to timeout(usec)=%ld isTimedOut=%s", *Str(getContextId()), (long unsigned int)(_operationTimerUsec / PEG_MICROSEC), (long unsigned int)(currentTime / PEG_MICROSEC), (long signed int)((_operationTimerUsec - currentTime)), boolToString(timedOut) )); #endif // If it is timed out, set timer inactive. if (timedOut) { _operationTimerUsec = 0; } return(timedOut); }
// Wait until cache size drops below defined limit. Saves time // in wait in EnumerationContext for statistics and uses // waitProviderLimitCondition condition variable. void EnumerationContext::waitCacheSize() { PEG_METHOD_ENTER(TRC_ENUMCONTEXT, "EnumerationContext::waitCacheSize()"); PEGASUS_DEBUG_ASSERT(valid()); _providerWaitConditionMutex.lock(); Uint64 startTime = System::getCurrentTimeUsec(); while ((!_clientClosed) && (responseCacheSize() > _responseCacheMaximumSize) && !_providersComplete) { _providerWaitCondition.wait(_providerWaitConditionMutex); } _providerWaitConditionMutex.unlock(); Uint64 interval = System::getCurrentTimeUsec() - startTime; #ifdef ENUMERATION_CONTEXT_DIAGNOSTIC_TRACE PEG_TRACE((TRC_ENUMCONTEXT, Tracer::LEVEL4, "waitCacheSize ContextId=%s Wait=%lu usec", *Str(getContextId()), (unsigned long int)interval )); #endif _totalWaitTimeUsec += interval; if (interval > _maxWaitTimeUsec) { _maxWaitTimeUsec = interval; } PEG_METHOD_EXIT(); }
Boolean DefaultProviderManager::hasActiveProviders() { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::hasActiveProviders"); try { AutoMutex lock(_providerTableMutex); PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Number of providers in _providers table = %d", _providers.size())); // Iterate through the _providers table looking for an active provider for (ProviderTable::Iterator i = _providers.start(); i != 0; i++) { if (i.value()->status.isInitialized()) { PEG_METHOD_EXIT(); return true; } } } catch (...) { // Unexpected exception; do not assume that no providers are loaded PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL1, "Unexpected Exception in hasActiveProviders."); PEG_METHOD_EXIT(); return true; } // No active providers were found in the _providers table PEG_METHOD_EXIT(); return false; }
void IndicationDispatchEvent::increaseRetries() { PEG_TRACE_CSTRING(TRC_LISTENER, Tracer::LEVEL4, "Increasing retries\n"); _retries++; _lastAttemptTime = CIMDateTime::getCurrentDateTime(); PEG_TRACE((TRC_LISTENER,Tracer::LEVEL4,"Last attempt time %s", (const char*)_lastAttemptTime.toString().getCString())); }
void shutdownSignalHandler(int s_n, PEGASUS_SIGINFO_T* s_info, void* sig) { PEG_METHOD_ENTER(TRC_SERVER, "shutdownSignalHandler"); PEG_TRACE((TRC_SERVER, Tracer::LEVEL3, "Signal %d received.", s_n)); CIMServer::shutdownSignal(); PEG_METHOD_EXIT(); }
// // Send notify config change message to provider manager service // This code was borrowed from the ConfigSettingProvider and should // be kept in sync. // The purpose is to ensure that OOP agents also get the update. // TBD, or is it for other reasons as well? // void ZOSConsoleManager::_sendNotifyConfigChangeMessage( const String& propertyName, const String& newPropertyValue, Boolean currentValueModified) { PEG_METHOD_ENTER(TRC_SERVER, "ZOSConsoleManager::_sendNotifyConfigChangeMessage"); ModuleController* controller = ModuleController::getModuleController(); MessageQueue * queue = MessageQueue::lookup( PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP); MessageQueueService * service = dynamic_cast<MessageQueueService *>(queue); if (service != NULL) { // create CIMNotifyConfigChangeRequestMessage CIMNotifyConfigChangeRequestMessage * notify_req = new CIMNotifyConfigChangeRequestMessage ( XmlWriter::getNextMessageId (), propertyName, newPropertyValue, currentValueModified, QueueIdStack(service->getQueueId())); notify_req->operationContext.insert( IdentityContainer(System::getEffectiveUserName())); // create request envelope AsyncLegacyOperationStart asyncRequest( NULL, service->getQueueId(), notify_req); AutoPtr<AsyncReply> asyncReply( controller->ClientSendWait(service->getQueueId(), &asyncRequest)); AutoPtr<CIMNotifyConfigChangeResponseMessage> response( reinterpret_cast<CIMNotifyConfigChangeResponseMessage *>( (static_cast<AsyncLegacyOperationResult *> (asyncReply.get()))->get_result())); if (response->cimException.getCode() != CIM_ERR_SUCCESS) { CIMException e = response->cimException; const CString exMsg = e.getMessage().getCString(); PEG_TRACE((TRC_SERVER, Tracer::LEVEL1, "Notify config changed failed with rc=%d, message = %s", e.getCode(), (const char*)exMsg)); PEG_METHOD_EXIT(); } } PEG_METHOD_EXIT(); }
void WsmResponseEncoder::sendResponse(const SoapResponse* response) { PEG_METHOD_ENTER(TRC_WSMSERVER, "WsmResponseEncoder::sendResponse"); PEG_TRACE((TRC_WSMSERVER, Tracer::LEVEL3, "WsmResponseEncoder::sendResponse()")); if (!response) { PEG_METHOD_EXIT(); return; } Uint32 queueId = response->getQueueId(); Boolean httpCloseConnect = response->getHttpCloseConnect(); PEG_TRACE((TRC_WSMSERVER, Tracer::LEVEL4, "WsmResponseEncoder::sendResponse()- " "response->getHttpCloseConnect() returned %d", httpCloseConnect)); MessageQueue* queue = MessageQueue::lookup(queueId); if (!queue) { PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1, "ERROR: non-existent queueId = %u, response not sent.", queueId)); PEG_METHOD_EXIT(); return; } PEGASUS_ASSERT(dynamic_cast<HTTPConnection*>(queue) != 0); Buffer message = response->getResponseContent(); // Note: WS-Management responses are never sent in chunks, so there is no // need to check dynamic_cast<HTTPConnection*>(queue)->isChunkRequested(). // HTTPMessage::isComplete() defaults to true, and we leave it that way. AutoPtr<HTTPMessage> httpMessage(new HTTPMessage(message)); httpMessage->setCloseConnect(httpCloseConnect); queue->enqueue(httpMessage.release()); PEG_METHOD_EXIT(); }
ProviderMessageHandler* DefaultProviderManager::_lookupProvider( const String& moduleName, const String& providerName) { PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "DefaultProviderManager::_lookupProvider"); // lock the providerTable mutex AutoMutex lock(_providerTableMutex); // Construct the lookup key. We need a compound key to differentiate // providers with the same name from different modules. The size field is // added to handle the unlikely case when moduleName+providerName // produce identical strings but define different providers. char buffer[12]; sprintf(buffer, "%u:", providerName.size()); const String key = buffer + moduleName + ":" + providerName; // look up provider in cache ProviderMessageHandler* pr = 0; if (_providers.lookup(key, pr)) { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4, "Found Provider %s in Provider Manager Cache", (const char*)providerName.getCString())); } else { // create provider pr = new ProviderMessageHandler( moduleName, providerName, 0, _indicationCallback, _responseChunkCallback, _subscriptionInitComplete); // insert provider in provider table _providers.insert(key, pr); PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL4,"Created provider %s", (const char*)pr->getName().getCString())); } PEG_METHOD_EXIT(); return pr; }