tests/mock_event_handler.c
int wait_random (const char *msg)
{
  #define HALF_SEC 500000l
  long delay = (random() >> 5) + 60000000l;
  long secs, usecs;
  struct timeval timeout;

  secs = delay / 1000000;
  usecs = delay % 1000000;
  ParodusInfo ("Waiting %ld secs %ld usecs for %s\n", secs, usecs, msg);
  
  while (!g_shutdown) {
	timeout.tv_sec = 0;
	if (delay <= HALF_SEC) {
	  timeout.tv_usec = delay;
	  select (0, NULL, NULL, NULL, &timeout);
	  return 0;
	}
	timeout.tv_usec = HALF_SEC;
	delay -= HALF_SEC;
	select (0, NULL, NULL, NULL, &timeout);
  }
  return -1;    
}
// waits from 60 to 124 secs
waits from 60 to 124 secs
waits from 60 to 124 secs
int wait_random (const char *msg)
{
  #define HALF_SEC 500000l
  long delay = (random() >> 5) + 60000000l;
  long secs, usecs;
  struct timeval timeout;
  secs = delay / 1000000;
  usecs = delay % 1000000;
  ParodusInfo ("Waiting %ld secs %ld usecs for %s\n", secs, usecs, msg);
  while (!g_shutdown) {
	timeout.tv_sec = 0;
	if (delay <= HALF_SEC) {
	  timeout.tv_usec = delay;
	  select (0, NULL, NULL, NULL, &timeout);
	  return 0;
	}
	timeout.tv_usec = HALF_SEC;
	delay -= HALF_SEC;
	select (0, NULL, NULL, NULL, &timeout);
  }
  return -1;    
}
int wait_random ( const char * msg ) { #define HALF_SEC  500000l long delay = ( random ( ) >> 5 ) + 60000000l ; long secs , usecs ; struct timeval timeout ; secs = delay / 1000000 ; usecs = delay % 1000000 ; ParodusInfo ( " \n " , secs , usecs , msg ) ; while ( ! g_shutdown ) { timeout . tv_sec = 0 ; if ( delay <= HALF_SEC ) { timeout . tv_usec = delay ; select ( 0 , NULL , NULL , NULL , & timeout ) ; return 0 ; } timeout . tv_usec = HALF_SEC ; delay -= HALF_SEC ; select ( 0 , NULL , NULL , NULL , & timeout ) ; } return -1 ; }
waits from 60 to 124 secs
waits from 60 to 124 secs