summaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-11 20:45:43 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-03-11 20:45:43 +0200
commit618314985d6a632ccfd2001d969d32a5ee6e4ca1 (patch)
tree94faf77b08206466fb55f80448b02c557e734881 /src/server.cpp
parentd1d83d7e7f5e2e7cbef5272eda9c580129e301a3 (diff)
downloadminetest-618314985d6a632ccfd2001d969d32a5ee6e4ca1.tar.gz
minetest-618314985d6a632ccfd2001d969d32a5ee6e4ca1.tar.bz2
minetest-618314985d6a632ccfd2001d969d32a5ee6e4ca1.zip
Proper handling of failing to bind server socket
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 767de035f..63bf794ab 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -109,6 +109,10 @@ void * ServerThread::Thread()
{
infostream<<"Server: PeerNotFoundException"<<std::endl;
}
+ catch(con::ConnectionBindFailed &e)
+ {
+ m_server->setAsyncFatalError(e.what());
+ }
}
END_DEBUG_EXCEPTION_HANDLER(errorstream)
@@ -837,6 +841,7 @@ Server::Server(
m_path_world(path_world),
m_path_config(path_config),
m_gamespec(gamespec),
+ m_async_fatal_error(""),
m_env(NULL),
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this),
m_authmanager(path_world+DIR_DELIM+"auth.txt"),
@@ -865,6 +870,9 @@ Server::Server(
m_step_dtime_mutex.Init();
m_step_dtime = 0.0;
+ if(path_world == "")
+ throw ServerError("Supplied empty world path");
+
if(!gamespec.isValid())
throw ServerError("Supplied invalid gamespec");
@@ -1079,6 +1087,8 @@ Server::~Server()
void Server::start(unsigned short port)
{
DSTACK(__FUNCTION_NAME);
+ infostream<<"Starting server on port "<<port<<"..."<<std::endl;
+
// Stop thread if already running
m_thread.stop();
@@ -1128,6 +1138,11 @@ void Server::step(float dtime)
JMutexAutoLock lock(m_step_dtime_mutex);
m_step_dtime += dtime;
}
+ // Throw if fatal error occurred in thread
+ std::string async_err = m_async_fatal_error.get();
+ if(async_err != ""){
+ throw ServerError(async_err);
+ }
}
void Server::AsyncRunStep()