[lttng-dev] [PATCH lttng-tools v2] Fix: timeout for connect is not respected

2018-11-09 Thread Jonathan Rajotte
Problem: The previous algorithm was not *wrong* but was prone to C type conversion error. Previous algorithm: ((A.sec - B.sec) * MSEC_PER_SEC) + ((A.nsec - B.nsec) / NSEC_PER_SEC) ((A.sec - B.sec) * 100ULL) + ((A.nsec - B.nsec) / 100ULL) Note that "(A.nsec - B.nsec)" can be negative.

Re: [lttng-dev] [PATCH lttng-tools v2] Fix: timeout for connect is not respected

2018-11-09 Thread Mathieu Desnoyers
- On Nov 9, 2018, at 10:37 AM, Jonathan Rajotte jonathan.rajotte-jul...@efficios.com wrote: > Problem: > > The previous algorithm was not *wrong* but was prone to C type conversion > error. > > Previous algorithm: > > ((A.sec - B.sec) * MSEC_PER_SEC) + ((A.nsec - B.nsec) / NSEC_PER_SEC) >

Re: [lttng-dev] [PATCH lttng-tools v2] Fix: timeout for connect is not respected

2018-11-09 Thread Jonathan Rajotte-Julien
> > diff --git a/src/common/sessiond-comm/inet.c > > b/src/common/sessiond-comm/inet.c > > index e0b3e7a96..94a3c3a67 100644 > > --- a/src/common/sessiond-comm/inet.c > > +++ b/src/common/sessiond-comm/inet.c > > @@ -119,16 +119,28 @@ static > > unsigned long time_diff_ms(struct timespec *time_a,

[lttng-dev] [PATCH lttng-tools v3] Fix: timeout for connect is not respected

2018-11-09 Thread Jonathan Rajotte
Problem: The previous algorithm was not *wrong* but was prone to C type conversion error. Previous algorithm: ((A.sec - B.sec) * MSEC_PER_SEC) + ((A.nsec - B.nsec) / NSEC_PER_SEC) ((A.sec - B.sec) * 100ULL) + ((A.nsec - B.nsec) / 100ULL) Note that "(A.nsec - B.nsec)" can be negative.

Re: [lttng-dev] [PATCH lttng-tools v2] Fix: timeout for connect is not respected

2018-11-09 Thread Mathieu Desnoyers
- On Nov 9, 2018, at 1:52 PM, Jonathan Rajotte jonathan.rajotte-jul...@efficios.com wrote: >> > diff --git a/src/common/sessiond-comm/inet.c >> > b/src/common/sessiond-comm/inet.c >> > index e0b3e7a96..94a3c3a67 100644 >> > --- a/src/common/sessiond-comm/inet.c >> > +++ b/src/common/sessiond

[lttng-dev] [PATCH lttng-tools 2/2] Fix: max_t/min_t macros are missing cast on input

2018-11-09 Thread Mathieu Desnoyers
The semantic expected from max_t and min_t is to perform the max/min comparison in the type provided as first parameter. Cast the input parameters to the proper type before comparing them, rather than after. There is no more need to cast the result of the expression now that both inputs are cast t

[lttng-dev] [PATCH lttng-tools 1/2] Fix: Connect timeout arithmetic in inet/inet6

2018-11-09 Thread Mathieu Desnoyers
The nanoseconds part of the timespec struct time_a is not always bigger than time_b since it wrap around each seconds. Use 64-bit arithmetic to perform the difference. Merge/move duplicated code into utils.c. This function is really doing two things. Split it into timespec_to_ms() and timespec_a

Re: [lttng-dev] [PATCH lttng-tools 1/2] Fix: Connect timeout arithmetic in inet/inet6

2018-11-09 Thread Jonathan Rajotte-Julien
On Fri, Nov 09, 2018 at 05:27:48PM -0500, Mathieu Desnoyers wrote: > The nanoseconds part of the timespec struct time_a is not always > bigger than time_b since it wrap around each seconds. > > Use 64-bit arithmetic to perform the difference. > > Merge/move duplicated code into utils.c. > > This

[lttng-dev] [PATCH lttng-tools 2/2] Fix: max_t/min_t macros are missing cast on input

2018-11-09 Thread Mathieu Desnoyers
The semantic expected from max_t and min_t is to perform the max/min comparison in the type provided as first parameter. Cast the input parameters to the proper type before comparing them, rather than after. There is no more need to cast the result of the expression now that both inputs are cast t

[lttng-dev] [PATCH lttng-tools 1/2] Fix: Connect timeout arithmetic in inet/inet6 (v2)

2018-11-09 Thread Mathieu Desnoyers
The nanoseconds part of the timespec struct time_a is not always bigger than time_b since it wrap around each seconds. Use 64-bit arithmetic to perform the difference. Merge/move duplicated code into utils.c. This function is really doing two things. Split it into timespec_to_ms() and timespec_a

Re: [lttng-dev] [PATCH lttng-tools 1/2] Fix: Connect timeout arithmetic in inet/inet6

2018-11-09 Thread Mathieu Desnoyers
- On Nov 9, 2018, at 5:34 PM, Jonathan Rajotte jonathan.rajotte-jul...@efficios.com wrote: [...] >> + >> +LTTNG_HIDDEN >> +struct timespec timespec_abs_diff(struct timespec t1, struct timespec t2) >> +{ >> +uint64_t ts1 = (uint64_t) t1.tv_sec * INT64_C(10) + (uint64_t) >> t1.tv_

Re: [lttng-dev] [PATCH lttng-tools 1/2] Fix: Connect timeout arithmetic in inet/inet6 (v2)

2018-11-09 Thread Jonathan Rajotte-Julien
As discussed on IRC, could you make sure to test it manually at least once since the problematic scenario is never tested by regression test. Looks much better than my first attempt but we never know. You can force delay locally using tc. Something like: LTTNG_NETWORK_SOCKET_TIMEOUT=4000 ltt

Re: [lttng-dev] [PATCH lttng-tools 1/2] Fix: Connect timeout arithmetic in inet/inet6 (v2)

2018-11-09 Thread Jonathan Rajotte-Julien
> diff --git a/src/common/utils.c b/src/common/utils.c > index 3442bef8..5b4e1d3c 100644 > --- a/src/common/utils.c > +++ b/src/common/utils.c > @@ -31,6 +31,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -41,6 +42,7 @@ > > #include "utils.h" > #in