summaryrefslogtreecommitdiff
path: root/src/char/char.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/char/char.c')
-rw-r--r--src/char/char.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 38c1f4a..fbf512e 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -720,8 +720,20 @@ void mmo_char_sync(void) {
// Function to save (in a periodic way) datas in files
//----------------------------------------------------
int mmo_char_sync_timer(int tid, unsigned int tick, int id, int data) {
+ pid_t pid;
+
+ // 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)
+ return 0;
+
mmo_char_sync();
inter_save();
+
+ // If we're a child we should suicide now.
+ if (pid == 0)
+ exit(0);
+
return 0;
}
@@ -905,7 +917,6 @@ int make_new_char(int fd, unsigned char *dat) {
memcpy(&char_dat[i].save_point, &start_point, sizeof(start_point));
char_num++;
- mmo_char_sync();
return i;
}