if change date during select ( ), select is hang

if change date during select ( ), select is hang

Post by Lee, Ho-Yu » Thu, 15 May 2003 10:51:37



[problem]

In my code like following, using select() and an application as linked
pthread lib.
If I change date, application*.

(sample code)
#include <stdio.h>
#include <sys/time.h>

int
main()
{
    struct timeval timeout;
    int cnt;

    for(cnt=0;;cnt++) {
#if 1
        timeout.tv_sec  = 5;
        timeout.tv_usec = 0;
        select(0,0,0,0,&timeout);
#else
        sleep(5);
#endif
        printf("[%d] Wakeup \n",cnt);
    }

Quote:}

(compile & link)
cc -o test_sleep test_sleep.c -lpthread

(If I change date at another terminal like "date 0101010102", sample code is
blocked)

I think this problem can solve with some kernel patch.

Somebody help me~ T_T

 
 
 

if change date during select ( ), select is hang

Post by Darren Dunha » Fri, 16 May 2003 01:49:13



> [problem]
> In my code like following, using select() and an application as linked
> pthread lib.
> If I change date, application*.
> (sample code)
> (compile & link)
> cc -o test_sleep test_sleep.c -lpthread
> (If I change date at another terminal like "date 0101010102", sample code is
> blocked)

Was it like that, or was it that?

I don't believe Sun makes any promises about Solaris being stable in the
face of backward timeshifts.  You can completely fill up the TCP socket
table by doing that.

Quote:> I think this problem can solve with some kernel patch.

Why do you need your code to work when the clock goes backward?

--

Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >

 
 
 

if change date during select ( ), select is hang

Post by Lee, Ho-Yu » Fri, 16 May 2003 09:49:25




> > [problem]

> > In my code like following, using select() and an application as linked
> > pthread lib.
> > If I change date, application*.

> > (sample code)
> > (compile & link)
> > cc -o test_sleep test_sleep.c -lpthread

> > (If I change date at another terminal like "date 0101010102", sample
code is
> > blocked)

> Was it like that, or was it that?

was it that.... ^^;

I need study english harder.

Quote:

> I don't believe Sun makes any promises about Solaris being stable in the
> face of backward timeshifts.  You can completely fill up the TCP socket
> table by doing that.

> > I think this problem can solve with some kernel patch.

> Why do you need your code to work when the clock goes backward?

my system using NTP.

if system clock goes fast, NTP will backward the clock.

I'm worry about that.

If that is occured, my application will stoped.

I don't wanna occur*.

> --

> Unix System Administrator                    Taos - The SysAdmin Company
> Got some Dr Pepper?                           San Francisco, CA bay area
>          < This line left intentionally blank to confuse you. >

Thank you for your reply.

PS : Have a good day~

 
 
 

if change date during select ( ), select is hang

Post by Matt Atterbur » Fri, 16 May 2003 12:52:47



> > Why do you need your code to work when the clock goes backward?

> my system using NTP.

> if system clock goes fast, NTP will backward the clock.

> I'm worry about that.

> If that is occured, my application will stoped.

