コード例 #1
0
ファイル: cms_client.c プロジェクト: osrf/opensplice
void
cms_clientFree(
    cms_client client)
{
    struct soap* soap;
    cms_soapThread soapThread;

    cms_thread(client)->terminate = TRUE;

    os_mutexLock(&client->conditionMutex);
    os_condSignal(&client->condition);
    os_mutexUnlock(&client->conditionMutex);

    cms_threadDeinit(cms_thread(client));

    if(client->soapEnvs){
        os_mutexLock(&client->soapMutex);
        soap = (struct soap*)(c_iterTakeFirst(client->soapEnvs));

        while(soap){
            soap->error = soap_receiver_fault(soap, "Service is terminating.", NULL);
            soap_send_fault(soap);
            soap_destroy(soap);
            soap_end(soap);
            soap_done(soap);
            os_free(soap);
            soap = (struct soap*)(c_iterTakeFirst(client->soapEnvs));
        }
        c_iterFree(client->soapEnvs);
        client->soapEnvs = NULL;
        os_mutexUnlock(&client->soapMutex);
    }

    if(client->threads){
        soapThread = cms_soapThread(c_iterTakeFirst(client->threads));

        while(soapThread){
            cms_soapThreadFree(soapThread);
            (void)u_observableAction(u_observable(client->service->uservice), cms_clientStatisticsThreadRemove, client->service);
            soapThread = cms_soapThread(c_iterTakeFirst(client->threads));
        }
        c_iterFree(client->threads);
        client->threads = NULL;
    }
    os_mutexDestroy(&client->soapMutex);
    os_mutexDestroy(&client->threadMutex);
    os_mutexDestroy(&client->conditionMutex);
    os_condDestroy(&client->condition);
    client->initCount = 0;

    if(client->service->configuration->verbosity >= 5){
        OS_REPORT(OS_INFO, CMS_CONTEXT, 0,
                        "Client thread stopped for IP: %d.%d.%d.%d",
                        (int)(client->ip>>24)&0xFF,
                        (int)(client->ip>>16)&0xFF,
                        (int)(client->ip>>8)&0xFF,
                        (int)(client->ip&0xFF));
    }
コード例 #2
0
ファイル: cms_soapThread.c プロジェクト: S73417H/opensplice
cms_soapThread
cms_soapThreadNew(
    const c_char* name,
    cms_client client)
{
    cms_soapThread thread;
    os_mutexAttr attr;
    os_condAttr condAttr;
    os_result osr;

    thread = NULL;
    osr = os_resultInvalid;

    if(client != NULL){
        thread = cms_soapThread(os_malloc(C_SIZEOF(cms_soapThread)));
        if (thread != NULL) {
            cms_object(thread)->kind = CMS_SOAPTHREAD;
            cms_threadInit(cms_thread(thread), name, &client->service->configuration->clientScheduling);
            cms_thread(thread)->uri =  os_strdup(cms_thread(client)->uri);
            thread->client = client;
            thread->soap = NULL;

            osr = os_mutexAttrInit(&attr);
            if(osr == os_resultSuccess){
                attr.scopeAttr = OS_SCOPE_PRIVATE;
                osr = os_mutexInit(&thread->soapMutex, &attr);
                if(osr == os_resultSuccess){
                    osr = os_condAttrInit(&condAttr);
                    if(osr == os_resultSuccess){
                        condAttr.scopeAttr = OS_SCOPE_PRIVATE;
                        osr = os_condInit(&thread->condition, &thread->soapMutex, &condAttr );
                    }
                }
            }
        }
    }

    if (osr != os_resultSuccess) {
        cms_soapThreadFree(thread);
        return NULL;
    }

    return thread;
}