* Make Toolkit compile on WIN32. Affected files in win32/
and in lib/silcutil/win32/.
+ * Changed silc_compare_timeval to return negative, zero or
+ positive instead of just TRUE or FALSE. This fixes 0 timeout
+ task dispatching on Windows. Affected files are
+ lib/silcutil/silctime.[ch] and silcschedule.c.
+
Mon May 7 18:18:48 EEST 2007 Pekka Riikonen <priikone@silcnet.org>
* Fixed CMODE channel auth public key retrieval. Affected
***/
#define SILC_FSM_CALL(function) \
do { \
- assert(!silc_fsm_set_call(fsm, TRUE)); \
+ SILC_ASSERT(!silc_fsm_set_call(fsm, TRUE)); \
function; \
if (!silc_fsm_set_call(fsm, FALSE)) \
return SILC_FSM_CONTINUE; \
}
/* Execute the task if the timeout has expired */
- if (!silc_compare_timeval(&task->timeout, &curtime) && !dispatch_all)
+ if (silc_compare_timeval(&task->timeout, &curtime) > 0 && !dispatch_all)
break;
t->valid = FALSE;
/* If the timeout is in past, we will run the task and all other
timeout tasks from the past. */
- if (silc_compare_timeval(&task->timeout, &curtime) && dispatch) {
+ if (silc_compare_timeval(&task->timeout, &curtime) <= 0 && dispatch) {
silc_schedule_dispatch_timeout(schedule, FALSE);
if (silc_unlikely(!schedule->valid))
return;
prev = NULL;
while ((tmp = silc_list_get(list)) != SILC_LIST_END) {
/* If we have shorter timeout, we have found our spot */
- if (silc_compare_timeval(&ttask->timeout, &tmp->timeout)) {
+ if (silc_compare_timeval(&ttask->timeout, &tmp->timeout) < 0) {
silc_list_insert(schedule->timeout_queue, prev, ttask);
break;
}
/* Return TRUE if `smaller' is smaller than `bigger'. */
-SilcBool silc_compare_timeval(struct timeval *smaller,
- struct timeval *bigger)
+int silc_compare_timeval(struct timeval *t1, struct timeval *t2)
{
- if ((smaller->tv_sec < bigger->tv_sec) ||
- ((smaller->tv_sec == bigger->tv_sec) &&
- (smaller->tv_usec < bigger->tv_usec)))
- return TRUE;
-
- return FALSE;
+ SilcInt32 s = t1->tv_sec - t2->tv_sec;
+ if (!s)
+ return t1->tv_usec - t2->tv_usec;
+ return s;
}
*
* SYNOPSIS
*
- * SilcBool silc_compare_timeval(struct time_val *smaller,
- * struct time_val *bigger)
+ * int silc_compare_timeval(struct time_val *t1, struct time_val *t2);
*
* DESCRIPTION
*
- * Compare two timeval structures and return TRUE if the first
- * time value is smaller than the second time value.
+ * Compares `t1' and `t2' time structures and returns less than zero,
+ * zero or more than zero when `t1' is smaller, equal or bigger than
+ * `t2', respectively.
*
***/
-SilcBool silc_compare_timeval(struct timeval *smaller,
- struct timeval *bigger);
+int silc_compare_timeval(struct timeval *t1, struct timeval *t2);
/****f* silcutil/SilcTimeAPI/silc_gettimeofday
*
/* If we have passed the rate time limit, set our new time limit,
and zero the rate limit. This limits reads per second. */
silc_gettimeofday(&curtime);
- if (!silc_compare_timeval(&curtime, &sock->qos->next_limit)) {
+ if (silc_compare_timeval(&curtime, &sock->qos->next_limit) > 0) {
curtime.tv_sec++;
sock->qos->next_limit = curtime;
sock->qos->cur_rate = 0;