210 Commits

Author SHA1 Message Date
Johan Wikman
6870d77acb Fix set_user prototype. 2015-12-07 14:14:42 +02:00
Markus Makela
f62ff4c551 Fixed spelling mistake in usage output.
Path was spelled as apth.
2015-12-04 17:47:14 +02:00
Johan Wikman
ecb5ae528c Reindented server/core/gateway.c 2015-11-30 13:40:56 +02:00
Johan Wikman
5fa3ef8236 Allow logging to shared memory to be enabled in config file.
Earlier, by default, the error and message logfiles were written to
the filesystem and trace and debug logfiles to shared memory. Now,
with just one log-file the default must be the file-system. However,
if info and debug messages are logged, then the filesystem will
become a bottle-neck.

A reasonable approach is then as follows (in the config file)

syslog=true
maxlog=false
log_to_shm=true

With this set, the maxlog file will be created to shared memory, but
nothing will be written to it, since it is disabled. However, if there
is a need to investigate something, then a dba can from maxadmin turn
on maxlog logging and also enable info and debug messages. That is, it
will be possible to enable debugging output without restarting maxscale.

Incidentally, the way the config file and command line arguments are
handled should be rewritten. Currently, it is a mess.
2015-11-29 21:03:05 +02:00
Johan Wikman
384029c109 MaxScale log called consistently for maxlog
There were some variance regarding the way the MaxScale log (i.e.
the file log) was called; "maxlog" in configuration file and
"maxscalelog" at the command line and maxadmin interface. Now it
is uniformly referred to as "maxlog" in the configuration file, at
the command line, from maxadmin and in the code.
2015-11-27 16:10:37 +02:00
Johan Wikman
916ee5ff2a Rename some log concepts
The mxs prefix is now uniformly used with all log components.
2015-11-26 17:34:53 +02:00
Markus Makela
038877b8db Fixed minor format errors and resource leaks
Some format strings used integer values for unsigned integers.
Memory and file descriptors leaked in some error conditions.
2015-11-25 12:43:49 +02:00
Markus Makela
c6982b863a Added missing initialization of values
A call to localtime_r was done with an uninitialized time_t value.
2015-11-23 18:33:59 +02:00
Johan Wikman
6164b7f301 Fixed unsafe use of localtime
Since localtime is not thread-safe it should not be used in multithreaded
contexts. For this reason all calls to localtime were changed to localtime_r
in code where concurrency issues were possible.

