iofunc_ocb_detach()

Release Open Control Block resources

Synopsis:

#include <sys/iofunc.h>

int iofunc_ocb_detach( resmgr_context_t * ctp,
                       iofunc_ocb_t * ocb );

Arguments:

ctp
A pointer to a resmgr_context_t structure that the resource-manager library uses to pass context information between functions.
ocb
A pointer to the iofunc_ocb_t structure for the Open Control Block that was created when the client opened the resource.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The iofunc_ocb_detach() function releases any resources allocated to the passed ocb, such as any memory map (mmap) entries.


Note: This function doesn't free the memory associated with the OCB itself.

The iofunc_ocb_detach() function also updates the time structure, by calling iofunc_time_update(), and decrements the read, write, lock, and use counters, according to the mode that was used to open the resource (from ocb->ioflag).

The counters are incremented in iofunc_ocb_attach(), and represent the number of OCBs that are using the managed resource in the respective manners (e.g.: ocb->attr->rcount keeps count of how many OCBs are using the resource specified by attr for read access).

If you're are using iofunc_mmap() or iofunc_mmap_default(), you must call iofunc_ocb_detach() to clean up. This function is called by iofunc_close_ocb().

Returns:

A bitwise OR of flags describing the state of the managed resource:

IOFUNC_OCB_LAST_READER
This OCB was the last one performing read operations on the resource. This flag is set when the ocb->attr->rcount flag is decremented to zero.
IOFUNC_OCB_LAST_WRITER
This OCB was the last one performing write operations on the resource. This flag is set when the ocb->attr->wcount flag is decremented to zero.
IOFUNC_OCB_LAST_RDLOCK
This OCB was the last one holding a read lock on the resource. This flag is set when the ocb->attr->rlocks flag is decremented to zero.
IOFUNC_OCB_LAST_WRLOCK
This OCB was the last one holding a write lock on the resource. This flag is set when the ocb->attr->wlocks flag is decremented to zero.
IOFUNC_OCB_LAST_INUSE
This OCB was the last one using the resource. This flag is set when the ocb->attr->count flag is decremented to zero.

Classification:

QNX Neutrino

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

iofunc_close_ocb(), iofunc_close_ocb_default(), iofunc_mmap(), iofunc_mmap_default(), iofunc_ocb_attach(), iofunc_ocb_t, iofunc_time_update(), resmgr_context_t

Writing a Resource Manager