This is an automated email from the git hooks/post-receive script.
mreynolds pushed a commit to branch 389-ds-base-1.3.10
in repository 389-ds-base.
commit f919952d2a75c1c1328236752d616686b44efe39
Author: Thierry Bordaz <tbordaz(a)redhat.com>
AuthorDate: Tue Jul 23 13:59:01 2019 +0200
Ticket 50510 - etime can contain invalid nanosecond value
Bug Description:
When computing the etime, it takes into account the nanosecond.
At border of a second, the ending nsec can be lower than starting nsec.
In such case the computation is wrong as delta=(ending_nsec - starting_nsec) is
negative.
final_nsec = 1 - delta > 1sec
Fix Description:
if delta=(ending_nsec - starting_nsec) is negative
final_nsec = 1 + delta < 1sec
https://pagure.io/389-ds-base/issue/50510
Reviewed by: Mark Reynolds (Thanks!)
Platforms tested: F28
Flag Day: no
Doc impact: no
---
dirsrvtests/tests/suites/ds_logs/ds_logs_test.py | 44 ++++++++++++++++++++++++
ldap/servers/slapd/time.c | 6 ++--
2 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py
b/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py
index fb73a22..6f1e93c 100644
--- a/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py
+++ b/dirsrvtests/tests/suites/ds_logs/ds_logs_test.py
@@ -186,7 +186,51 @@ def test_log_plugin_off(topology_st):
assert len(access_log_lines) > 0
assert not topology_st.standalone.ds_access_log.match('^\[.+\d{9}.+\].+')
+(a)pytest.mark.bz1732053
+(a)pytest.mark.ds50510
+def test_etime_at_border_of_second(topology_st):
+ topo = topology_st.standalone
+ # be sure to analyze only the following rapid OPs
+ topo.stop()
+ os.remove(topo.accesslog)
+ topo.start()
+
+ prog = os.path.join(topo.ds_paths.bin_dir, 'rsearch')
+
+ cmd = [prog]
+
+ # base search
+ cmd.extend(['-s', DN_CONFIG])
+
+ # scope of the search
+ cmd.extend(['-S', '0'])
+
+ # host / port
+ cmd.extend(['-h', HOST_STANDALONE])
+ cmd.extend(['-p', str(PORT_STANDALONE)])
+
+ # bound as DM to make it faster
+ cmd.extend(['-D', DN_DM])
+ cmd.extend(['-w', PASSWORD])
+
+ # filter
+ cmd.extend(['-f', "(cn=config)"])
+
+ # 2 samples SRCH
+ cmd.extend(['-C', "2"])
+
+ output = subprocess.check_output(cmd)
+ topo.stop()
+
+ # No etime with 0.199xxx (everything should be few ms)
+ invalid_etime = topo.ds_access_log.match(r'.*etime=0\.19.*')
+ if invalid_etime:
+ for i in range(len(invalid_etime)):
+ log.error('It remains invalid or weird etime: %s' %
invalid_etime[i])
+ assert not invalid_etime
+
+
if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
diff --git a/ldap/servers/slapd/time.c b/ldap/servers/slapd/time.c
index 584bd1e..8048a33 100644
--- a/ldap/servers/slapd/time.c
+++ b/ldap/servers/slapd/time.c
@@ -235,8 +235,10 @@ slapi_timespec_diff(struct timespec *a, struct timespec *b, struct
timespec *dif
if (nsec < 0) {
/* It's negative so take one second */
sec -= 1;
- /* And set nsec to to a whole value */
- nsec = 1000000000 - nsec;
+ /* And set nsec to to a whole value
+ * nsec is negative => nsec = 1s - abs(nsec)
+ */
+ nsec = 1000000000 + nsec;
}
diff->tv_sec = sec;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.