Internal tests were left unchanged because they aren't multithreaded.
2015-11-19 17:17:16 +02:00
Johan Wikman
6613723a1f Update error message when startup fails
Claiming that the loading of maxscale.cnf failed in case of any
error was misleading. Maxscale may not succeed in opening it,
reading it or processing it.
2015-11-19 09:28:14 +02:00
Johan Wikman
44df53d846 LOGIF and skygw_write_log removed from server/core/*.c
LOGIF and skygw_write_log removed from server/core/*.c and
replaced with calls to MXS_(ERROR|WARNING|NOTICE|INFO|DEBUG).
This is a mechanism change, no updating of the actual message
has been performed.

Currently this causes a very small performance hit, since the
check whether the priority is enabled or not is performed in
the function that is called and not before the function is called.
Once all LOGIFs and skygw_write_logs have been replaced, the
behaviour will be altered back to what it was.
2015-11-16 09:49:12 +02:00
Johan Wikman
2c1b53c120 Log: Cleanup of API
skygw_ functions removed and replaced with mxs_ equivalents.
logfile_id_t removed.
2015-11-12 18:31:53 +02:00
Johan Wikman
05fbdb1b76 Log: skygw_log_flush replaced with mxs_log_flush.
skygw_log_flush replaced with mxs_log_flush and skygw_log_sync_all
with mxs_log_flush_sync.
2015-11-12 18:28:34 +02:00
Johan Wikman
c7a329e43e Log: skygw_logmanager_init renamed to mxs_log_init.
skygw_logmanager_init renamed to mxs_log_init and skygw_logmanager_done
renamed to mxs_log_finish. skygw_logmanager_exit removed alltogether as
all it did was to call skygw_logmanager_done. That appears to have been
a source for confusion as in many places a call to skygw_logmanager_done
was followed by a call to skygw_logmanager_exit. In addition, the function
skygw_log_done was removed from the header, since it lacked an
implementation.
2015-11-12 16:06:44 +02:00
Johan Wikman
bdfd72404b Log: skygw_log_rotate replaced with mxs_log_rotate.
With only one log-file no arguments are needed. The maxadmin command
'flush log'  still accepts all the previous arguments, but warns about
them being deprecated.
2015-11-12 14:48:37 +02:00
Johan Wikman
acb0a523a7 Log: No more argv parsing for log manager.
Earlier, the global setting for the syslog decided whether syslog
was enabled when skygw_logmanager_init was called, but not whether
logging to syslog actually was made.

Now syslog logging is enabled by default and the global setting
decides whether or not syslog logging actually is made. That is,
this opens up the possiblity for making it possible to turn on
and off sysloging at runtime.

Further, although the API led you to believe otherwise, it was
hardwired that LOGFILE_ERROR and LOGFILE_MESSAGE messages were
written to syslog.

The changed removed the need for passing an argv array explicitly.
2015-11-11 13:53:14 +02:00
Johan Wikman
24bed47794 Syslog ident must be provided explicitly.
The syslog ident must be provided explicitly when calling
skygw_logmanager_init (and not provided via the argv array).
It can be NULL, in which case it automatically will be the program
name.

The openlog() call is now always made, irrespective of what the
value of the global syslog flag is. That way it will be possible
to turn syslog logging on or off after the fact.
2015-11-11 13:48:57 +02:00
Johan Wikman
55dbaa49c0 Logging target must be explicitly defined.
Whether the log-file should be written to the filesystem or to
shared memory must now be explicitly defined when calling
skygw_logmanager_init() (instead of passing that via the argc/argv
construct).

Also, the meaning of '-l' when invoking maxscale has been changed.

Earlier -l [file|shm] specified whether the trace and debug logs
should be written to shared memory (while the error and message
logs always were written to the filesystem) and the _default_
was to write them to shared memory.

Now, with only one file, '-l' has still the same meaning, but it
decides whether the one and only logfile should be written to shared
memory, or the filesystem and the _default_ is to write it to the
filesystem.
2015-11-11 13:47:34 +02:00
Johan Wikman
450078fa92 Interface of skygw_logmanager_init(int argc, char* argv[]) changed.
The previous interface of skygw_logmanager_init was conceptually
broken. With -o you could specify that logging should be done to
stdout. However, even if you did that, the log manager still checked
that the logging directory could be accessed. Unless it had been
specified using -j <path> the default was /var/log/maxscale.

That is, unless the program calling skygw_logmanager_init was invoked
by a user that had write access to /var/log/maxscale, there would be
a complaint even if nothing was ever written to that directory.
In practice this meant that even if -o was used you had to provide
a -j with a path that surely is writeable (e.g. "/tmp").

This has now been changed so that you explicitly must provide the
log directory and the flags -j and -o are removed.

  bool skygw_logmanager_init(const char* logdir, int argc, char* argv[]);

If /logdir/ is provided then logged messages are written to a log file
in that directory. If /logdir/ is NULL then messages are logged to stdout
and no checks for access to any directory is not made.
2015-11-06 14:20:05 +02:00
Johan Wikman
834a88aeda Log variables moved to log_manager.h
The log manager variables lm_enabled_log_files_bitmask, log_ses_count
and tls_log_info that earlier were declared separately in every
c-file are now declared in the log_manager.h header.
2015-11-04 14:26:53 +02:00
Johan Wikman
b543f36a49 Indentation and whitespace fixes.
There were many combinations of tab-width used so making the
indentation look right in the editor wasn't really possible.

The changes made:
- All tabs replaced with spaces.
- Indentation depth 4.
- , followed by space.
- Most binary operators (*, =, -) surrounded by one space.
- No space following ( or before ).
- Keywords follwed by 1 space.
2015-10-30 10:21:54 +02:00
Markus Makela
56ed36ee76 Moved SSL initialization to be done before services are started. 2015-10-05 09:05:38 +03:00
Johan Wikman
9efad8727a All warnings removed.
Minimal changes to remove warnings when compiling.
2015-09-25 14:07:19 +03:00
Markus Makela
338b870cd1 Fix to MXS-373: https://mariadb.atlassian.net/browse/MXS-373
The log manager is initialized only once and skygw_log_sync_all now checks if the log manager has been successfully started before interacting with the log manager
2015-09-21 17:27:49 +03:00
Markus Makela
601eac5a5d Fixed parent-child code being called in non-daemon mode. 2015-09-18 17:26:27 +03:00
MassimilianoPinto
d192cee0a1 Fixed Log message to 2015
Fixed Log message to 2015
2015-09-18 09:49:22 +02:00
Markus Makela
8a996029bc Merge branch 'MXS-35' into develop 2015-09-15 11:50:36 +03:00
Markus Makela
bbc0116cd2 Moved the writing to and closing of the parent-child pipe to a separate function. 2015-09-15 10:52:37 +03:00
Johan Wikman
37f8148574 MXS-362: Enable/disable log augmentation
Log message augmentation (appending of function name) can now
be enabled or disabled via the configuration file and command
line.

By default, the augmentation is disabled.
2015-09-11 15:58:31 +03:00
MassimilianoPinto
ad0becae48 Copyright set to 2015
Copyright set to 2015
2015-09-07 14:39:55 +02:00
Markus Makela
0febf23992 Removed LOGIF macros which prevented implicit initialization of the log manager. 2015-09-07 09:41:57 +03:00
Johan Wikman
160bbb70ee MXS-251: strerror
Replaces all calls to strerror with calls to strerror_r. The former
is non-thread safe while the latter is.
2015-09-05 15:52:13 +03:00
Markus Makela
30cdda48c6 The datadir path is now used as the location where the process specific data directories are created. 2015-09-03 19:30:16 +03:00
Markus Makela
e55d345ab4 Added --version-full which prints version and commit ID. 2015-09-02 10:58:41 +03:00
Markus Makela
77a49e8cbd Removed magic numbers. 2015-09-01 14:31:35 +03:00
Markus Makela
e839dafdd0 Cleaned up code. 2015-09-01 14:31:35 +03:00
Markus Makela
386fa78a30 Fix to MXS-342: https://mariadb.atlassian.net/browse/MXS-342
Added more error messaging when the parsing of the configuration file fails.
2015-09-01 14:31:35 +03:00
Markus Makela
9fe479e679 Cleaned up code. 2015-09-01 10:11:20 +03:00
Markus Makela
28a6ea90c0 Added more details to log output when MaxScale receives a fatal signal. 2015-09-01 10:11:20 +03:00
Markus Makela
0c552bab29 Fix to MXS-35: https://mariadb.atlassian.net/browse/MXS-35
The parent process now correctly returns the value from the child process.
2015-08-27 14:22:58 +03:00
Markus Makela
1658e3d704 Added more verbose error messages and fixed bugs. 2015-08-25 15:20:10 +03:00
Markus Makela
f58e7af94d Added a define for the PID file desciptor initial value. 2015-08-25 15:20:10 +03:00
Markus Makela
372403760c Cleaned up code. 2015-08-25 15:20:10 +03:00
Markus Makela
063c8f904a Fixed wrong file open mode. 2015-08-25 15:20:10 +03:00
Markus Makela
0a33174803 Added PID file locks and cleaned up code. 2015-08-25 15:20:10 +03:00
Markus Makela
1dd22a4d2c Cleaned up code and error messages. 2015-08-25 15:20:10 +03:00
Markus Makela
b1d6096fa8 Added a check for running MaxScale processes. 2015-08-25 15:20:10 +03:00
Markus Makela
98ab399e6e Changed sprintf calls to snprintf calls and fixed compiler warnings. 2015-08-18 10:50:48 +03:00
Markus Makela
86ad570af8 Fix to MXS-310: https://mariadb.atlassian.net/browse/MXS-310
The dumpable flag is now reset to true after the uid is changed.
2015-08-16 18:15:16 +03:00
Markus Makela
d6b587ad59 Fixed bad directory names in config not causing MaxScale to exit. 2015-08-11 21:07:11 +03:00