Commit Graph

71 Commits

Author SHA1 Message Date
75ea1b6ea1 Fix formatting of new(std::nothrow)
The code previously formatted everything as `new( std::nothrow)`.
2018-10-04 21:50:44 +03:00
268e689dc5 Fix code for warnings: unused-but-set-variable and warn_unused_result. 2018-10-03 16:33:24 +03:00
75f9921ca2 Merge branch '2.2' into develop 2018-10-02 10:18:09 +03:00
c65edd1298 Enhance StopWatch
Clean up, comments and enhancements. StopWatch lap() didn't mean lap-time, but elapsed time. Changed meaning to lap-time and added split() for split-time.
2018-10-01 09:30:24 +03:00
df3d08b959 Remove spammy debug print
The code was ran even when nothing was really going on and constantly wrote
to the log.
2018-09-26 14:03:08 +03:00
1063b4a6be Add missing cancel callback for delayed call.
And make the function a little neater.
2018-09-26 11:21:55 +03:00
5132339b7b Fix race condition.
Change a counter (s_next_delayed_call_id) in Worker from class static to
class member to avoid race conditions on the variable.
2018-09-25 17:07:06 +03:00
6d82de811f Relax Average value access memory ordering
As there are no requirements with regards to the visibility of writes to
the Average, the access can be relaxed.
2018-09-24 12:07:50 +03:00
a94081067f Move Average into average.hh
Moved the class to a more appropriate place.
2018-09-24 12:07:49 +03:00
5ed3667f4a Document average.hh
Add documentation for the average classes.
2018-09-24 12:07:49 +03:00
71ffef5708 Partially revert 4ba011266843857bbd3201e5b925a47e88e1808f
Add back leading operator enforcement.
2018-09-20 15:57:30 +03:00
2e069fa892 MXS-1632: Take mxb::atomic::add into use
The function now mostly replaces the use of atomic_add_ functions declared
in atomic.h.
2018-09-18 15:21:54 +03:00
4d792c3410 MXS-1632: Add C++ wrappers for __atomic builtins
Using the __atomic functions makes it easy to increment fundamental types
atomically without converting them to std::atomic<T>.
2018-09-18 15:21:54 +03:00
9b0f016aba Fix minor formatting oversights
Code that was not formatted was merged into develop unformatted.
2018-09-12 08:58:15 +03:00
6938df0d62 Use default member initializers in WORKER_STATISTICS
Makes the class simpler and removes the need for an explicit
constructor. Also switched to std::array to enable easy iteration over the
array.
2018-09-10 14:15:10 +03:00
94a567f4ca Remove redundant Worker method
The Worker::get_local_statistics was a duplicate of Worker::statistics.
2018-09-10 14:14:21 +03:00
108638b0cf Format with Uncrustify 0.67 2018-09-10 13:31:39 +03:00
d11c78ad80 Format all sources with Uncrustify
Formatted all sources and manually tuned some files to make the code look
neater.
2018-09-10 13:22:49 +03:00
c447e5cf15 Uncrustify maxscale
See script directory for method. The script to run in the top level
MaxScale directory is called maxscale-uncrustify.sh, which uses
another script, list-src, from the same directory (so you need to set
your PATH). The uncrustify version was 0.66.
2018-09-09 22:26:19 +03:00
fa7ec95069 MXS-1777 Tune code for cases with slow, or new servers.
Changes that allow slow or new servers to quickly apply samples towards the
server average. The most important changes are to not ignore the first N samples,
and apply an average to the server as soon as there is one available.
The new ResponseStat::make_valid() will use filter samples to add an average,
if no averages have yet been added, even if the number of  filter samples is less
than the filter limit.
2018-09-09 14:17:40 +03:00
d52885d68d MXS-1777 Cosmetic changes based on code reviews. 2018-09-05 17:05:06 +03:00
1e6509423a MXS-1777: Add an EMAverage to the server struct, and a new slave selection criteria.
This is to support calculating the average from a session, and the slave selection criteria to be able to route based on averages. This commit, like the next one, have TODOs which you should feel free to comment on. Undecided things.
2018-09-05 17:05:06 +03:00
cdea8aa7be mxs-1777: maxutils additions
Adding classes for calculating averages. Update StopWatch to C++11.
2018-09-05 17:05:06 +03:00
0afcfd7719 Link maxbase tests against rt
The logging requires it.
2018-08-31 09:32:07 +03:00
e2ba7151b7 MXS-2008 Enforce right initialization of maxbase
Now maxbase can only be initialized via maxbase::init().
2018-08-21 14:35:51 +03:00
24ab3c099c Move top of the file "#pragma once" to after the following comment (swap them). If the comment is a BPL update it to the latest one 2018-08-21 13:13:15 +03:00
e852dcacdd MXS-2008 Provide single entrypoint for initializing maxbase
Everything of maxbase can now be initialized by a call to

    maxbase_init();

