From 8edd0456a3a85341ad429a887691487beed3262c Mon Sep 17 00:00:00 2001 From: MadCamel Date: Fri, 28 Feb 2014 09:09:07 -0500 Subject: Lower process priority when saving login/char databases In the event of CPU contention this will make forked database writes take a back-seat to the actual running server. --- src/char/char.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/char/char.cpp') 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 #include +#include + #include #include #include @@ -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(); -- cgit v1.2.3-60-g2f50