Re: setitimer, small delta and XNU

Paolo Bonzini <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.gnu.general
Message-ID <[email protected]>

On 15/04/2015 22:25, Holger Freyther wrote:
> this means deltaMilli will be 0 which leads to us “canceling” the timer instead
> of setting it. My workaround is to make sure that tv_usec is never zero. Is this
> acceptable? E.g. something like this?
> 
> diff --git a/libgst/sysdep/posix/timer.c b/libgst/sysdep/posix/timer.c
> index c47ae91..10e0e92 100644
> --- a/libgst/sysdep/posix/timer.c
> +++ b/libgst/sysdep/posix/timer.c
> @@ -121,8 +121,16 @@ _gst_sigalrm_at (int64_t nsTime)
>       struct itimerval value;
> 
>       value.it_interval.tv_sec = value.it_interval.tv_usec = 0;
> -      value.it_value.tv_sec = deltaMilli / 1000;
> -      value.it_value.tv_usec = (deltaMilli % 1000) * 1000;
> +      if (deltaMilli)
> +        {
> +          value.it_value.tv_sec = deltaMilli / 1000;
> +          value.it_value.tv_usec = (deltaMilli % 1000) * 1000;
> +        }
> +      else
> +        {
> +          value.it_value.tv_sec = 0;
> +          value.it_value.tv_usec = 1;
> +        }
>       setitimer (ITIMER_REAL, &value, (struct itimerval *) 0);
>     }
> }
> 
> 

Yes, certainly!

Paolo

_______________________________________________
help-smalltalk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.