Move serverMode flag from log.c to server.c

This commit is contained in:
Andrew Bettison 2014-06-11 14:53:26 +09:30
parent 11dcc3e972
commit a1c42eb378
7 changed files with 13 additions and 10 deletions

6
conf.c
View File

@ -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
View File

@ -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
View File

@ -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();

View File

@ -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 */

View File

@ -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"

View File

@ -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,

View File

@ -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;