Browse Source

1、db_api 中的源文件减去可执行的情况... chmod a-x *
2、添加了一些注释, 形如 "//zzj..."

zzj 6 years ago
parent
commit
966d8abd30
4 changed files with 53 additions and 55 deletions
  1. 1 1
      card.cpp
  2. 11 10
      db_api/CDBConnPool.cpp
  3. 0 2
      net-service.cpp
  4. 41 42
      websocket/thread_safe_map.h

+ 1 - 1
card.cpp

@@ -1119,7 +1119,7 @@ void card_list::on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_
 	const auto c=get(cardid);
 	if(c==nullptr)
 	{
-		log_warn("数据库中未定义该卡的信息,card_id=%d", loc.m_card_id);
+		log_warn("数据库中未定义该卡的信息,card_id=%d, card_type=%d", loc.m_card_id, loc.m_card_type);
 		return;
 	}
 	log_info("card message:site=%d,ant=%d,card=%d,tof=%lld,rav=%02X,acc=%02X,rssi=%d,stamp=%llu",

+ 11 - 10
db_api/CDBConnPool.cpp

@@ -141,7 +141,7 @@ namespace YADB
 					return 0;
 				}
 
-				__IdleConnList.pop_front();
+				__IdleConnList.pop_front();				//zzj, ERROR!!,应该是pop_back吧
 				__BusyConnList.push_back( pConn );
 			}
 			else
@@ -151,7 +151,7 @@ namespace YADB
 			}
 		}
 
-		//验证看数据库连接是否还有效
+		//验证看数据库连接是否还有效 //zzj, 新建的链接不需要测试
 		if ( pConn )
 		{
 			if ( pConn->ConnctionTest( Error ) != 0 )
@@ -172,6 +172,7 @@ namespace YADB
 		return pConn;
 	}
 
+	//zzj, 建议使用栈展开的方式 自动回收
 	void CDBConnPool::GiveBack( CDBConnect * pConn )
 	{
 		std::unique_lock<std::mutex> lock( __mtx );
@@ -326,7 +327,7 @@ namespace YADB
     }
 
     bool CDBConnPool::Query( const char *szSql, CDBResultSet& DBRes,std::string& Error )
-    {
+	{
 		CDBConnect *pConn = GetDBConnect( Error );
 		if ( 0 == pConn )
 		{
@@ -334,9 +335,9 @@ namespace YADB
 		}
 
 		MYSQL_RES* pRes = pConn->Query( szSql, Error );
-	GiveBack( pConn );
-        return DBRes.Bind( pRes, Error );
-    }
+		GiveBack( pConn );
+		return DBRes.Bind( pRes, Error );
+	}
     
     MYSQL_RES* CDBConnPool::Query( const char *szSql, std::string& Error)
     {
@@ -350,15 +351,15 @@ namespace YADB
         return pRes;
     }
     my_ulonglong CDBConnPool::ExecuteSql( const char *szSql, std::string& Error )
-    {
-    	CDBConnect *pConn = GetDBConnect( Error );
+	{
+		CDBConnect *pConn = GetDBConnect( Error );
 		if ( 0 == pConn )
 		{
 			return -1;
 		}
-	my_ulonglong nRet = pConn->ExecuteSql( szSql, Error );
+		my_ulonglong nRet = pConn->ExecuteSql( szSql, Error );
 		GiveBack( pConn );
 		return nRet;
 		//return pConn->ExecuteSql( szSql, Error );
-    }
+	}
 }

+ 0 - 2
net-service.cpp

@@ -17,8 +17,6 @@
 #include "ant.h"
 net_service::net_service()
 {
-	m_loc_worker=nullptr;
-	m_sync_worker=nullptr;
 	m_loc_worker=worker::instance();
 	m_sync_worker=tdoa_sync::instance();
 }

+ 41 - 42
websocket/thread_safe_map.h

