/** * Restores the signal mask to what it was when `blockSigs()` was called and * unblocks the product-index map. * * @pre {`lockMapAndBlockSigs` was previously called} * @retval 0 Success. * @retval LDM7_SYSTEM System error. `log_add()` called. */ static inline Ldm7Status restoreSignalsAndUnlockMap(void) { restoreSigs(); return unlockMap(); }
void NetHandler::removeConnection(int fd) { NetCache *cache = getCacheFromFd(fd); if (cache != NULL) { //int64 id = cache->uid; lockMap(); fdCache.erase(fd); unlockMap(); delete cache; } }
NetCache *NetHandler::getCacheFromFd(int fd) { NetCache* cache = NULL; lockMap(); map<int, NetCache*>::const_iterator it = fdCache.find(fd); if (it != fdCache.end()) { cache = it->second; } unlockMap(); return cache; }
NetCache *NetHandler::addConnection(int fd, struct sockaddr_in addr, size_t rsize) { NetCache *cache = new NetCache(fd, addr, rsize); lockMap(); fdCache.insert(pair<int, NetCache*>(fd, cache)); unlockMap(); #ifdef _WIN32 if (fd > fdmax) { fdmax = fd; } #endif return cache; }