Trigger names cannot exceed 11 characters on OS X, so the new "config_change" trigger
has been renamed to "conf_change" and the "config_change_log" trigger has been renamed
to "conf_log".
Very occasionally, when the file logger was creating the symlink from
'serval.log' to the current log file, there was a race with another
process doing exactly the same, causing one of them to log an
symlink-failed ERROR that caused the server/StartTwice test to fail
(when asserting that the "start" command contained no ERROR log
messages). Now the symlink failure is logged at WARN level, which will
not cause the test to fail.
This introduces a new way of linking Serval executables and dynamic
libraries from static libraries like libservald.a -- called
"feature-driven" linking.
The Makefile now links servald and serval-tests from libservald.a,
rather than from an explicit list of object (.o) files. Thanks to the
section-based method for registering functions such as HTTP handlers,
CLI commands and MDP handlers, these object files had become
"stand-alone" and hence were no longer included in the link because
there was no unresolved reference that required them to be linked in.
The new "feature.h" provides the DECLARE_FEATURE(name) macro that each
stand-alone source file uses to declare the named feature(s) it
provides. Each executable can call the USE_FEATURE(name) macro in any
of its explicitly-linked source files to cause the corresponding
object(s) to be included in the link, eg, servald_features.c.
The DEFINE_BINDING() macro has been extended so that every individual
MDP binding is given a feature name based on its port number macro, eg,
"mdp_binding_MDP_PORT_ECHO".
Some features have been factored into their own separate source files so
they can be omitted or included in a build independently of each other:
- the MDP bindings for MDP_PORT_DNALOOKUP, MDP_PORT_ECHO,
MDP_PORT_TRACE, MDP_PORT_KEYMAPREQUEST, MDP_PORT_RHIZOME_xxx,
MDP_PORT_PROBE, MDP_PORT_STUN, MDP_PORT_STUNREQ
- the CLI "log" and "echo" commands
- the CLI "rhizome direct" command
The JNI source files are only compiled if the <jni.h> header is present,
otherwise they are omitted from libservald.so.
This is required to support feature-driven linking, in which the exact
list of which functions to call in response to a configuration re-load
is not known until link time.
The "config_change_log" trigger is called before "config_change", so
that the logger can respond to the change before other subsystems.
The CLI and server main loop now have no conditional JNI code. All JNI
code has been moved into separate source files, which #include the new
"jni_common.h" instead of <jni.h>. The "cli.h" header no longer
includes <jni.h>, so the rest of the Serval source code is now
unaffected by JNI definitions.
The 'cf_limbo' global variable is now thread-local, so that each thread
has its own independent copy of the loaded configuration. The JNI
server entry point now calls cf_init() once. The new 'cf_initialised'
flag prevents clobbering the config state by redundant calls to
cf_init().
The CLI "stop" command now sends SIGHUP to the specific thread in which
the server is running. This is achieved by writing the PID and TID
(Linux Thread ID) into the pidfile, separated by a space, on systems
that support the Linux gettid() and tgkill() system calls. The server's
signal handler has been overhauled, and its logging improved.
Make .o files in separate subdirectories for servald and library
Factor struct __sourceloc and __WHENCE__ from "log.h" into "whence.h"
Factor sid_t etc from "serval.h" into "serval_types.h"
Factor rhizome_bid_t etc from "rhizome.h" into "rhizome_types.h"
Do not include "serval.h" in library sources
Add log_stderr.c and logMessage.c for stand-alone executables
Make logMessage() -- wrapper around vlogMessage() -- an inline
function and remove redundant conditional level != LOG_LEVEL_SILENT
Move logString() into log_util.c, refactor so outer loop now iterates
over lines in buffer, rather than over all log outputs
Rename log_backtrace() to logBacktrace() for consistency
Document __NOWHENCE__ value
If no instance directory specified, then use paths like
/etc/serval/serval.conf
/var/cache/serval
/var/log/serval
/var/run/serval
etc. for files, instead of all in a single directory.
Log all directory creation as INFO messages.
Interpretation of log.file.directory_path has changed slightly.
Updated servald configuration tech doc.
New UNUSED(param) macro suppresses the warning for a specific parameter
In some cases, removed the unused parameters. In others, used the
parameter in a DEBUGF() or assert() statement to document the intent.
Move config-dependent code (recvwithttl) from net.c to mdp_net.c (new)
Move log-implementation-independent code from log.c to log_util.c (new)
Build config_test binary in Makefile
Merge 4e3c93e failed: it should contain log.c from a1a296f, not a mix
between both varargs fix implementations (the other is f88dff0).
The resulting merge fails tests (on 64 bits architecture), while both
parents pass.
"man stdarg" says:
If ap is passed to a function that uses va_arg(ap,type) then the value
of ap is undefined after the return of that function.
va_start(…) and va_end(…) must be called at each iteration.
By chance, it worked in 32 bits, but it segfaulted in 64 bits.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31484
Refactor much of the new code in log.c
Add new functions: cf_load_strict() and cf_reload_strict() for use by the
server, which does not want to overwrite its in-memory config at all if there
is any defect in the config file. However, commands always want to overwrite
the default in-memory config, even with a defective config file, so that
logging has a chance to succeed.
Added `log_format.dump_config` boolean config option
Indepent configuration of show_pid, show_time and log level for each
destination
Update test scripts for new config options
Include xprintf.c in MDP client source files (now used by log.c)
Upgrade configuration schema macros to allow optional "default label"
argument to SUB_STRUCT and VALUE_SUB_STRUCT elements.
New STRUCT_DEFAULT section declares alternative STRUCT default values
with a label.
If configuration is bad, do not execute commands except those with the
PERMISSIVE_CONFIG property.
Flush log buffer immediately after clearing cf_limbo flag, in case there are no
further log messages that would cause the flush. (Fixes bug that an unrecognised
command produced no log output.)
More block comments in log.c.