ctaCloseServices

Closes one or more services.

Prototype

DWORD ctaCloseServices ( CTAHD ctahd, char *svcname[], unsigned nsvcs)

Argument

Description

ctahd

Context handle.

svcname

Pointer to the names of the services to close.

nsvcs

Number of services in svcname.


Return values

Return value

Description

SUCCESS

 

CTAERR_BAD_ARGUMENT

svcname pointer is NULL.

CTAERR_INVALID_CTAHD

An invalid context handle was passed as an argument to a function, or the context was destroyed by another thread.

CTAERR_INVALID_SEQUENCE

There is a pending open or close service on the context.

CTAERR_NOT_FOUND

One or more services in svcname are not open on the context.

CTAERR_NOT_INITIALIZED

Natural Access is not initialized. Call ctaInitialize first.

CTAERR_SVR_COMM

Server communication error.


Events

CTAEVN_CLOSE_SERVICES_DONE

Details

ctaCloseServices closes one or more services on a context. This function is asynchronous and returns immediately. The application must wait for the DONE event before all the services indicated in svcname are closed.

If multiple services are being closed and more than one service close fails, the value field of the CTA_EVENT structure (specified in ctaWaitEvent) contains the failure reason for the first service that failed to close.

Note: To more efficiently identify which service failed to close, close services one at a time.

Refer to Closing services for more information.

See also

ctaOpenServices

Example

/* This is a synchronous function and assumes a single context */
/* per queue programming model has been used.                  */

void DemoCloseServices( CTAQUEUEHD ctaqueuehd, CTAHD ctahd, 
                        char *services[], unsigned numservices)
{
    CTA_EVENT  event;

    /* Close services */
    ctaCloseServices( ctahd, services, numservices );

    /* Wait for the services to be closed asynchronously */
    do
    {
        ctaWaitEvent( ctaqueuehd, &event, CTA_WAIT_FOREVER ); 
    } while (event.id != CTAEVN_CLOSE_SERVICES_DONE);
      
    if (event.value != CTA_REASON_FINISHED)
        printf ("Closing services failed: val=0x%x\n", event.value );
}