zzj 6 years ago
parent
commit
f8f872f7c7
2 changed files with 7 additions and 8 deletions
  1. 4 1
      net-service.cpp
  2. 3 7
      worker.cpp

+ 4 - 1
net-service.cpp

@@ -17,13 +17,16 @@
 
 net_service::net_service()
 {
+	m_loc_worker=nullptr;
+	m_sync_worker=nullptr;
 	m_loc_worker=worker::instance();
 	m_sync_worker=tdoa_sync::instance();
 }
 
 net_service::~net_service()
 {
-	m_loc_worker->stop();
+	if(m_loc_worker)
+		m_loc_worker->stop();
 }
 
 void net_service::on_message(std::shared_ptr<client> clt,const char*data,size_t len)

+ 3 - 7
worker.cpp

@@ -17,12 +17,9 @@ struct worker_thread: zloop<task*>
 {
 	std::unique_ptr<std::thread> m_thread;
 
-	card_list*m_card_list;
-
 	worker_thread ()
 	{
 		m_thread.reset(new std::thread(std::bind(&worker_thread::run,this)));
-		m_card_list=card_list::instance();//*********
 	}
 
 	void run()
@@ -47,13 +44,14 @@ struct worker_thread: zloop<task*>
 			case 0x843b://tof
 			case 0x863b://tdoa
 				log_info("card loc message%04X",t.m_cmd_code);
-				m_card_list->on_message(this,t.body<message_locinfo>(),false);
+
+				card_list::instance()-> on_message(this,t.body<message_locinfo>(),false);
 				//card_message::on_loc_message(this,t.m_param1);
 			break;
 			case 0x853b://tof his
 			case 0x873b://tdoa his
 				log_info("site history message%04X",t.m_cmd_code);
-				m_card_list->on_message(this,t.body<message_locinfo>(),true);
+				card_list::instance()-> on_message(this,t.body<message_locinfo>(),true);
 				//site_message::on_sync(this,t.m_param1);
 			break;
 
@@ -123,5 +121,3 @@ worker*worker::instance()
 }
 
 
-
-