summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2014-06-06 20:40:53 +0200
committerSimon Rettberg2014-06-06 20:40:53 +0200
commit4b4726ce6dae79843293f724f85a1164d0edf7c6 (patch)
tree7ad467d8540f61bbcd7dd3c2dc39cf725217bc90
parentActually really fix helper_connect4 when passing a hostname (diff)
downloadldadp-4b4726ce6dae79843293f724f85a1164d0edf7c6.tar.gz
ldadp-4b4726ce6dae79843293f724f85a1164d0edf7c6.tar.xz
ldadp-4b4726ce6dae79843293f724f85a1164d0edf7c6.zip
Bail out on startup if an AD server is not reachable
-rw-r--r--ldadp.c3
-rw-r--r--server.c6
-rw-r--r--server.h2
3 files changed, 7 insertions, 4 deletions
diff --git a/ldadp.c b/ldadp.c
index c044a88..4d481df 100644
--- a/ldadp.c
+++ b/ldadp.c
@@ -47,7 +47,8 @@ int main(int argc, char **argv)
// Add listener
if (ePoll_add(EPOLLIN, (epoll_item_t*)&lsn) == -1) bail("Could not add listen socket to epoll fd");
// Init AD uplinks
- server_initServers();
+ if (!server_initServers())
+ exit(1);
// Daeaeaemon
if (isdaemon && daemon(1, 0) == -1) bail("daemon() failed.");
// Do the mainloop
diff --git a/server.c b/server.c
index 13202f8..aeb9d12 100644
--- a/server.c
+++ b/server.c
@@ -80,14 +80,16 @@ void server_setHomeTemplate(const char *server, const char *hometemplate)
if (count > 5) printf("WARNING: Too many '%%' in Home Template for %s. Don't forget to replace literal '%%' with '%%%%'\n", server);
}
-void server_initServers()
+BOOL server_initServers()
{
int i;
printf("%d servers configured.\n", serverCount);
for (i = 0; i < serverCount; ++i) {
printf("%s:\n Bind: %s\n Base: %s\n", servers[i].addr, servers[i].bind, servers[i].base);
- server_ensureConnected(&servers[i]);
+ if (!server_ensureConnected(&servers[i]))
+ return FALSE;
}
+ return TRUE;
}
// What the proxy calls
diff --git a/server.h b/server.h
index 4923d6e..7c966a2 100644
--- a/server.h
+++ b/server.h
@@ -14,7 +14,7 @@ void server_setBase(const char *server, const char *base);
void server_setHomeTemplate(const char *server, const char *hometemplate);
-void server_initServers();
+BOOL server_initServers();
int server_send(epoll_server_t *server, const char *buffer, size_t len, const BOOL cork);