< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

Re: [reSIProcate] Stun.cxx sleep code


On 3/8/06, Matthias Moetje - TERASENS GmbH <moetje@xxxxxxxxxxxx> wrote:
> Hi,
>
> I just came across the following piece of code in
> Stun.cxx:
>
>    sendMessage( myFd, buf, len, dest.addr, dest.port, verbose );
>
>    // add some delay so the packets don't get sent too quickly
> #ifdef WIN32 // !cj! TODO - should fix this up in windows
>                  clock_t now = clock();
>                  assert( CLOCKS_PER_SEC == 1000 );
>                  while ( clock() <= now+10 ) { };
> #else
>                  usleep(10*1000);
> #endif
>
> }
>
>
> 1. It seems that the code will cause a pause of 10ms
> on Windows (with 100% CPU activity) and a pause of 10s
> on all other platforms. On Windows Sleep(xx) could be
> used, too.
>
> 2. Why is this pause needed at all? Afterwards a recvfrom
> is usually done which blocks until reception anyway..
>
> Any reasons for not removing the whole pause stuff?
>

I think we can just remove this.