]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Simplify set_server_start_time().
authorAndre Noll <maan@systemlinux.org>
Thu, 9 Jan 2014 16:57:58 +0000 (16:57 +0000)
committerAndre Noll <maan@systemlinux.org>
Thu, 19 Jun 2014 13:30:22 +0000 (15:30 +0200)
This function receives a pointer to a timeval structure which is
supposed to contain the daemon startup time. Passing NULL means to
set the daemon startup time to the current time.

There are only two callers of this function, in audiod.c and in
server.c.  The first one passes NULL, the other one initialises the
timeval structure pointed to by the global now pointer to the current
time, and passes this pointer.

It's easier to let set_server_start_time() always act as if NULL had
been passed.

audiod.c
daemon.c
daemon.h
server.c

index a8f401834b8a438d7b21d96920bc7b735f0a6c6b..d5c603e94fcdbc5c8b7a2121a8e54fb7f5bc76c5 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1411,7 +1411,7 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
        log_welcome("para_audiod");
                exit(EXIT_FAILURE);
        }
        log_welcome("para_audiod");
-       set_server_start_time(NULL);
+       set_server_start_time();
        set_initial_status();
        FOR_EACH_SLOT(i)
                clear_slot(i);
        set_initial_status();
        FOR_EACH_SLOT(i)
                clear_slot(i);
index 05002f4eff228e0200d5d6cdce9be0c697ed3bc3..cace3b7874e7a3f00c72b134b59ada6d4978959d 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -292,21 +292,14 @@ void drop_privileges_or_die(const char *username, const char *groupname)
 /**
  * Set the server startup time.
  *
 /**
  * Set the server startup time.
  *
- * \param startuptime The value to store as the server start time.
+ * This should be called once on startup. It sets the server start time to the
+ * current time. The stored time is used for retrieving the server uptime.
  *
  *
- * This should be called once on startup with \a startuptime either NULL or a
- * pointer to a struct timeval which contains the current time. If \a
- * startuptime is NULL, the server start time is set to the current time.
- *
- * \sa time(2), difftime(3) \ref get_server_uptime(), \ref
- * get_server_uptime_str().
+ * \sa time(2), \ref get_server_uptime(), \ref get_server_uptime_str().
  */
  */
-void set_server_start_time(const struct timeval *startuptime)
+void set_server_start_time(void)
 {
 {
-       if (startuptime)
-               me->startuptime = startuptime->tv_sec;
-       else
-               time(&me->startuptime);
+       time(&me->startuptime);
 }
 
 /**
 }
 
 /**
index fd435577e6258aa24fe2fe1edc9bde2ce50c7d5f..025b6a5e9ef7b52225af1205bedc0a2b4f4c0400 100644 (file)
--- a/daemon.h
+++ b/daemon.h
@@ -6,8 +6,7 @@ void daemon_open_log_or_die(void);
 void daemon_close_log(void);
 void log_welcome(const char *whoami);
 void drop_privileges_or_die(const char *username, const char *groupname);
 void daemon_close_log(void);
 void log_welcome(const char *whoami);
 void drop_privileges_or_die(const char *username, const char *groupname);
-/** used for server_uptime() */
-void set_server_start_time(const struct timeval *startuptime);
+void set_server_start_time(void);
 time_t get_server_uptime(const struct timeval *current_time);
 __malloc char *get_server_uptime_str(const struct timeval *current_time);
 void daemon_set_logfile(char *logfile_name);
 time_t get_server_uptime(const struct timeval *current_time);
 __malloc char *get_server_uptime_str(const struct timeval *current_time);
 void daemon_set_logfile(char *logfile_name);
index fa19ce4225111e33ec7f192935f455c6cd5b2d76..bdb5df982bbd23ff7c8ebba1101c660b54ae53a2 100644 (file)
--- a/server.c
+++ b/server.c
@@ -484,9 +484,7 @@ static void server_init(int argc, char **argv)
        parse_config_or_die(0);
        log_welcome("para_server");
        init_ipc_or_die(); /* init mmd struct and mmd->lock */
        parse_config_or_die(0);
        log_welcome("para_server");
        init_ipc_or_die(); /* init mmd struct and mmd->lock */
-       /* make sure, the global now pointer is uptodate */
-       clock_get_realtime(now);
-       set_server_start_time(now);
+       set_server_start_time();
        init_user_list(user_list_file);
        /* become daemon */
        if (conf.daemon_given)
        init_user_list(user_list_file);
        /* become daemon */
        if (conf.daemon_given)