diff --git a/src/config/get.c b/src/config/get.c index 4e1dd34..5a2babc 100644 --- a/src/config/get.c +++ b/src/config/get.c @@ -30,6 +30,10 @@ ConfigValue configGet(Config this, const char * key, size_t nkey) { + if (NULL == this) { + return NULL; + } + return hashGet(this->config, key, nkey); } diff --git a/src/taskrambler.c b/src/taskrambler.c index 0c7b317..fcbda24 100644 --- a/src/taskrambler.c +++ b/src/taskrambler.c @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -68,15 +69,31 @@ Config config; int main() { - pid_t pid; long psize = sysconf(_SC_PAGESIZE); + struct rlimit limit = {RLIM_INFINITY, RLIM_INFINITY}; + + pid_t pid; int status; int shm; struct randval * value; + logger = new(LoggerSyslog, LOGGER_DEBUG); config = new(Config, CONFIGDIR "/taskrambler.conf"); - struct rlimit limit = {RLIM_INFINITY, RLIM_INFINITY}; + if (NULL == config) { + loggerLog(logger, LOGGER_INFO, + "unable to load configuration file: %s\n", + CONFIGDIR "/taskrambler.conf"); + + if (! INSTANCE_OF(LoggerStderr, logger)) { + fprintf(stderr, + "unable to load configuration file: %s\n", + CONFIGDIR "/taskrambler.conf"); + } + + return 1; + } + setrlimit(RLIMIT_CPU, &limit); getrlimit(RLIMIT_NOFILE, &limit); @@ -175,8 +192,6 @@ main() shm_unlink("/fooshm"); close(shm); - logger = new(LoggerSyslog, LOGGER_DEBUG); - authLdap = new( AuthLdap, (ldap_host->value).string, @@ -257,7 +272,6 @@ main() delete(passwords); delete(users); delete(authLdap); - delete(logger); clearMimeTypes(); assetPoolCleanup(); @@ -267,6 +281,7 @@ main() } delete(config); + delete(logger); memCleanup(); return 0;