diff options
-rw-r--r-- | src/char/char.cpp | 9 | ||||
-rw-r--r-- | src/login/login.cpp | 6 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/char/char.cpp b/src/char/char.cpp index 55dca81..04e540b 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -7,6 +7,8 @@ #include <netdb.h> #include <unistd.h> +#include <sys/resource.h> + #include <cassert> #include <cstdlib> #include <cstring> @@ -555,8 +557,13 @@ void mmo_char_sync_timer(TimerData *, tick_t) // This can take a lot of time. Fork a child to handle the work and return at once // If we're unable to fork just continue running the function normally - if ((pid = fork()) > 0) + if ((pid = fork()) > 0) { return; + } + + // If we're a child, run as a lower priority process + if (pid == 0) + setpriority(PRIO_PROCESS, getpid(), 10); mmo_char_sync(); inter_save(); diff --git a/src/login/login.cpp b/src/login/login.cpp index ea58669..b21b028 100644 --- a/src/login/login.cpp +++ b/src/login/login.cpp @@ -5,6 +5,8 @@ #include <netdb.h> #include <unistd.h> +#include <sys/resource.h> + #include <cstdlib> #include <cstring> #include <ctime> @@ -652,6 +654,10 @@ void check_auth_sync(TimerData *, tick_t) if ((pid = fork()) > 0) return; + // If we're a child, run as a lower priority process + if (pid == 0) + setpriority(PRIO_PROCESS, getpid(), 10); + mmo_auth_sync(); // If we're a child we should suicide now. |