> I don't wanna occur*.

        NTP does not use `date' to change the date (I believe it uses
        adjtime), except possibly when first started (and there are ways
        to avoid a sudden time shift when first starting NTP, which should be
        in the NTP documentation).

        There are -many- applications that use select/poll which work just
        fine with NTP so unless you do something strange you should not have a
        problem.

        m.

 
 
 

if change date during select ( ), select is hang

Post by Darren Dunha » Fri, 16 May 2003 14:54:33



>> > (If I change date at another terminal like "date 0101010102", sample
> code is
>> > blocked)

>> Was it like that, or was it that?
> was it that.... ^^;

I was asking if your "date" string was just a sample, or if you really
set the clock back by over a year?

Quote:

>> I don't believe Sun makes any promises about Solaris being stable in the
>> face of backward timeshifts.  You can completely fill up the TCP socket
>> table by doing that.

>> > I think this problem can solve with some kernel patch.

>> Why do you need your code to work when the clock goes backward?

> my system using NTP.
> if system clock goes fast, NTP will backward the clock.

Maybe by a second or two.  You've set your clock back by over a year.
That's very different.

Do you need to set your clock back by more than a few seconds for any
reason?

--

Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >

 
 
 

if change date during select ( ), select is hang

Post by Lee, Ho-Yu » Fri, 16 May 2003 18:05:08




> >> > (If I change date at another terminal like "date 0101010102", sample
> > code is
> >> > blocked)

> >> Was it like that, or was it that?

> > was it that.... ^^;

> I was asking if your "date" string was just a sample, or if you really
> set the clock back by over a year?

nope. If NTP change system clock, maybe it's just one or two second.
I would not change the clock by "date" command.
NTP will change the system clock.

Quote:

> >> I don't believe Sun makes any promises about Solaris being stable in
the
> >> face of backward timeshifts.  You can completely fill up the TCP socket
> >> table by doing that.

> >> > I think this problem can solve with some kernel patch.

> >> Why do you need your code to work when the clock goes backward?

> > my system using NTP.

> > if system clock goes fast, NTP will backward the clock.

> Maybe by a second or two.  You've set your clock back by over a year.
> That's very different.

> Do you need to set your clock back by more than a few seconds for any
> reason?

No. ^^
I said. I do not need to change the clock.
The clock may change by only the NTP service.
So It maybe different just one or two second.
The problem is NTP can backward the clock.
Then my application will*.

If you compile my sample code and set the clock for backward
during application running, you can understand my problem so easily. ^^

I could not solve this problem.

Thank you for your care.

PS : have a HAPPY day~ ^^

 
 
 

if change date during select ( ), select is hang

Post by Casper H.S. Di » Fri, 16 May 2003 18:28:48



>I said. I do not need to change the clock.
>The clock may change by only the NTP service.

How are you using NTP, then? Generally speaking, NTP will NOT step
the clock backward; it will slow the clock down so real time can
catch up.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

if change date during select ( ), select is hang

Post by Lee, Ho-Yu » Sat, 17 May 2003 15:50:49





> >I said. I do not need to change the clock.
> >The clock may change by only the NTP service.

> How are you using NTP, then? Generally speaking, NTP will NOT step
> the clock backward; it will slow the clock down so real time can
> catch up.

> Casper
> --

Yes. You're right. It's my mistake.
My code use "ntpdate" command.
So it can change the system clock to backward.

Now, can u solve this problem??

PS : have a good day~

 
 
 

if change date during select ( ), select is hang

Post by Hans J?rgen Jakobse » Sat, 17 May 2003 16:55:33






>> >I said. I do not need to change the clock.
>> >The clock may change by only the NTP service.

>> How are you using NTP, then? Generally speaking, NTP will NOT step
>> the clock backward; it will slow the clock down so real time can
>> catch up.

>> Casper
>> --

> Yes. You're right. It's my mistake.
> My code use "ntpdate" command.
> So it can change the system clock to backward.

> Now, can u solve this problem??

"your code" should not be running ntpdate!
The system should be running xntpd (or ntpd) (the daemon version of ntpdate)
(common startup scripts run ntpdate to get the clock within some milliseconds.
Afterwards (x)ntpd takes over and keeps the clock acurate without jumps.)
 
 
 

1. Does select() return if the FD changed before select() was called?

Does a select() call return if the file descriptor it is watching changed
before the select() was called if the file descriptor hasn't been read or
written to since the change? For an illustration:

while ( select() ) {
    //Do some stuff here
    //One of the file descriptors select() watches happens to change right
here
    //Do some more stuff

Will select return on the next while() iteration because of the file
descriptor that changed in the middle of the loop? Or will it only watch for
descriptors that change since the select() call was made, which means my
program would block in select() without noticing the change that happened in
the last loop?

The man page doesn't seem to say much about this.

Also, if anyone can recommend any good books on programming TCP
clients/servers on POSIX and/or Win32 systems I'd appreciate it.

LKembel

2. INN Configuring

3. How does select() function "select"?

4. xterm icon label

5. select field n to last? select last field?

6. Route config for 2 win98 boxes w/linux

7. select() and ignore work, reissue select.

8. Mystery Chip...AMD

9. Invalid Argument during Select Partition screen

10. How to select files between dates in combination with grep

11. Select files with DATE??

12. Select which NIC to use during kickstart?

13. Select files by date and move them