Beispiel #1
0
static os_result
u__userExceptionCallbackWrapper(void)
{
    /* do not detach when using single process as this does not function correctly for single process*/
    if(!os_serviceGetSingleProcess()) {
        OS_REPORT(OS_ERROR, "u__userExceptionCallbackWrapper", 0,
                "Exception occurred, will detach user-layer from domain.");
        u__userDetach();
    }
    return os_resultSuccess;
}
Beispiel #2
0
static os_result
u__serviceExceptionCallbackWrapper(void)
{
    os_result result = os_resultSuccess;

    /* do not detach when using single process as this does not function correctly for single process*/
    if(!os_serviceGetSingleProcess()) {
        OS_REPORT(OS_ERROR, "u__serviceExceptionCallbackWrapper", 0,
                "Exception occurred, will detach service from domain.");
        /* calling the kernel service free directly because only the kernel administration needs to be removed */
        if (u_entityAction(u_entity(callbackService),freeKernelServiceObject,NULL) != U_RESULT_OK)
            result = os_resultFail;
    }
    return result;
}
Beispiel #3
0
static os_result
u__userExitRequestCallbackWrapper(
    os_callbackArg arg)
{
    /* do _exit when using single process as the exit request handler does not function correctly for single process*/
    if(!os_serviceGetSingleProcess()) {
        OS_REPORT(OS_WARNING, "u__userExitRequestCallbackWrapper", 0,
                  "Received termination request, will detach user-layer from domain.");
        u__userDetach();
    } else {
#ifdef _WRS_KERNEL
        exit(0);
#else
        _exit(0);
#endif    
    }
    return os_signalHandlerFinishExitRequest(arg);
}
Beispiel #4
0
OPENSPLICE_SERVICE_ENTRYPOINT (ospl_cmsoap, cmsoap)
{
    cms_service cms;
    cms_client client;
    c_bool success;
    char* name = NULL;
    char* config;
    c_long slave;
    struct soap* soap;
    slave = -1;
    soap = NULL;

       if(argc == 3)
       {
          name = argv[1];
          config = argv[2];
          cms = cms_serviceNew(name,config);

          if(cms != NULL){
             os_signalHandlerExitRequestHandle erh = os_signalHandlerExitRequestHandleNil;

             if(!os_serviceGetSingleProcess()){
                  erh = os_signalHandlerRegisterExitRequestCallback(exitRequestHandler, NULL, NULL, NULL, cms);
             }

             while(cms->terminate == FALSE){
                while( (slave < 0) && (cms->terminate == FALSE)){
                   slave = soap_accept(cms->soap);
                }
                if (slave < 0) {
                   if(cms->configuration->verbosity > 0){
                      /* soap_accept is likely to return -1 when the soap service is shutdown
                       * so should be an INFO message here rather than a WARNING
                       */
                      OS_REPORT(OS_INFO, CMS_CONTEXT, 0,
                                "not accepting requests.");
                   }
                   cms->terminate = TRUE;
                } else {
                   if(cms->configuration->verbosity > 6){
                      OS_REPORT(OS_INFO, CMS_CONTEXT, 0,
                                  "Thread %d accepts connection from IP %d.%d.%d.%d\n",
                                  slave,
                                  (int)(cms->soap->ip>>24)&0xFF,
                                  (int)(cms->soap->ip>>16)&0xFF,
                                  (int)(cms->soap->ip>>8)&0xFF,
                                  (int)(cms->soap->ip&0xFF));
                   }
                   client = cms_serviceLookupClient(cms);

                   if(client != NULL){
                      soap = soap_copy(cms->soap);

                      if (soap == NULL) {
                         if(cms->configuration->verbosity > 0){
                            OS_REPORT(OS_ERROR, CMS_CONTEXT, 0,
                                      "Could not allocate SOAP environment.");
                         }
                         cms->terminate = TRUE;
                      } else {
                         soap->socket = slave;
                         slave = -1;
                         success = cms_clientHandleRequest(client, soap);

                         if(success == FALSE){
                            soap->error = soap_receiver_fault(soap,
                                                              "Could not handle request.", NULL);
                            soap_send_fault(soap);
                            soap_destroy(soap);
                            soap_end(soap);
                            soap_done(soap);
                            os_free(soap);
                            soap = NULL;
                         }
                      }
                   } else {
                      if(cms->configuration->verbosity > 3){
                         OS_REPORT(OS_INFO, CMS_CONTEXT, 0,
                                   "Maximum number of clients reached.");
                      }

                      if (soap == NULL) {
                         if(cms->configuration->verbosity > 0){
                            OS_REPORT(OS_ERROR, CMS_CONTEXT, 0,
                                      "Could not allocate SOAP environment.");
                         }
                         cms->terminate = TRUE;
                      } else {
                         soap->socket = slave;
                         slave = -1;
                         soap->error = soap_receiver_fault(soap,
                                                           "Maximum number of clients reached.",
                                                           NULL);
                         soap_send_fault(soap);
                         soap_destroy(soap);
                         soap_end(soap);
                         soap_done(soap);
                         soap = NULL;
                      }
                   }
                }
             }