The putback for 6565503 "callout processing is single threaded, throttling
applications that rely on scalable callouts" in build 103 apparently has
changed the kernel function cv_waituntil_sig() to create callouts with
a new flag CALLOUT_FLAG_HRESTIME.  This flag is described in
uts/common/sys/callo.h as:

 * CALLOUT_FLAG_HRESTIME
 *      Normally, callouts are not affected by changes to system time
 *      (hrestime). This flag is used to create a callout that is affected
 *      by system time. If system time changes, these timers must expire
 *      at once. These are used by condition variables and LWP timers that
 *      need this behavior.

cv_waituntil_sig() is used with several system calls (poll() / select() /
sigtimedwait(), semtimedop(), ...).  What I'm observing is that with
build 103 or newer all of these system calls return prematurely -
before the timeout expires - when the system time is set (e.g. by
ntp / ntpdate or rdate).

Test cases are:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int
main(int argc, char **argv)
{
        struct timeval  tv;
        int             i;

        tv.tv_sec = 250;
        tv.tv_usec = 0;
        i = select(0, NULL, NULL, NULL, &tv);
        if (i < 0) {
                perror("select");
                exit(1);
        }
        printf("select returned %d\n", i);
        exit(0);
}

-----------------------------------------------

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>

int
main(int argc, char **argv)
{
        sigset_t set;
        siginfo_t info;
        struct timespec tmout;

        sigemptyset(&set);
        sigaddset(&set, SIGALRM);
        tmout.tv_sec = 250;
        tmout.tv_nsec = 0;
        sigtimedwait(&set, &info, &tmout);
}


-----------------------------------------------

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>


int
main(int argc, char **argv)
{
        int sem;
        struct sembuf ops[1];
        struct timespec ts;

        sem = semget(IPC_PRIVATE, 1, 0600);
        if (sem < 0) {
                perror("semget");
                exit(1);
        }
        ops[0].sem_num = 0;
        ops[0].sem_op = -1;
        ops[0].sem_flg = 0;

        ts.tv_sec = 250;
        ts.tv_nsec = 0;
        semtimedop(sem, ops, 1, &ts);
}



If you start any one of these on build 103 or newer
and run "rdate {time-server}" or set the date with
"date HHMM" in another window, the system call
gets a timeout and the program terminates.
Expected behavior would be that these programs
wait 250 seconds for some event, and changing
the system clock does not affect waiting.

Is this a bug or a feature of 6565503?


Btw. the changed timeout for poll() behavior did break hald:

    Bug ID: 6792302
    Synopsis: hald occasionally exits on startup with status 2
    http://bugs.opensolaris.org/view_bug.do?bug_id=6792302
-- 
This message posted from opensolaris.org
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to