[OpenSIPS-Devel] [OpenSIPS/opensips] 656a87: Fix bad subtraction algorithm in get_time_diff()

Liviu Chircu noreply at github.com
Wed Feb 15 18:21:20 UTC 2023


  Branch: refs/heads/master
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 656a875b5b81c0c5f60d799f8c5ce4f165803547
      https://github.com/OpenSIPS/opensips/commit/656a875b5b81c0c5f60d799f8c5ce4f165803547
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2023-02-15 (Wed, 15 Feb 2023)

  Changed paths:
    M ut.h

  Log Message:
  -----------
  Fix bad subtraction algorithm in get_time_diff()

The gettimeofday(2) function actually returns the .usec as a *relative*
value instead of absolute one, as can be seen below, hence it is
incorrect to subtract the @begin.tv_usec field from the @end.tv_usec@
field, as this can lead to a negative number!

1676481011 893759
1676481012 144123
1676481012 394239
1676481012 644397
1676481012 894537
1676481013 144690
1676481013 394849
1676481013 644960
1676481013 895110
1676481014 145278
1676481014 395429
...

This will potentially fix occasional false-positive "processing
threshold exceeded" alerts (e.g. SIP, DNS, TCP, etc.), especially when
dealing with sub-second time differentials!

PS: the fact that this function is limited to measuring a time diff of
2147 seconds is best left for another commit...





More information about the Devel mailing list