/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <stdlib.h>
#include <limits.h>
#include <sys/sysmacros.h>
#include <libinetutil.h>
#include "libinetutil_impl.h"
/*
* iu_tq_create(): creates, initializes and returns a timer queue for use
*
* input: void
* output: iu_tq_t *: the new timer queue
*/
iu_tq_t *
iu_tq_create(void)
{
}
/*
* iu_tq_destroy(): destroys an existing timer queue
*
* input: iu_tq_t *: the timer queue to destroy
* output: void
*/
void
{
}
}
/*
* insert_timer(): inserts a timer node into a tq's timer list
*
* input: iu_tq_t *: the timer queue
* iu_timer_node_t *: the timer node to insert into the list
* uint64_t: the number of milliseconds before this timer fires
* output: void
*/
static void
{
/*
* find the node to insert this new node "after". we do this
* instead of the more intuitive "insert before" because with
* the insert before approach, a null `before' node pointer
* is overloaded in meaning (it could be null because there
* are no items in the list, or it could be null because this
* is the last item on the list, which are very different cases).
*/
break;
else
}
/*
* remove_timer(): removes a timer node from the tq's timer list
*
* input: iu_tq_t *: the timer queue
* iu_timer_node_t *: the timer node to remove from the list
* output: void
*/
static void
{
else
}
/*
* destroy_timer(): destroy a timer node
*
* input: iu_tq_t *: the timer queue the timer node is associated with
* iu_timer_node_t *: the node to free
* output: void
*/
static void
{
/*
* if we're in expire, don't delete the node yet, since it may
* still be referencing it (through the expire_next pointers)
*/
if (tq->iutq_in_expire) {
} else
}
/*
* iu_schedule_timer(): creates and inserts a timer in the tq's timer list
*
* input: iu_tq_t *: the timer queue
* uint32_t: the number of seconds before this timer fires
* iu_tq_callback_t *: the function to call when the timer fires
* void *: an argument to pass to the called back function
* output: iu_timer_id_t: the new timer's timer id on success, -1 on failure
*/
void *arg)
{
}
/*
* iu_schedule_ms_timer(): creates and inserts a timer in the tq's timer list,
* using millisecond granularity
*
* input: iu_tq_t *: the timer queue
* uint64_t: the number of milliseconds before this timer fires
* iu_tq_callback_t *: the function to call when the timer fires
* void *: an argument to pass to the called back function
* output: iu_timer_id_t: the new timer's timer id on success, -1 on failure
*/
void *arg)
{
return (-1);
return (-1);
}
return (node->iutn_timer_id);
}
/*
* iu_cancel_timer(): cancels a pending timer from a timer queue's timer list
*
* input: iu_tq_t *: the timer queue
* iu_timer_id_t: the timer id returned from iu_schedule_timer
* void **: if non-NULL, a place to return the argument passed to
* iu_schedule_timer
* output: int: 1 on success, 0 on failure
*/
int
{
if (timer_id == -1)
return (0);
return (1);
}
}
return (0);
}
/*
* iu_adjust_timer(): adjusts the fire time of a timer in the tq's timer list
*
* input: iu_tq_t *: the timer queue
* iu_timer_id_t: the timer id returned from iu_schedule_timer
* uint32_t: the number of seconds before this timer fires
* output: int: 1 on success, 0 on failure
*/
int
{
if (timer_id == -1)
return (0);
return (1);
}
}
return (0);
}
/*
* iu_earliest_timer(): returns the time until the next timer fires on a tq
*
* input: iu_tq_t *: the timer queue
* output: int: the number of milliseconds until the next timer (up to
* a maximum value of INT_MAX), or INFTIM if no timers are pending.
*/
int
{
unsigned long long timeout_interval;
return (INFTIM);
/*
* event might've already happened if we haven't gotten a chance to
* run in a while; return zero and pretend it just expired.
*/
return (0);
/*
* since the timers are ordered in absolute time-to-fire, just
* subtract from the head of the list.
*/
}
/*
* iu_expire_timers(): expires all pending timers on a given timer queue
*
* input: iu_tq_t *: the timer queue
* output: int: the number of timers expired
*/
int
{
int n_expired = 0;
/*
* in_expire is in the iu_tq_t instead of being passed through as
* an argument to remove_timer() below since the callback
* function may call iu_cancel_timer() itself as well.
*/
tq->iutq_in_expire++;
/*
* this function builds another linked list of timer nodes
* through `expire_next' because the normal linked list
* may be changed as a result of callbacks canceling and
* scheduling timeouts, and thus can't be trusted.
*/
/*
* If the timeout is within 1 millisec of current time,
* consider it as expired already. We do this because
* iu_earliest_timer() only has millisec granularity.
* So we should also use millisec grandularity in
* comparing timeout values.
*/
break;
/*
* fringe condition: two timers fire at the "same
* time" (i.e., they're both scheduled called back in
* this loop) and one cancels the other. in this
* case, the timer which has already been "cancelled"
* should not be called back.
*/
if (node->iutn_pending_delete)
continue;
/*
* we remove the timer before calling back the callback
* so that a callback which accidentally tries to cancel
* itself (through whatever means) doesn't succeed.
*/
n_expired++;
}
tq->iutq_in_expire--;
/*
* any cancels that took place whilst we were expiring timeouts
* ended up on the `pending_delete_chain'. delete them now
* that it's safe.
*/
}
return (n_expired);
}
/*
* get_timer_id(): allocates a timer id from the pool
*
* input: iu_tq_t *: the timer queue
* output: iu_timer_id_t: the allocated timer id, or -1 if none available
*/
static iu_timer_id_t
{
unsigned int map_index;
unsigned char map_bit;
for (; ; tq->iutq_next_timer_id++) {
if (have_wrapped)
return (-1);
tq->iutq_next_timer_id = 0;
}
break;
}
return (tq->iutq_next_timer_id++);
}
/*
* release_timer_id(): releases a timer id back into the pool
*
* input: iu_tq_t *: the timer queue
* iu_timer_id_t: the timer id to release
* output: void
*/
static void
{
}