projects
/
umurmur.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #100 from C4K3/scheduler-timing
[umurmur.git]
/
src
/
main.c
diff --git
a/src/main.c
b/src/main.c
index c1649b6fb20b6ff2e4c24aa8fc431348c2aead51..bc913395f8b56e784709aac25ed9839ca1820f73 100644
(file)
--- a/
src/main.c
+++ b/
src/main.c
@@
-55,6
+55,8
@@
#include "conf.h"
#include "version.h"
#include "config.h"
#include "conf.h"
#include "version.h"
#include "config.h"
+#include "sharedmemory.h"
+#include "ban.h"
char system_string[64], version_string[64];
int bindport;
char system_string[64], version_string[64];
int bindport;
@@
-197,6
+199,10
@@
void daemonize()
for (i = getdtablesize(); i >= 0; --i)
close(i); /* close all descriptors */
for (i = getdtablesize(); i >= 0; --i)
close(i); /* close all descriptors */
+#ifdef USE_GNUTLS
+ gnutls_global_init();
+#endif
+
i = open("/dev/null",O_RDWR);
(void)dup(i);
(void)dup(i);
i = open("/dev/null",O_RDWR);
(void)dup(i);
(void)dup(i);
@@
-317,6
+323,13
@@
int main(int argc, char **argv)
if (pidfile != NULL)
lockfile(pidfile);
if (pidfile != NULL)
lockfile(pidfile);
+#ifdef POSIX_PRIORITY_SCHEDULING
+ /* Set the scheduling policy, has to be called after daemonizing
+ * but before we drop privileges */
+ if (realtime)
+ setscheduler();
+#endif
+
switch_user();
/* Reopen log file. If user switch results in access denied, we catch
switch_user();
/* Reopen log file. If user switch results in access denied, we catch
@@
-326,6
+339,15
@@
int main(int argc, char **argv)
}
else Log_init(true);
}
else Log_init(true);
+#ifdef POSIX_PRIORITY_SCHEDULING
+ /* We still want to set scheduling policy if nodaemon is specified,
+ * but if we are daemonizing setscheduler() will be called above */
+ if (nodaemon) {
+ if (realtime)
+ setscheduler();
+ }
+#endif
+
signal(SIGCHLD, SIG_IGN); /* ignore child */
signal(SIGTSTP, SIG_IGN); /* ignore tty signals */
signal(SIGTTOU, SIG_IGN);
signal(SIGCHLD, SIG_IGN); /* ignore child */
signal(SIGTSTP, SIG_IGN); /* ignore tty signals */
signal(SIGTTOU, SIG_IGN);
@@
-350,13
+372,16
@@
int main(int argc, char **argv)
Client_init();
Ban_init();
Client_init();
Ban_init();
-#ifdef POSIX_PRIORITY_SCHEDULING
- if (realtime)
- setscheduler();
+#ifdef USE_SHAREDMEMORY_API
+ Sharedmemory_init( bindport, bindport6 );
#endif
Server_run();
#endif
Server_run();
+#ifdef USE_SHAREDMEMORY_API
+ Sharedmemory_deinit();
+#endif
+
Ban_deinit();
SSLi_deinit();
Chan_free();
Ban_deinit();
SSLi_deinit();
Chan_free();