fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <time.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <signal.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <poll.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_server.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_cache.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_obj.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_pdu.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_func.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_qry.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_msgq.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_log.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_sched.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_scn.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_esi.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * global variables.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * local variables.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic ev_t *ev_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t stopwatch = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic pthread_mutex_t stw_mtx = PTHREAD_MUTEX_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int wakeup = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic pthread_mutex_t idl_mtx = PTHREAD_MUTEX_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic pthread_cond_t idl_cond = PTHREAD_COND_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * external variables.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern const int UID_ATTR_INDEX[MAX_OBJ_TYPE_FOR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern boolean_t time_to_exit;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern msg_queue_t *sys_q;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint64_t esi_threshold;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void dump_pdu1(isns_pdu_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * local functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void *esi_monitor(void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * new_esi_portal:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Make a new portal for ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid - the portal object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ip6 - the portal IPv6 format IP address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * port - the portal port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * esip - the ESI port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the new ESI portal.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic esi_portal_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenew_esi_portal(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte in6_addr_t *ip6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t port,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t esip
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte esi_portal_t *p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = (esi_portal_t *)malloc(sizeof (esi_portal_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((int *)ip6)[0] == 0x00 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((int *)ip6)[1] == 0x00 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uchar_t *)ip6)[8] == 0x00 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uchar_t *)ip6)[9] == 0x00 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uchar_t *)ip6)[10] == 0xFF &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((uchar_t *)ip6)[11] == 0xFF) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p->sz = sizeof (in_addr_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p->ip4 = ((uint32_t *)ip6)[3];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p->sz = sizeof (in6_addr_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p->ip6 = ip6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p->port = port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p->esip = esip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p->ref = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p->so = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * free_esi_portal:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free a list of portal of one ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI portal.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefree_esi_portal(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte esi_portal_t *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte esi_portal_t *n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n = p->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(p->ip6);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = n;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ev_new:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Make a new ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid - the Entity object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * eid - the Entity object name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * len - the length of the name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic ev_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteev_new(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *eid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t len
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev = (ev_t *)malloc(sizeof (ev_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ev != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pthread_mutex_init(&ev->mtx, NULL) != 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ev->eid = (uchar_t *)malloc(len)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->uid = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy((char *)ev->eid, (char *)eid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->eid_len = len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialization time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->flags = EV_FLAG_INIT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_portal_uids:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Callback function which makes a copy of the portal child object
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * UIDs from a Network Entity object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - the Network Entity object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - the lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the number of portal object UIDs.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_portal_uids(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *cuidp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t num = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *p = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cuidp = get_child_t(obj, OBJ_PORTAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cuidp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = (uint32_t *)malloc(*cuidp * sizeof (*p));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num = *cuidp ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memcpy(p, cuidp, num * sizeof (*p));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[1].ptr = (uchar_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_ENTITY(ISNS_ENTITY_REG_PERIOD_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->tag != 0 && attr->value.ui != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[2].ui = attr->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* just one second before the end of the world */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[2].ui = INFINITY - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (num);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cb_esi_portal:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Callback function which gets ESI port number and ESI interval
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from a portal object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p1 - the Portal object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p2 - the lookup control data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the ESI interval.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecb_esi_portal(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t intval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t *lcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte in6_addr_t *ip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t esip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cb_clone_attrs(p1, p2) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = (isns_obj_t *)p1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp = (lookup_ctrl_t *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ip = lcp->data[1].ip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte esip = lcp->data[2].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (esip != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PORTAL(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PORTAL_PORT_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lcp->data[0].ui = attr->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[ATTR_INDEX_PORTAL(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_ESI_INTERVAL_ATTR_ID)];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->tag != 0 && attr->value.ui != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte intval = attr->value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte intval = DEFAULT_ESI_INTVAL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(ip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((int)intval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * extract_esi_portal:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Extract a list of portal which have an ESI port for an Entity.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid - the Entity object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * intval - the ESI interval for returnning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the list of portals.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic esi_portal_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextract_esi_portal(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *intval
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte esi_portal_t *list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte esi_portal_t *p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t num_of_portal;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *portal_uids;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t intv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare for looking up entity object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_ENTITY, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[1].ptr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[2].ui = INFINITY - 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the array of the portal uid(s) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num_of_portal = (uint32_t)cache_lookup(&lc, NULL, cb_portal_uids);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portal_uids = (uint32_t *)lc.data[1].ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *intval = lc.data[2].ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare for looking up portal object(s) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_PORTAL, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[1] = ISNS_PORTAL_IP_ADDR_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.id[2] = ISNS_ESI_PORT_ATTR_ID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FOR_EACH_OBJS(portal_uids, num_of_portal, uid, {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ui = uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte intv = cache_lookup(&lc, NULL, cb_esi_portal);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (intv != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = new_esi_portal(uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (in6_addr_t *)lc.data[1].ip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lc.data[0].ui, lc.data[2].ui);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p->next = list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte list = p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*intval > intv) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *intval = intv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte });
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free up the portal uid array */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(portal_uids);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ev_add:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add an ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ev - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * init - 0: initialization time, otherwise not.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteev_add(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int init
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t intval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte esi_portal_t *p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte double rnd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t t = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the portal(s) which are registered for ESI monitoring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* and the second interval for ESI or registration expiration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = extract_esi_portal(ev->uid, &intval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->intval = intval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->type = EV_ESI;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->portal = p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* avoid running everything at the same time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (init != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* generate random number within range (0, 1] */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rnd = (rand() + 1) / (double)(RAND_MAX + 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = (uint32_t)(intval * rnd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no portal is registered for ESI monitoring, make */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* an entry for entity registration expiration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->type = EV_REG_EXP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->portal = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (init != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = intval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* schedule the event */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (el_add(ev, t, NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * global functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sigalrm:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The signal handler for SIGALRM, the ESI proc uses the SIGALRM
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for waking up to perform the client status inquery.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sig - the signal.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesigalrm(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sig
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* wake up the idle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&idl_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wakeup = 1; /* wake up naturally */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_cond_signal(&idl_cond);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&idl_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * esi_load:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Load an ESI event from data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid - the Entity object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * eid - the Entity object name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * len - the length of the name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteesi_load(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *eid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t len
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make a new event */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev = ev_new(uid, eid, len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* put the new event to the list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ev != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->next = ev_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_list = ev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * verify_esi_portal:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Verify ESI port and add the ESI entries after the ESI are loaded.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteverify_esi_portal(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add each event from the list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ev_list != NULL && ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev = ev_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_list = ev->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ev_add(ev, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * esi_add:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add a new ESI event when a new Entity is registered.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid - the Entity object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * eid - the Entity object name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * len - the length of the name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteesi_add(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *eid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t len
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make a new event */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev = ev_new(uid, eid, len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ev != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* interrupt idle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->flags |= EV_FLAG_WAKEUP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ev_add(ev, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * esi_remove:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove an ESI event immediately.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid - the Entity object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - always successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteesi_remove(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) el_remove(uid, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * esi_remove_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Update an ESI event when a Entity object or a Portal object is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * removed from server. If the object is being removed because of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ESI failure, the ESI event will be removed with a pending time,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * otherwise, the ESI will be removed immediately.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the object being removed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pending - the pending flag.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - always successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteesi_remove_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *obj,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int pending
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t puid, uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (obj->type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case OBJ_PORTAL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte puid = get_parent_uid(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = get_obj_uid(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case OBJ_ENTITY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte puid = get_obj_uid(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte puid = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (puid != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) el_remove(puid, uid, pending);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_stopwatch:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the stopwatch. It might need to signal the condition to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wake up the idle so the stopwatch gets updated.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flag - wake up flag.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the stopwatch.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_stopwatch(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* not re-schedule, wake up idle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&idl_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wakeup = 2; /* wake up manually */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_cond_signal(&idl_cond);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wakeup = 0; /* clear previous interruption */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&idl_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get most current time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&stw_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = stopwatch;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&stw_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ev_intval:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the time interval of an ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the time interval.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteev_intval(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (((ev_t *)p)->intval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ev_match:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the ESI event maching an Entity object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid - the Entity object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 1: match, otherwise not.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteev_match(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((ev_t *)p)->uid == uid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ev_remove:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove a portal or an ESI event. If all of ESI portal has been
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * removed, the ESI event will be marked as removal pending, which
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will result in removing the Entity object after the pending time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * portal_uid - the Portal object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * flag - 0: the ESI is currently in use, otherwise it is scheduled.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pending - flag for the ESI removal pending.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 0: the ESI is physically removed, otherwise not.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteev_remove(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t portal_uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int pending
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev = (ev_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte esi_portal_t **pp, *portal;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int has_portal = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove one portal only */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (portal_uid != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp = &ev->portal;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portal = *pp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (portal != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* found the match portal */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (portal->ref == portal_uid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mark it as removed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portal->ref = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* not in use, remove it physically */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pp = portal->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portal->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_esi_portal(portal);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp = &portal->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* one or more esi portals are available */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (portal->ref != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte has_portal = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pp = &portal->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portal = *pp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no portal available */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (has_portal == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state = (pending << 1) | flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (state) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0x0:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mark the event as removed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->flags |= EV_FLAG_REMOVE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isnslog(LOG_DEBUG, "ev_remove",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s [%d] is marked as removed.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->type == EV_ESI ? "ESI" : "REG_EXP",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0x1:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* physically remove the event */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_free(ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0x2:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0x3:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mark the event as removal pending */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isnslog(LOG_DEBUG, "ev_remove",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s [%d] is marked as removal pending.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->type == EV_ESI ? "ESI" : "REG_EXP",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->flags |= EV_FLAG_REM_P1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte has_portal = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isnslog(LOG_DEBUG, "ev_remove", "%s [%d] removed portal %d.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->type == EV_ESI ? "ESI" : "REG_EXP",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->uid, portal_uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (has_portal);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ev_free:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free an ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteev_free(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev = (ev_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free up all of portals */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_esi_portal(ev->portal);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isnslog(LOG_DEBUG, "ev_free",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s [%d] is physically removed.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->type == EV_ESI ? "ESI" : "REG_EXP",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(ev->eid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free the event */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * evf_init:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the initial flag of an ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 0: not initial, otherwise yes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteevf_init(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (((ev_t *)p)->flags & EV_FLAG_INIT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * evf_again:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the again flag of an ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * (this flag might be eliminated and use the init flag.)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 0: not again, otherwise yes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteevf_again(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (((ev_t *)p)->flags & EV_FLAG_AGAIN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * evf_wakeup:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the wakeup flag of an ESI event. The idle might need to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wake up before the event is scheduled.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 0: no wakeup, otherwise yes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteevf_wakeup(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (((ev_t *)p)->flags & EV_FLAG_WAKEUP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * evf_rem:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the removal flag of an ESI event. The ESI entry might be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * marked as removal.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 0: not removed, otherwise yes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteevf_rem(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (((ev_t *)p)->flags & EV_FLAG_REMOVE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * evf_rem_pending:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the removal pending flag of an ESI event. The ESI entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * might be marked as removal pending. If it is, we will switch the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * event type and change the time interval.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 0: not removal pending, otherwise yes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteevf_rem_pending(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev = (ev_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ev->flags & EV_FLAG_REM_P) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ev->type != EV_REG_EXP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isnslog(LOG_DEBUG, "ev_rem_pending",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s [%d] is changed to REG_EXP.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->type == EV_ESI ? "ESI" : "REG_EXP",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->type = EV_REG_EXP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->intval *= 2; /* after 2 ESI interval */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * evf_zero:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reset the event flag.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteevf_zero(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev = (ev_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* not acutally clear it, need to set again flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* and keep the removal pending flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->flags = EV_FLAG_AGAIN | (ev->flags & EV_FLAG_REM_P);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * evl_append:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Append an ESI event to the list, the list contains all of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ESI events which are being processed at present.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteevl_append(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev = (ev_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->next = ev_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_list = ev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * evl_strip:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Strip off an ESI event from the list after the event is being
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * processed, it will be scheduled in the scheduler.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteevl_strip(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t **evp = &ev_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev = *evp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ev != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ev == p) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *evp = ev->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte evp = &ev->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev = *evp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * evl_remove:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove an ESI event or a portal of an ESI event from the event list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * id1 - the Entity object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * id2 - the Portal object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pending - the pending flag.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 1: found a match event, otherwise not.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteevl_remove(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t id1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t id2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int pending
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev = ev_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ev != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* found it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ev_match(ev, id1) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* lock the event */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&ev->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mark it as removed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ev_remove(ev, id2, 0, pending);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock the event */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&ev->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* tell caller removal is done */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev = ev->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* not found it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ALARM_MAX (21427200)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * idle:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Idle for certain amount of time or a wakeup signal is recieved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * t - the idle time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the time that idle left.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteidle(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t t1, t2, t3 = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int idl_int = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* hold the mutex for stopwatch update */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&stw_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (t > ALARM_MAX) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t1 = ALARM_MAX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t1 = t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* start alarm */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) alarm(t1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* hold the mutex for idle condition */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&idl_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* wait on condition variable to wake up idle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (wakeup == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_cond_wait(&idl_cond, &idl_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wakeup == 2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte idl_int = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clean wakeup flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wakeup = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release the mutex for idle condition */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&idl_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* stop alarm */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t2 = alarm(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* seconds actually slept */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t3 += t1 - t2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t -= t3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (t > 0 && idl_int == 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* increate the stopwatch by the actually slept time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stopwatch += t3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release the mutex after stopwatch is updated */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&stw_mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* return the amount of time which is not slept */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ev_ex:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Execute an event. To inquiry the client status or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * perform registration expiration.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ev - the event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteev_ex(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pthread_t tid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (ev->type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EV_ESI:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pthread_create(&tid, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte esi_monitor, (void *)ev) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isnslog(LOG_DEBUG, "ev_ex", "pthread_create() failed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reschedule for next occurence */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) el_add(ev, 0, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* increase the thread ref count */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inc_thr_count();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EV_REG_EXP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) queue_msg_set(sys_q, REG_EXP, (void *)ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * esi_proc:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ESI thread entry, which:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1: fetch an event from schedule,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2: idle for some time,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 3: execute the event or re-schedule it,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 4: repeat from step 1 before server is being shutdown.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg - the thread argument.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteesi_proc(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *arg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t t, t1, pt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *evp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (time_to_exit == B_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev = (ev_t *)el_first(&pt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* caculate the idle time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ev != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pt > stopwatch) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = pt - stopwatch;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = INFINITY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* block for a certain amount of time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (t > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isnslog(LOG_DEBUG, "esi_proc",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "idle for %d seconds.", t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t1 = idle(t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t1 = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (t1 > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isnslog(LOG_DEBUG, "esi_proc",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "idle interrupted after idle for "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%d seconds.", t - t1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (time_to_exit != B_FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev = NULL; /* force break */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (ev != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (t1 > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* not naturally waken up */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reschedule current event */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte evp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) el_add(ev, pt, &evp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev = (ev_t *)evp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = t1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* excute */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isnslog(LOG_DEBUG, "esi_proc",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "excute the cron job[%d].",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_ex(ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (ev != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * esi_ping:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Ping the client with the ESI retry threshold for status inquiry.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * so - the socket descriptor.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pdu - the ESI packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pl - the length of packet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 1: status inquired, otherwise not.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteesi_ping(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int so,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_pdu_t *pdu,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t pl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int try_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_pdu_t *rsp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t rsp_sz;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int alive = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_send_pdu(so, pdu, pl) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (isns_rcv_pdu(so, &rsp, &rsp_sz,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_RCV_SHORT_TIMEOUT) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dump_pdu1(rsp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte alive = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* retry after 1 second */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sleep(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try_cnt ++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } while (try_cnt < esi_threshold);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rsp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(rsp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (alive);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * esi_monitor:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Child thread for client status mornitoring.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * arg - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteesi_monitor(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *arg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev = (ev_t *)arg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte esi_portal_t *p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int so;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_pdu_t *pdu = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t sz;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t pl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t half;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte time_t t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int feedback;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* lock the event for esi monitoring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_lock(&ev->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (evf_rem(ev) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto mon_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (evf_rem_pending(ev) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto mon_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* timestamp */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte t = time(NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allocate ESI PDU */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pdu_reset_esi(&pdu, &pl, &sz) != 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu_add_tlv(&pdu, &pl, &sz,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_TIMESTAMP_ATTR_ID, 8, (void *)&t, 1) != 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu_add_tlv(&pdu, &pl, &sz,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_EID_ATTR_ID, ev->eid_len, (void *)ev->eid, 0) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no memory, will retry later */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto mon_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set pdu head */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu->version = htons((uint16_t)ISNSP_VERSION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu->func_id = htons((uint16_t)ISNS_ESI);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu->xid = htons(get_server_xid());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* keep the current lenght of the playload */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte half = pl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = ev->portal;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (p != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p->ref != 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* skip IPv6 portal */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p->sz != sizeof (in6_addr_t) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu_add_tlv(&pdu, &pl, &sz,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PORTAL_IP_ADDR_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (in6_addr_t), (void *)p->ip6, 0) == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pdu_add_tlv(&pdu, &pl, &sz,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISNS_PORTAL_PORT_ATTR_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 4, (void *)p->port, 0) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* connect once */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte so = connect_to(p->sz, p->ip4, p->ip6, p->esip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (so != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte feedback = esi_ping(so, pdu, pl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(so);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* p->so = so; */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cannot connect, portal is dead */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte feedback = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (feedback == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isnslog(LOG_DEBUG, "esi_monitor",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESI ping failed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) queue_msg_set(sys_q, DEAD_PORTAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)p->ref);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto mon_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pl = half;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = p->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemon_done:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock the event after esi monitoring is done */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pthread_mutex_unlock(&ev->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* clean up pdu */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pdu != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(pdu);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set reschedule flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->flags |= EV_FLAG_WAKEUP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reschedule for next occurence */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) el_add(ev, 0, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* decrease the thread ref count */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dec_thr_count();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * portal_dies:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Handles the dead portal that ESI detected.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * uid - the Portal object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteportal_dies(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare the lookup control for deregistration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_PORTAL, uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* lock the cache for object deregistration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_lock_write();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* deregister the portal */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = dereg_object(&lc, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock cache and sync with data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_unlock_sync(ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * portal_dies:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Handles the Entity registration expiration.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the ESI event.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereg_expiring(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *p
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev_t *ev = (ev_t *)p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lookup_ctrl_t lc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* prepare the lookup control for deregistration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SET_UID_LCP(&lc, OBJ_ENTITY, ev->uid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* lock the cache for object deregistration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_lock_write();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (evf_rem(ev) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* deregister the entity */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = dereg_object(&lc, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unlock cache and sync with data store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = cache_unlock_sync(ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successfuk, mark ev as removed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->flags |= EV_FLAG_REMOVE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* failed, retry after 3 mintues */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ev->intval = 3 * 60;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isnslog(LOG_DEBUG, "reg_expiring",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dereg failed, retry after 3 mintues.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ev is marked as removed, no need to dereg */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cache_unlock_nosync();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reschedule it for next occurence */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) el_add(ev, 0, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}