29 #include <sys/resource.h>
30 #include <sys/types.h>
33 #include <sys/signal.h>
34 #include <sys/param.h>
56 #define DEFAULT_SECS 10
59 #define DEFAULT_USECS 0
72 long psize = sysconf(_SC_PAGESIZE);
73 struct rlimit limit = {RLIM_INFINITY, RLIM_INFINITY};
81 config =
new(Config, CONFIGDIR
"/taskrambler.conf");
85 "unable to load configuration file: %s\n",
86 CONFIGDIR
"/taskrambler.conf");
90 "unable to load configuration file: %s\n",
91 CONFIGDIR
"/taskrambler.conf");
97 setrlimit(RLIMIT_CPU, &limit);
99 getrlimit(RLIMIT_NOFILE, &limit);
100 limit.rlim_cur = limit.rlim_max;
101 setrlimit(RLIMIT_NOFILE, &limit);
106 shm = shm_open(
"/fooshm", O_RDWR|O_CREAT, S_IRWXU);
107 if (-1 == ftruncate(shm, psize)) {
111 switch((pid = fork())) {
117 sigset_t block_these, pause_mask;
119 struct itimerval interval;
121 value = mmap (0,
sizeof(
struct randval), PROT_READ|PROT_WRITE,
123 value->timestamp = 0;
129 sigemptyset(&block_these);
130 sigaddset(&block_these, SIGALRM);
131 sigprocmask(SIG_BLOCK, &block_these, &pause_mask);
134 sigemptyset(&s.sa_mask);
135 sigaddset(&s.sa_mask, SIGINT);
138 if (sigaction(SIGALRM, &s, NULL) < 0) {
139 perror(
"sigaction SIGALRM");
148 setitimer(ITIMER_REAL, &interval, NULL);
152 value->timestamp = time(NULL);
153 value->value = rand() % 100;
154 sigsuspend(&pause_mask);
164 Application application;
166 ApplicationAdapterHttp adapterHttp;
170 ConfigValue ldap_base =
172 ConfigValue ldap_host =
174 ConfigValue runtime_dir =
179 char user_storage[512];
180 char password_storage[512];
182 strcpy(user_storage, (runtime_dir->value).string);
183 strcpy(password_storage, (runtime_dir->value).string);
184 strcat(user_storage,
"/users.db");
185 strcat(password_storage,
"/passwords.db");
187 value = mmap (0,
sizeof(
int), PROT_READ|PROT_WRITE,
190 shm_unlink(
"/fooshm");
197 (ldap_host->value).string,
200 users =
new(Storage, user_storage);
201 passwords =
new(Storage, password_storage);
203 if (NULL == users || NULL == passwords) {
204 puts(
"error opening database files...\n");
215 "14de9e60-d497-4754-be72-f3bed52541fc",
218 router =
new(Router, application);
219 adapterHttp =
new(ApplicationAdapterHttp, application, router);
221 worker =
new(HttpWorker,
"taskrambler");
228 (int)(port->value).number,
241 w = waitpid(pid, &status, 0);
245 case EINTR: w = waitpid(pid, &status, 0);
247 case ECHILD: perror(
"no child");
254 if (WIFEXITED(status)) {
256 "child exited, status=%d\n",
257 WEXITSTATUS(status));
258 }
else if (WIFSIGNALED(status)) {
260 "killed by signal %d\n",
262 }
else if (WIFSTOPPED(status)) {
264 "stopped by signal %d\n",
266 }
else if (WIFCONTINUED(status)) {
270 }
while (!WIFEXITED(status) && !WIFSIGNALED(status));
int authCreate(Auth, AuthModule,...)
ConfigValue configGet(Config, const char *, size_t)
void assetPoolCleanup(void)
#define CSTRA(val)
Const STRing Argument.
void serverRun(Server this)
void loggerLog(void *, logger_level, const char *const,...)
void subjectAttach(void *, void *)
#define INSTANCE_OF(class, obj)
void clearMimeTypes(void)