iofunc_notify_trigger(), iofunc_notify_trigger_strict()
Send notifications to queued clients
Synopsis:
#include <sys/iofunc.h>
void iofunc_notify_trigger( iofunc_notify_t *nop,
int count,
int index );
void iofunc_notify_trigger_strict( resmgr_context_t *ctp,
iofunc_notify_t *nop,
int count,
int index );
Arguments:
- ctp
- (iofunc_notify_trigger_strict() only) A pointer to a resmgr_context_t structure that the resource-manager library uses to pass context information between functions. This argument can be NULL to notify all clients that match, or a current ctp to notify only on the file descriptor of the current client.
- nop
- An array of three iofunc_notify_t structures that represent (in order) the input, output, and out-of-band notification lists whose entries you want to examine.
- count
- The count that you want to compare against the trigger value for the input, output, or out-of-band event in each notification list entry. The trigger values for the three event types are defined earlier in the notifycounts argument of iofunc_notify().
- index
- The index into the nop array that you want to check; one of
the following:
- IOFUNC_NOTIFY_INPUT
- IOFUNC_NOTIFY_OUTPUT
- IOFUNC_NOTIFY_OBAND
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The iofunc_notify_trigger() function examines all entries given in the list at nop[index] to see if each event should be delivered. If the specified count is greater than or equal to the trigger value for the particular notification list element, then the function updates the event if appropriate, calls MsgDeliverEvent() to deliver the event to the client whose rcvid is stored in that list element, and disarms the element.
The iofunc_notify_trigger_strict() function is similar, except that only notifications armed
via the file descriptor in the client that maps to the ctp argument are notified.
The strict
variant is useful when a duplicated file descriptor is
closed, and only clients blocked on that descriptor are required to wake
up and notice (EBADF on subsequent read or write).
Calling this function with a ctp of NULL
provides the same behavior as iofunc_notify_trigger().
A resource manager generally calls iofunc_notify_trigger_strict() in a close_dup callout to unblock any client poll() calls that are waiting on a file descriptor that's been closed. You should call it three times with a count value of INT_MAX, the ctp passed to the close_dup callout, and an index of IOFUNC_NOTIFY_INPUT, IOFUNC_NOTIFY_OUTPUT, and IOFUNC_NOTIFY_OBAND.
#define IOFUNC_NOTIFY_INPUT_CHECK(__nop, __cnt, __tran) ...
#define IOFUNC_NOTIFY_OUTPUT_CHECK(__nop, __cnt) ...
#define IOFUNC_NOTIFY_OBAND_CHECK(__nop, __cnt, __tran) ...
The arguments are:
- __nop
- An array of three iofunc_notify_t structures that represent (in order), the input, output, and out-of-band notification lists whose entries you want to examine.
- __cnt
- The number of elements present in the corresponding queue (input, output, or out-of-band) to compare to the trigger value. The trigger value is provided by iofunc_notify() and specifies the number of elements that need to be present to trigger an event.
- __tran
- (IOFUNC_NOTIFY_INPUT_CHECK() and IOFUNC_NOTIFY_OBAND_CHECK() only) Nonzero if you want to arm the trigger when the list makes the transition from empty to nonempty. (For example, mq_notify() does this.)
Examples:
Classification:
Safety: | |
---|---|
Cancellation point | No |
Signal handler | Yes |
Thread | Read the Caveats |
Caveats
To ensure thread safety, lock the underlying object before calling this function. This object is usually an iofunc_attr_t structure; lock it by calling iofunc_attr_lock().