X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fserver.c;h=8aa356c58c2f0df6e69f580f947e8137dd4183c7;hb=71893121fbce7762f5cd9e6a98c4ead7e5cd6211;hp=9bb6ccb801e44294ca872145f99b5b30a56de4fc;hpb=49584345810f98b779d6927f7997fcdd11b98569;p=umurmur.git diff --git a/src/server.c b/src/server.c index 9bb6ccb..8aa356c 100644 --- a/src/server.c +++ b/src/server.c @@ -47,6 +47,7 @@ #include "timer.h" #include "version.h" #include "util.h" +#include "sharedmemory.h" /* globals */ bool_t shutdown_server; @@ -66,11 +67,11 @@ void checkIPversions() int testsocket = -1; testsocket = socket(PF_INET, SOCK_STREAM, 0); - hasv4 = (errno == EAFNOSUPPORT) ? false : true; + hasv4 = (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT) ? false : true; if (!(testsocket < 0)) close(testsocket); testsocket = socket(PF_INET6, SOCK_STREAM, 0); - hasv6 = (errno == EAFNOSUPPORT) ? false : true; + hasv6 = (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT) ? false : true; if (!(testsocket < 0)) close(testsocket); if(!hasv4) @@ -84,7 +85,6 @@ void checkIPversions() Log_info("IPv6 is not supported by this system"); nofServerSocks -= 2; } - if(nofServerSocks == 0) { Log_fatal("Neither IPv4 nor IPv6 are supported by this system"); @@ -95,10 +95,17 @@ void checkIPversions() struct sockaddr_storage** Server_setupAddressesAndPorts() { struct sockaddr_storage** addresses = calloc(2, sizeof(void*)); + if(!addresses) + Log_fatal("Not enough memory to allocate addresses"); struct sockaddr_storage* v4address = calloc(1, sizeof(struct sockaddr_storage)); + if(!v4address) + Log_fatal("Not enough memory to allocate IPv4 address"); v4address->ss_family = AF_INET; + struct sockaddr_storage* v6address = calloc(1, sizeof(struct sockaddr_storage)); + if(!v6address) + Log_fatal("Not enough memory to allocate IPv6 address"); v6address->ss_family = AF_INET6; #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)