mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-19 21:27:57 +00:00
Move serverMode flag from log.c to server.c
This commit is contained in:
parent
11dcc3e972
commit
a1c42eb378
6
conf.c
6
conf.c
@ -59,7 +59,7 @@ static int reload(const char *path, int *resultp)
|
||||
}
|
||||
if (cmp_file_meta(&meta, &conffile_meta) == 0)
|
||||
return 0;
|
||||
if (conffile_meta.mtime.tv_sec != -1 && serverMode)
|
||||
if (conffile_meta.mtime.tv_sec != -1)
|
||||
INFOF("config file %s -- detected new version", conffile_path());
|
||||
char *buf = NULL;
|
||||
if (meta.mtime.tv_sec == -1) {
|
||||
@ -93,8 +93,8 @@ static int reload(const char *path, int *resultp)
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
if (serverMode)
|
||||
INFOF("config file %s successfully read %ld bytes", path, (long) meta.size);
|
||||
if (config.debug.config)
|
||||
DEBUGF("config file %s successfully read %ld bytes", path, (long) meta.size);
|
||||
}
|
||||
conffile_meta = meta;
|
||||
if (config.debug.config)
|
||||
|
4
log.c
4
log.c
@ -43,7 +43,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "strbuf_helpers.h"
|
||||
#include "xprintf.h"
|
||||
|
||||
int serverMode = 0;
|
||||
int logLevel_NoLogFileConfigured = LOG_LEVEL_INFO;
|
||||
|
||||
#define NO_FILE ((FILE *)1)
|
||||
|
||||
@ -487,7 +487,7 @@ static void _open_log_file(_log_iterator *it)
|
||||
if (cf_limbo)
|
||||
return;
|
||||
_log_file = NO_FILE;
|
||||
_logs_printf_nl(serverMode ? LOG_LEVEL_WARN : LOG_LEVEL_INFO, __NOWHERE__, "No log file configured");
|
||||
_logs_printf_nl(logLevel_NoLogFileConfigured, __NOWHERE__, "No log file configured");
|
||||
} else {
|
||||
// Create the new log file.
|
||||
size_t dirsiz = strlen(_log_file_path) + 1;
|
||||
|
2
log.h
2
log.h
@ -48,7 +48,7 @@ const char *log_level_as_string(int level);
|
||||
int string_to_log_level(const char *text);
|
||||
|
||||
// Log output control.
|
||||
extern int serverMode;
|
||||
extern int logLevel_NoLogFileConfigured;
|
||||
void close_log_file();
|
||||
void disable_log_stderr();
|
||||
void logFlush();
|
||||
|
@ -26,8 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* using stdio buffered output.
|
||||
*/
|
||||
|
||||
int serverMode=0;
|
||||
|
||||
static const char *_trimbuildpath(const char *path)
|
||||
{
|
||||
/* Remove common path prefix */
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <inttypes.h> // for PRIx64 on Android
|
||||
#include "serval.h" // for serverMode
|
||||
#include "serval_types.h"
|
||||
#include "instance.h"
|
||||
#include "overlay_address.h"
|
||||
|
4
serval.h
4
serval.h
@ -173,16 +173,16 @@ struct overlay_buffer;
|
||||
struct overlay_frame;
|
||||
struct broadcast;
|
||||
|
||||
extern int serverMode;
|
||||
|
||||
int server_pid();
|
||||
const char *_server_pidfile_path(struct __sourceloc);
|
||||
#define server_pidfile_path() (_server_pidfile_path(__WHENCE__))
|
||||
void server_save_argv(int argc, const char *const *argv);
|
||||
int server(void);
|
||||
int server_write_pid();
|
||||
int server_write_proc_state(const char *path, const char *fmt, ...);
|
||||
int server_get_proc_state(const char *path, char *buff, size_t buff_len);
|
||||
void overlay_mdp_clean_socket_files();
|
||||
void serverCleanUp();
|
||||
|
||||
int overlay_forward_payload(struct overlay_frame *f);
|
||||
int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, size_t len,
|
||||
|
4
server.c
4
server.c
@ -39,6 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#define PIDFILE_NAME "servald.pid"
|
||||
#define STOPFILE_NAME "servald.stop"
|
||||
|
||||
int serverMode = 0;
|
||||
keyring_file *keyring=NULL;
|
||||
|
||||
static char pidfile_path[256];
|
||||
@ -94,6 +95,9 @@ int server()
|
||||
IN();
|
||||
serverMode = 1;
|
||||
|
||||
// Warn, not merely Info, if there is no configured log file.
|
||||
logLevel_NoLogFileConfigured = LOG_LEVEL_WARN;
|
||||
|
||||
/* Catch SIGHUP etc so that we can respond to requests to do things, eg, shut down. */
|
||||
struct sigaction sig;
|
||||
sig.sa_handler = signal_handler;
|
||||
|
Loading…
Reference in New Issue
Block a user