@@ -1,18 +1,18 @@
 /**
 * @brief
-线程安全模板类
+绾跨▼瀹夊叏妯℃澘绫�
 
 * @version
   V 1.0.0
 
 * @author
-  王益俊
+  鐜嬬泭淇�
 
 * @date
-  创建时间:  2018-08-20\n
+  鍒涘缓鏃堕棿:  2018-08-20\n
 
 * @note
-  2018-08-20  创建类。\n
+  2018-08-20  鍒涘缓绫汇€俓n
 
 * @warning
 
@@ -35,12 +35,12 @@ private:
 public:
 	/**
 	* @brief
-	重置函数。
+	閲嶇疆鍑芥暟銆�
 
 	* @param  [in] const Key &inputKey  key\n
 	* @param  [in] const T &inputValue  value\n
 
-	* @return 无\n
+	* @return 鏃燶n
 
 	* @note
 
@@ -53,17 +53,16 @@ public:
 	{
 		boost::mutex::scoped_lock lock( the_mutex );
 		__map.insert( std::pair<Key, T>( inputKey, inputValue ) );
-		lock.unlock();
 	}
 	/**
 	* @brief
-	返回map是否为空函数。
+	杩斿洖map鏄�惁涓虹┖鍑芥暟銆�
 
-	* @param  无\n
+	* @param  鏃燶n
 
-	* @return 是否为空\n
-	* @retval  true  为空\n
-    * @retval  false  不为空\n
+	* @return 鏄�惁涓虹┖\n
+	* @retval  true  涓虹┖\n
+    * @retval  false  涓嶄负绌篭n
 
 	* @note
 
@@ -79,14 +78,14 @@ public:
 	}
 	/**
 	* @brief
-	用某个key获取值的函数。
+	鐢ㄦ煇涓猭ey鑾峰彇鍊肩殑鍑芥暟銆�
 
-	* @param  [in] const Key &inputKey  指定的key\n
-	* @param  [out] T &outputValue  获得的值\n
+	* @param  [in] const Key &inputKey  鎸囧畾鐨刱ey\n
+	* @param  [out] T &outputValue  鑾峰緱鐨勫€糪n
 
-	* @return 是否获取成功\n
-	* @retval  true  成功\n
-    * @retval  false  失败\n
+	* @return 鏄�惁鑾峰彇鎴愬姛\n
+	* @retval  true  鎴愬姛\n
+    * @retval  false  澶辫触\n
 
 	* @note
 
@@ -112,13 +111,13 @@ public:
 	}
 	/**
 	* @brief
-	用查找某个key是否存在的函数。
+	鐢ㄦ煡鎵炬煇涓猭ey鏄�惁瀛樺湪鐨勫嚱鏁般€�
 
-	* @param  [in] const Key &inputKey  指定的key\n
+	* @param  [in] const Key &inputKey  鎸囧畾鐨刱ey\n
 
-	* @return 是否存在\n
-	* @retval  true  存在\n
-    * @retval  false  不存在\n
+	* @return 鏄�惁瀛樺湪\n
+	* @retval  true  瀛樺湪\n
+    * @retval  false  涓嶅瓨鍦╘n
 
 	* @note
 
@@ -143,14 +142,14 @@ public:
 	}
 	/**
 	* @brief
-	更新某个key对应值的函数。
+	鏇存柊鏌愪釜key瀵瑰簲鍊肩殑鍑芥暟銆�
 
-	* @param  [in] const Key &inputKey  指定的key\n
-	* @param  [out] T &outputValue  获得的值\n
+	* @param  [in] const Key &inputKey  鎸囧畾鐨刱ey\n
+	* @param  [out] T &outputValue  鑾峰緱鐨勫€糪n
 
-	* @return 是否获取成功\n
-	* @retval  true  成功\n
-    * @retval  false  失败\n
+	* @return 鏄�惁鑾峰彇鎴愬姛\n
+	* @retval  true  鎴愬姛\n
+    * @retval  false  澶辫触\n
 
 	* @note
 
@@ -176,11 +175,11 @@ public:
 	}
 	/**
 	* @brief
-	根据某个key删除值的函数。
+	鏍规嵁鏌愪釜key鍒犻櫎鍊肩殑鍑芥暟銆�
 
-	* @param  [in] const Key &inputKey  指定的key\n
+	* @param  [in] const Key &inputKey  鎸囧畾鐨刱ey\n
 
-	* @return 无\n
+	* @return 鏃燶n
 
 	* @note
 
@@ -196,11 +195,11 @@ public:
 	}
 	/**
 	* @brief
-	获得大小的函数。
+	鑾峰緱澶у皬鐨勫嚱鏁般€�
 
-	* @param  无\n
+	* @param  鏃燶n
 
-	* @return 无\n
+	* @return 鏃燶n
 
 	* @note
 
@@ -216,11 +215,11 @@ public:
 	}
 	/**
 	* @brief
-	清除map的函数。
+	娓呴櫎map鐨勫嚱鏁般€�
 
-	* @param  无\n
+	* @param  鏃燶n
 
-	* @return 无\n
+	* @return 鏃燶n
 
 	* @note
 
@@ -236,11 +235,11 @@ public:
 	}
 	/**
 	* @brief
-	拷贝map的函数。
+	鎷疯礉map鐨勫嚱鏁般€�
 
-	* @param  无\n
+	* @param  鏃燶n
 
-	* @return 无\n
+	* @return 鏃燶n
 
 	* @note
 
@@ -254,4 +253,4 @@ public:
 		boost::mutex::scoped_lock lock( the_mutex );
 		dest_map = __map;
 	}
-};
+};