(from a C-program) or

    maxbase::init();

from a C++-program and finalized with calls to either
maxbase_finish() or maxbase::finish(). Creating an instance
maxbase::MaxBase will take care of both operations.
2018-08-21 10:02:39 +03:00
88f1795412 MXS-2008 Move Worker and MessageQueue to maxbase 2018-08-21 10:02:39 +03:00
355768c564 Add overloads to dump_stacktrace
Using a function while debugging helps to see where various functions are
called from.
2018-08-20 13:56:59 +03:00
0685276764 Use correct functions in maxutils CMake files
The headers and the static library were installed unconditionally.
2018-08-20 13:56:58 +03:00
40a5ae81c7 MXS-2008 Store worker as MXB_WORKER* and not void* 2018-08-20 11:15:14 +03:00
e0cb11151f MXS-2008 Move maxscale/worker.h to maxbase/worker.h 2018-08-20 11:15:14 +03:00
932956d5f6 MXS-2008 Add maxbase/poll.[h|hh]
Remove maxscale/poll_core.h
2018-08-20 11:15:14 +03:00
aaad63ee5e MXS-2008 Move content of maxscale/platform.h to maxbase/cdefs.h
No good reason for keeping that platform adjustments anywhere
else but in cdefs.h.
2018-08-20 11:15:14 +03:00
9510a3ae1a Use normal asserts in log.cc
The logger can't use the asserts that log messages as it introduces a
cyclical dependency on the logger itself.
2018-08-17 18:09:51 +03:00
9b199cfb50 Remove duplicate CMakeLists.txt entry
maxutils/maxbase/src/test/CMakeLists.txt
2018-08-17 16:21:58 +03:00
b82822a4b0 MXS-2017 Move maxscale::Semaphore to maxbase::Semaphore 2018-08-17 15:57:44 +03:00
d8255d0cac MXS-2017 Move maxscale::Semaphore to maxbase::Semaphore 2018-08-17 15:53:54 +03:00
25c81b118d Rename conflicting test 2018-08-17 15:02:03 +03:00
f09afa2967 Combine regression test suite and main CMake projects
Combining the projects makes it easier to use common components. This
fixes the build failure of maxutils due to missing jansson definitions.
2018-08-17 14:29:28 +03:00
c7a6d75ab9 MXS-2014 Address review issues 2018-08-17 10:59:37 +03:00
15bf481120 MXS-2014 Allow the header and footer to be adjusted 2018-08-17 10:59:37 +03:00
4388b8517e MXS-2014 Use standard assert in Logger 2018-08-17 10:59:37 +03:00
cfdfff46ae MXS-2014 Add skeleton test for mxb::Log 2018-08-17 10:59:37 +03:00
12e8f28907 MXS-2014 Add mxb::Log class for convenience
In tests, the log can now be setup as

    int main()
    {
        mxb::Log log;
        ...
    }

That will initialize the log so that it logs to a file called
<program-name>.log in the current directory and finalize it
when the program exits.
2018-08-17 10:59:37 +03:00
be986d366a MXS-2014 Handle default OOM message properly 2018-08-17 10:59:37 +03:00
876cf7c86f MXS-2014 Temporarily fix broken token pasting 2018-08-16 11:24:01 +03:00
19684deb69 MXS-2014 Init and finish properly
If any part of initalization fails, no resources are held.
At finalization, release all resources.

Also re-implement recent changes made to log_manager.cc that
did not automatically move over to log.cc.
2018-08-16 11:09:30 +03:00
a586aa13c4 MXS-2014 Add proper OOM support
Not that I think it ever will be needed...
2018-08-16 09:59:43 +03:00
85b68c439a MXS-2014 Still more cleanup of maxbase/log.h 2018-08-16 09:59:43 +03:00