/*
- * Copyright (c) 2014-2022 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2014-2022 Samsung Electronics Co., Ltd. All rights reserved
*
* This file is licensed under the terms of MIT License or the Apache License
* Version 2.0 of your choice. See the LICENSE.MIT file for MIT license details.
Service *m_service = nullptr;
fd_set m_readSet;
fd_set m_writeSet;
- int m_maxDesc = 0;
+ int m_maxDesc = -1;
int m_signalFd, m_listenSock = -1, m_notifyMe;
time_t m_nextGenerationStart = 0;
std::mutex m_eventQueueMutex;
void SocketManager::RegisterFdForReading(int fd) {
FD_SET(fd, &m_readSet);
- m_maxDesc = std::max(m_maxDesc, fd);
+ if (m_maxDesc < fd) {
+ m_maxDesc = fd;
+ if ((int)m_socketDescriptionVector.size() <= fd)
+ m_socketDescriptionVector.resize(fd+20);
+ }
}
void SocketManager::CreateDefaultReadSocketDescription(int sock)
{
- if ((int)m_socketDescriptionVector.size() <= sock)
- m_socketDescriptionVector.resize(sock+20);
+ RegisterFdForReading(sock);
auto &desc = m_socketDescriptionVector[sock];
desc.isOpen = true;
desc.isActiveThisGeneration = true;
desc.buffer.InitForInput();
-
- RegisterFdForReading(sock);
}
SocketManager::SocketManager()