aboutsummaryrefslogtreecommitdiff
path: root/src/server.c
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2016-01-31 19:53:45 -0500
committerFranklin Wei <frankhwei536@gmail.com>2016-01-31 19:53:45 -0500
commit0730fc3924dd4e04efbe51287d1d69850404d05f (patch)
tree495d79d0dc26e39c9065c6ceb7d16b9a3e76561d /src/server.c
parent8405274a91e3652ee98a423608a8496ead1edc05 (diff)
downloadnetcosm-0.5.0-rc1.zip
netcosm-0.5.0-rc1.tar.gz
netcosm-0.5.0-rc1.tar.bz2
netcosm-0.5.0-rc1.tar.xz
bump version to 0.5.0-rc10.5.0-rc1
* implements objects using reference counts rather than copying * implements both room-local and global verbs * refactors the world_* functions into a separate module * numerous other changes
Diffstat (limited to 'src/server.c')
-rw-r--r--src/server.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/server.c b/src/server.c
index 3b428d3..d65a3f1 100644
--- a/src/server.c
+++ b/src/server.c
@@ -23,6 +23,7 @@
#include "server.h"
#include "userdb.h"
#include "util.h"
+#include "world.h"
#define DEFAULT_PORT 1234
#define BACKLOG 512
@@ -116,8 +117,14 @@ static void __attribute__((noreturn)) serv_cleanup(void)
close(server_socket);
- world_free();
+ /* shut down modules */
+ obj_shutdown();
reqmap_free();
+ userdb_shutdown();
+ verb_shutdown();
+ world_free();
+
+ /* free internal data structures */
hash_free(child_map);
child_map = NULL;
@@ -125,14 +132,11 @@ static void __attribute__((noreturn)) serv_cleanup(void)
hash_free(dir_map);
dir_map = NULL;
- userdb_shutdown();
-
- obj_shutdown();
-
extern char *current_user;
if(current_user)
free(current_user);
+ /* shut down libev */
ev_default_destroy();
exit(0);
@@ -254,24 +258,25 @@ static void new_connection_cb(EV_P_ ev_io *w, int revents)
/* child */
are_child = true;
+ /* close our file descriptors */
close(readpipe[0]);
close(outpipe[1]);
close(server_socket);
- /* only the master process controls the world */
- world_free();
+ /* shut down modules */
+ obj_shutdown();
reqmap_free();
+ userdb_shutdown();
+ verb_shutdown();
+ world_free();
+
+ /* free our data structures */
hash_free(child_map);
child_map = NULL;
- /* we don't need libev anymore */
+ /* shut down libev */
ev_default_destroy();
- /* user DB requests go through the master */
- userdb_shutdown();
-
- obj_shutdown();
-
debugf("Child with PID %d spawned\n", getpid());
server_socket = new_sock;