Browse Source

Test that the clock is working at start and test for evloop errors.

master
Richard Nyberg 16 years ago
parent
commit
2947896074
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      btpd/main.c

+ 9
- 2
btpd/main.c View File

@@ -3,6 +3,7 @@
#include <sys/file.h> #include <sys/file.h>
#include <err.h> #include <err.h>
#include <getopt.h> #include <getopt.h>
#include <time.h>


static void static void
writepid(int pidfd) writepid(int pidfd)
@@ -16,6 +17,11 @@ static void
setup_daemon(int daemonize, const char *dir, const char *log) setup_daemon(int daemonize, const char *dir, const char *log)
{ {
int pidfd; int pidfd;
struct timespec ts;

if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
errx(1, "clock_gettime(CLOCK_MONOTONIC, ...) error (%s).",
strerror(errno));


if (log == NULL) if (log == NULL)
log = "log"; log = "log";
@@ -221,13 +227,14 @@ args_done:


setup_daemon(daemonize, dir, log); setup_daemon(daemonize, dir, log);


evloop_init();
if (evloop_init() != 0)
btpd_err("Failed to initialize evloop (%s).\n", strerror(errno));


btpd_init(); btpd_init();


evloop(); evloop();


btpd_err("Unexpected exit from evloop.\n");
btpd_err("Exit from evloop with error (%s).\n", strerror(errno));


return 1; return 1;
} }

Loading…
Cancel
Save