summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-01-18 19:36:34 +0000
committerJared Adams <jaxad0127@gmail.com>2010-01-18 19:36:34 +0000
commitabe96e3b05a99a984d6f00098f1aa9759814b542 (patch)
tree09ed3d132692869e055f9406a473c32399dc3a4b
parent98f533996e31c4a20d312724e02ba3d8bf35b110 (diff)
downloadtmwa-abe96e3b05a99a984d6f00098f1aa9759814b542.tar.gz
tmwa-abe96e3b05a99a984d6f00098f1aa9759814b542.tar.bz2
tmwa-abe96e3b05a99a984d6f00098f1aa9759814b542.tar.xz
tmwa-abe96e3b05a99a984d6f00098f1aa9759814b542.zip
Attempt to fix forking problem on platinum
-rw-r--r--src/char/char.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 2b25399..3755d1f 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -16,6 +16,7 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <stdarg.h>
+#include <sys/wait.h>
#include "core.h"
#include "socket.h"
@@ -114,6 +115,8 @@ int online_gm_display_min_level = 20; // minimum GM level to display 'GM' when
int *online_chars; // same size of char_dat, and id value of current server (or -1)
time_t update_online; // to update online files when we receiving information from a server (not less than 8 seconds)
+pid_t pid = 0; // For forked DB writes
+
//------------------------------
// Writing function of logs file
//------------------------------
@@ -828,7 +831,17 @@ void mmo_char_sync (void)
//----------------------------------------------------
int mmo_char_sync_timer (int tid, unsigned int tick, int id, int data)
{
- pid_t pid;
+ if (pid != 0)
+ {
+ int status;
+ pid_t temp = waitpid (pid, &status, WNOHANG);
+
+ // Need to check status too?
+ if (temp == 0)
+ {
+ return 0;
+ }
+ }
// 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