| Updated: October 28, 2024 |
Add, poll, or remove a notification handler
#include <sys/iofunc.h>
int iofunc_notify( resmgr_context_t *ctp,
io_notify_t *msg,
iofunc_notify_t *nop,
int trig,
const int *notifycounts,
int *armed );
Generally, this structure is maintained by the resource manager within an extended attributes structure.
You typically set this value, based on the conditions in effect at the time of the call.
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The POSIX layer helper function iofunc_notify() is used by a resource manager to implement notification.
This routine examines the message that the resource manager received (passed in the msg argument) and performs one of the following actions requested by the client code:
io_notify_t structure
The io_notify_t structure holds the _IO_NOTIFY or _IO_NOTIFY64 message received by the resource manager:
struct _io_notify {
uint16_t type;
uint16_t combine_len;
int32_t action;
int32_t flags;
struct __sigevent32 event;
/* The fields `mgr` to `timo` are only valid if (flags & _NOTIFY_COND_EXTEN)
* The full header must be present regardless of the flags. */
int32_t mgr[2]; /* For use by manager */
int32_t flags_extra_mask;
int32_t flags_exten;
int32_t nfds;
int32_t fd_first;
int32_t nfds_ready;
int64_t timo;
/* struct pollfd fds[nfds]; */
};
struct _io_notify64 {
uint16_t type;
uint16_t combine_len;
int32_t action;
int32_t flags;
struct __sigevent32 old_event;
/* The fields `mgr` to `timo` are only valid if (flags & _NOTIFY_COND_EXTEN)
* The full header must be present regardless of the flags. */
int32_t mgr[2]; /* For use by manager */
int32_t flags_extra_mask;
int32_t flags_exten;
int32_t nfds;
int32_t fd_first;
int32_t nfds_ready;
int64_t timo;
union {
struct __sigevent32 event32;
struct __sigevent64 event64;
};
/* struct pollfd fds[nfds]; */
};
struct _io_notify_reply {
uint32_t zero;
uint32_t flags; /* actions above */
int32_t flags2; /* flags above */
struct __sigevent32 event;
/* Following fields only updated by new managers (if valid) */
int32_t mgr[2]; /* For use by manager */
int32_t flags_extra_mask;
int32_t flags_exten;
int32_t nfds;
int32_t fd_first;
int32_t nfds_ready;
int64_t timo;
/* struct pollfd fds[nfds]; */
};
struct _io_notify_reply64 {
uint32_t zero;
uint32_t flags; /* actions */
int32_t flags2; /* flags above */
struct __sigevent32 old_event;
/* Following fields only updated by new managers (if valid) */
int32_t mgr[2]; /* For use by manager */
int32_t flags_extra_mask;
int32_t flags_exten;
int32_t nfds;
int32_t fd_first;
int32_t nfds_ready;
int64_t timo;
union {
struct __sigevent32 event32;
struct __sigevent64 event64;
};
/* struct pollfd fds[nfds]; */
};
typedef union {
struct _io_notify i;
struct _io_notify64 i64;
struct _io_notify_reply o;
struct _io_notify_reply64 o64;
} io_notify_t;
The I/O message structures are unions of an input message (coming to the resource manager) and an output or reply message (going back to the client).
The i member (of type _io_notify) and the i64 member (of type _io_notify64) contain the following members:
As indicated by the comment, if _NOTIFY_COND_EXTEN is set in flags, the message is followed by an array of pollfd structures. For more information about this structure, see poll().
The o member (of type _io_notify_reply) and the o64 member (of type _io_notify_reply64) contain the following members:
This structure contains other fields that aren't updated by this function. It also includes updated copies of the extended fields, that is, mgr[2] to timo. If _NOTIFY_COND_EXTEN is set in flags, the message is followed by an array of pollfd structures.
iofunc_notify_t structure
The iofunc_notify_t structure is defined in <sys/iofunc.h> as follows:
typedef struct _iofunc_notify {
int cnt;
struct _iofunc_notify_event *list;
} iofunc_notify_t;
Its members include:
The iofunc_notify_event_t structure is defined as:
typedef struct _iofunc_notify_event {
struct _iofunc_notify_event *next;
int rcvid;
int scoid;
int cnt;
struct __sigevent32 old_event;
unsigned flags;
int coid;
union {
struct sigevent event;
struct __sigevent32 event32;
struct __sigevent64 event64;
};
} iofunc_notify_event_t;
Its members include:
The sys/iofunc.h file also defines the following macros that work with the arrays of iofunc_notify_t structures:
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |