2285 /*
2286 * cte_publish_all
2287 *
2288 * Publish an event to all necessary event queues. The event, e, must
2289 * be zallocated by the caller, and the event's flags and type must be
2290 * set. The rest of the event's fields are initialized here.
2291 */
2292 uint64_t
2293 cte_publish_all(contract_t *ct, ct_kevent_t *e, nvlist_t *data, nvlist_t *gdata)
2294 {
2295 ct_equeue_t *q;
2296 timespec_t ts;
2297 uint64_t evid;
2298 ct_kevent_t *negev;
2299 int negend;
2300
2301 e->cte_contract = ct;
2302 e->cte_data = data;
2303 e->cte_gdata = gdata;
2304 e->cte_refs = 3;
2305 evid = e->cte_id = atomic_add_64_nv(&ct->ct_type->ct_type_evid, 1);
2306 contract_hold(ct);
2307
2308 /*
2309 * For a negotiation event we set the ct->ct_nevent field of the
2310 * contract for the duration of the negotiation
2311 */
2312 negend = 0;
2313 if (e->cte_flags & CTE_NEG) {
2314 cte_hold(e);
2315 ct->ct_nevent = e;
2316 } else if (e->cte_type == CT_EV_NEGEND) {
2317 negend = 1;
2318 }
2319
2320 gethrestime(&ts);
2321
2322 /*
2323 * ct_evtlock simply (and only) ensures that two events sent
2324 * from the same contract are delivered to all queues in the
2325 * same order.
|
2285 /*
2286 * cte_publish_all
2287 *
2288 * Publish an event to all necessary event queues. The event, e, must
2289 * be zallocated by the caller, and the event's flags and type must be
2290 * set. The rest of the event's fields are initialized here.
2291 */
2292 uint64_t
2293 cte_publish_all(contract_t *ct, ct_kevent_t *e, nvlist_t *data, nvlist_t *gdata)
2294 {
2295 ct_equeue_t *q;
2296 timespec_t ts;
2297 uint64_t evid;
2298 ct_kevent_t *negev;
2299 int negend;
2300
2301 e->cte_contract = ct;
2302 e->cte_data = data;
2303 e->cte_gdata = gdata;
2304 e->cte_refs = 3;
2305 evid = e->cte_id = atomic_inc_64_nv(&ct->ct_type->ct_type_evid);
2306 contract_hold(ct);
2307
2308 /*
2309 * For a negotiation event we set the ct->ct_nevent field of the
2310 * contract for the duration of the negotiation
2311 */
2312 negend = 0;
2313 if (e->cte_flags & CTE_NEG) {
2314 cte_hold(e);
2315 ct->ct_nevent = e;
2316 } else if (e->cte_type == CT_EV_NEGEND) {
2317 negend = 1;
2318 }
2319
2320 gethrestime(&ts);
2321
2322 /*
2323 * ct_evtlock simply (and only) ensures that two events sent
2324 * from the same contract are delivered to all queues in the
2325 * same order.
|