CT_EVENT_READ(3CONTRACT) Contract Management Library Functions CT_EVENT_READ(3CONTRACT)

ct_event_read, ct_event_read_critical, ct_event_reset, ct_event_reliable, ct_event_free, ct_event_get_flags, ct_event_get_ctid, ct_event_get_evid, ct_event_get_type, ct_event_get_nevid, ct_event_get_newct - common contract event functions

cc [ flag... ] file... -D_LARGEFILE64_SOURCE  -lcontract  [ library... ]
#include <libcontract.h>
int ct_event_read(int fd, ct_evthdl_t *evthndlp);

int ct_event_read_critical(int fd, ct_evthdl_t *evthndlp);

int ct_event_reset(int fd);

int ct_event_reliable(int fd);

void ct_event_free(ct_evthdl_t evthndl);

ctid_t ct_event_get_ctid(ct_evthdl_t evthndl);

ctevid_t ct_event_get_evid(ct_evthdl_t evthndl);

uint_t ct_event_get_flags(ct_evthdl_t evthndl);

uint_t ct_event_get_type(ct_evthdl_t evthndl);

int ct_event_get_nevid(ct_evthdl_t evthndl, ctevid_t *evidp);

int ct_event_get_newct(ct_evthdl_t evthndl, ctid_t *ctidp);

These functions operate on contract event endpoint file descriptors obtained from the contract(5) file system and event object handles returned by ct_event_read() and ct_event_read_critical().

The ct_event_read() function reads the next event from the queue referenced by the file descriptor fd and initializes the event object handle pointed to by evthndlp. After a successful call to ct_event_read(), the caller is responsible for calling ct_event_free() on this event object handle when it has finished using it.

The ct_event_read_critical() function behaves like ct_event_read() except that it reads the next critical event from the queue, skipping any intermediate events.

The ct_event_reset() function resets the location of the listener to the beginning of the queue. This function can be used to re-read events, or read events that were sent before the event endpoint was opened. Informative and acknowledged critical events, however, might have been removed from the queue.

The ct_event_reliable() function indicates that no event published to the specified event queue should be dropped by the system until the specified listener has read the event. This function requires that the caller have the {PRIV_CONTRACT_EVENT} privilege in its effective set.

The ct_event_free() function frees any storage associated with the event object handle specified by evthndl.

The ct_event_get_ctid() function returns the ID of the contract that sent the specified event.

The ct_event_get_evid() function returns the ID of the specified event.

The ct_event_get_flags() function returns the event flags for the specified event. Valid event flags are:

CTE_INFO

The event is an informative event.

CTE_ACK

The event has been acknowledged (for critical and negotiation messages).

CTE_NEG

The message represents an exit negotiation.

The ct_event_get_type() function reads the event type. The value is one of the event types described in contract(5) or the contract type's manual page.


The ct_event_get_nevid() function reads the negotiation ID from an CT_EV_NEGEND event.

The ct_event_get_newct() function obtains the ID of the contract created when the negotiation referenced by the CT_EV_NEGEND event succeeded. If no contract was created, ctidp will be 0. If the operation was cancelled, *ctidp will equal the ID of the existing contract.

Upon successful completion, ct_event_read(), ct_event_read_critical(), ct_event_reset(), ct_event_reliable(), ct_event_get_nevid(), and ct_event_get_newct() return 0. Otherwise, they return a non-zero error value.

The ct_event_get_flags(), ct_event_get_ctid(), ct_event_get_evid(), and ct_event_get_type() functions return data as described in the DESCRIPTION.

The ct_event_reliable() function will fail if:

EPERM

The caller does not have {PRIV_CONTRACT_EVENT} in its effective set.

The ct_event_read() and ct_event_read_critical() functions will fail if:

EAGAIN

The event endpoint was opened O_NONBLOCK and no applicable events were available to be read.

The ct_event_get_nevid() and ct_event_get_newct() functions will fail if:

EINVAL

The evthndl argument is not a CT_EV_NEGEND event object.

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Evolving
MT-Level Safe

libcontract(3LIB), contract(5), attributes(7), lfcompile(7)

April 9, 2016 OmniOS