[Previous] [Contents] [Next]

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 );

Library:

libc

Description:

The iofunc_ocb_detach() function releases any resources allocated to the passed ocb, such as any memory map (mmap) entries. It also updates the time structure via 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).

This function is called by iofunc_close_ocb(). This function doesn't free the memory associated with the OCB itself.

The return from iofunc_ocb_detach() is a bitwise OR of flags (see below) describing the state of the managed resource. 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 the iofunc_mmap() or iofunc_mmap_default(), you must call this function to clean up. This function is called automatically by iofunc_close_dup().

Returns:

The return value is a bitwise OR of flags, indicating (if set):

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 6

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

See also:

iofunc_close_dup(), iofunc_close_ocb(), iofunc_close_ocb_default(), iofunc_ocb_attach()


[Previous] [Contents] [Next]