void CDspIOCtClientHandler::handleClientConnected ( const IOSender::Handle& h )
{
	WRITE_TRACE( DBG_WARNING, "CDspIOCtClientHandler::handleClientConnected %s",
			QSTR2UTF8(h));
	QMutexLocker locker( &m_mutex );
	m_ioClients[h] = ClientInfo();
}
void
NetworkXioIOHandler::update_fs_client_info(const std::string& volume_name)
{
    uint16_t port = 0;
    std::string host;

    xio_connection_attr xcon_peer;
    int ret = xio_query_connection(cd_->conn,
                                   &xcon_peer,
                                   XIO_CONNECTION_ATTR_USER_CTX |
                                   XIO_CONNECTION_ATTR_PEER_ADDR);
    if (ret < 0)
    {
        LOG_ERROR(volume_name << ": failed to query the xio connection: " <<
                  xio_strerror(xio_errno()));
    }
    else
    {
        const yt::SocketAddress sa(xcon_peer.peer_addr);
        port = sa.get_port();
        host = sa.get_ip_address();
    }

    const FrontendPath volume_path(make_volume_path(volume_name));
    cd_->tag = fs_.register_client(ClientInfo(fs_.find_id(volume_path),
                                              std::move(host),
                                              port));
}
void NetworkServer::checkForNewClients() {
	std::vector<sf::TcpSocket *> updatedClients = communicator.getClients();
	std::vector<sf::TcpSocket *> newClients;
	std::vector<sf::TcpSocket *> lostClients;
	for(int i=0; i<updatedClients.size(); i++) {
		if(!isInClientList(updatedClients[i]))
			newClients.push_back(updatedClients[i]);
	}
	for(int i=0; i<clients.size(); i++) {
		if(!isClientInUpdatedList(clients[i].tcp, updatedClients))
			lostClients.push_back(clients[i].tcp);
	}
	
	for(int i=0; i<newClients.size(); i++) {
		clients.push_back(ClientInfo());
		clients[clients.size()-1].tcp = newClients[i];
		clients[clients.size()-1].ip = newClients[i]->getRemoteAddress();
		sendTcpBySocket("_CONNECT"+std::to_string(udpSocket.getLocalPort()), clients[clients.size()-1].tcp);
	}
	
	for(int i=0; i<newClients.size(); i++)
		gotNewClient(newClients[i]->getRemoteAddress());
	for(int i=0; i<lostClients.size(); i++)
		lostClient(lostClients[i]->getRemoteAddress());
}
예제 #4
0
bool EntriesManager::addClient(RequestContext::ClientId clientId, uint16_t bufferSize) {
    if (clientId == RequestContext::InvalidClientId) {
        LOGE("Invalid client id");
        return false;
    }
    if (m_clients.find(clientId) != m_clients.end()) {
        LOGE("Client [" << clientId << "] already exists, use modify instead");
        return false;
    }
    /*
     * For the first time client is registered for future entry, after this its state is kept,
     * so client can fetch entries continuously
     */
    EntriesQueue::EntryId startPoint = m_container.getBackEntryId();
    auto itInfo = m_clients.emplace(clientId, ClientInfo(clientId, startPoint, bufferSize));
    addEntryCount(startPoint, itInfo.first);
    registerClient(clientId, itInfo.first);
    return true;
}