select(2) ignoring timeval argument (Full Version)

All Forums >> [SFU / Interix / SUA Technology] >> Windows Server 2003 R2 SUA



Message


breiter -> select(2) ignoring timeval argument (Mar. 11, '06, 9:37:02 PM)

When I upgraded to SUA/Interix 5.2, I installed xgalaga. Which is frivolous, I know. The thing is that it works fine on SFU/Interix 3.5 but runs crazy-fast on SUA/Interix 5.2. The entire thing is a blur.

I pinged Rodney on this and he mentioned that xgalaga uses select(2) to throttle its speed. Thinking maybe I just needed to change the timing, I downloaded grabbed the xgalaga source code. Building it myself didn't help. I looked at documentation of select(2).

From man 2 select:

If timeout is a non-nil pointer, it specifies a maximum interval to wait
for the selection to complete. If timeout is a nil pointer, the select
blocks indefinitely. To effect a poll, the timeout argument should be non-
nil, pointing to a zero-valued timeval structure.

I injected this code at the end of the while(1) loop.

//insert a 10 second pause on every loop to test select().
struct timeval pause;
gettimeofday(&pause, 0);
printf("Get pause time: %d\n", pause.tv_sec);
pause.tv_sec += 10L;
printf("Add 10 seconds: %d\n", pause.tv_sec);
(void) select(0, 0, 0, 0, &pause);

This is the kind of output I get while xgalaga is running.

Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343
Get pause time: 1142130333
Add 10 seconds: 1142130343

No pause happened when select was called, so we're on the same second when the next loop iteration comes around. I think there is something very wrong here. Select(2) seems to be ignoring the timeval pause.




Rodney -> RE: select(2) ignoring timeval argument (Mar. 12, '06, 2:57:57 PM)

mmmm, we're starting to build up quite a selection of things with SUA.
1) Select timer ignored (mentioned above)
2) The SetUid problem (mentioned by Brian in another thread)
3) The AF_UNIX sockets have had the namespace shrunk from 104 to 14 characters.




breiter -> RE: select(2) ignoring timeval argument (Mar. 15, '06, 10:00:57 AM)

Here's a very simple test program that demonstrates the select(2) timeout problem in isolation:


#include <stdio.h>
#include <sys/time.h>

int main()
{
        struct timeval time;
        int i=0;
        printf("Testing select(2). Each pass through the loop should pause 10 seconds.\n\n");
        for( i; i<10; i++ )
        {
                //insert a 10 second pause on every loop to test select().              
                gettimeofday(&time, 0);
                printf("Current time: %d\n", time.tv_sec);
                time.tv_sec += 10L;
                printf("Add 10 seconds: %d... And pause by calling select(2).\n", time.tv_sec);
                (void) select(0, 0, 0, 0, &time); 
    }
        return 0;
}


% gcc selecttest.c -o selecttest
% ./selecttest
Testing select(2). Each pass through the loop should pause 10 seconds.

Current time: 1142434664
Add 10 seconds: 1142434674... And pause by calling select(2).
Current time: 1142434664
Add 10 seconds: 1142434674... And pause by calling select(2).
Current time: 1142434664
Add 10 seconds: 1142434674... And pause by calling select(2).
Current time: 1142434664
Add 10 seconds: 1142434674... And pause by calling select(2).
Current time: 1142434664
Add 10 seconds: 1142434674... And pause by calling select(2).
Current time: 1142434664
Add 10 seconds: 1142434674... And pause by calling select(2).
Current time: 1142434664
Add 10 seconds: 1142434674... And pause by calling select(2).
Current time: 1142434664
Add 10 seconds: 1142434674... And pause by calling select(2).
Current time: 1142434664
Add 10 seconds: 1142434674... And pause by calling select(2).
Current time: 1142434664
Add 10 seconds: 1142434674... And pause by calling select(2).




Page: [1]



Forum Software © ASPPlayground.NET Advanced Edition 2.5 ANSI

0.031