Browse Source

主线程添加了最外层的异常打印。

zzj 6 years ago
parent
commit
cff1f8514b
1 changed files with 18 additions and 1 deletions
  1. 18 1
      znet.cpp

+ 18 - 1
znet.cpp

@@ -626,7 +626,24 @@ struct main_loop:io_context
 
 		block_sig(SIGPIPE);
 		signal_w sint(*this,SIGINT),term(*this,SIGTERM);
-		ev::dynamic_loop::run(0);
+
+
+		while(!check_stop_flag())
+		{
+			try
+			{
+			ev::dynamic_loop::run(0);
+			}
+			catch(const std::exception&e)
+			{
+				log_error("捕获到异常:%s",e.what());
+			}
+			catch(...)
+			{
+				log_error("捕获到未知异常");
+			}
+		}
+
 		_1.stop();
 		close_all();