xref: /titanic_50/usr/src/man/man3contract/ct_event_read.3contract (revision 506ea5b80cb420d5edeb6aff19fe035c0a283bb3)
te
Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
CT_EVENT_READ 3CONTRACT "Apr 1, 2004"
NAME
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
SYNOPSIS

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

These functions operate on contract event endpoint file descriptors obtained from the contract(4) 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(4) 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.

RETURN VALUES

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.

ERRORS

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 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.

ATTRIBUTES

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

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Evolving
MT-Level Safe
SEE ALSO

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