@@ -377,11 +377,11 @@ struct Overload {
377377 };
378378
379379 inline static std::vector<std::thread> threads;
380- inline static std::map <unsigned long long , SOCKET> incomingSocketMap;
381- inline static std::map <unsigned long long , TcpData> tcpDataMap;
382- inline static std::map <unsigned long long , EventData> eventDataMap;
383- inline static std::map <unsigned long long , bool > isReceiveThreadSetupMap;
384- inline static std::map <unsigned long long , bool > isSendThreadSetupMap;
380+ inline static std::unordered_map <unsigned long long , SOCKET> incomingSocketMap;
381+ inline static std::unordered_map <unsigned long long , TcpData> tcpDataMap;
382+ inline static std::unordered_map <unsigned long long , EventData> eventDataMap;
383+ inline static std::unordered_map <unsigned long long , bool > isReceiveThreadSetupMap;
384+ inline static std::unordered_map <unsigned long long , bool > isSendThreadSetupMap;
385385 inline static EventQueue<TransmitRequest> transmitQueue;
386386 inline static EventQueue<ReceiveRequest> receiveQueue;
387387
@@ -996,7 +996,10 @@ struct Overload {
996996 CreateChild (NULL , &ListenToken->NewChildHandle );
997997 // At this point we dont know the tcp4Protocol for this peer (tcp4Protocol will be inititialzed in peerConnectionNewlyEstablished())
998998 // so we map the clientSocket to the handle to process it later in peerConnectionNewlyEstablished()
999- incomingSocketMap[(unsigned long long )ListenToken->NewChildHandle ] = clientSocket;
999+ {
1000+ std::lock_guard<std::mutex> lock (networkingLock);
1001+ incomingSocketMap[(unsigned long long )ListenToken->NewChildHandle ] = clientSocket;
1002+ }
10001003 ListenToken->CompletionToken .Status = EFI_SUCCESS;
10011004 tcpData->connectStatus = ConnectStatus::Connected;
10021005 });
@@ -1223,6 +1226,9 @@ struct Overload {
12231226 transmitProcessorThread.detach ();
12241227 std::thread receiveProcessorThread (receiveProcessor);
12251228 receiveProcessorThread.detach ();
1229+
1230+ // Reserve space
1231+ incomingSocketMap.reserve (1024 );
12261232 }
12271233};
12281234
0 commit comments