void process_connect_requests()

in src/afs.cc [2538:2610]


	void process_connect_requests()
	{
		std::lock_guard<std::mutex> lock(mutex_);
		bool haveRequest = false;
		for (auto it = connectRequests_.begin(); it != connectRequests_.end();)
		{
			auto& request = *it;
			ProcessorLockGuard lock(this);
			if (request->processing)
			{
				auto session = static_cast<SharedSessionData*>(
					dshash_find(sessions_, &(request->sessionID), false));
				if (!session)
				{
					++it;
					continue;
				}
				const auto initialized = session->initialized;
				if (initialized && !DsaPointerIsValid(session->errorMessage))
				{
					auto& localSession = localSessions_.find(request->sessionID)->second;
					localSession->valid = true;
					localSession->peerPID = session->executorPID;
					localSession->bufferData = &(session->bufferData);
					localSession->bufferAddress =
						dsa_get_address(area_, session->bufferData.pointer);
					P("%s: %s: connect: %" PRIu64,
					  Tag,
					  tag_,
					  session->bufferData.pointer);
				}
				dshash_release_lock(sessions_, session);
				if (!initialized)
				{
					++it;
					continue;
				}
				request->finished = true;
				it = connectRequests_.erase(it);
			}
			else
			{
				bool found;
				auto session = static_cast<SharedSessionData*>(
					dshash_find_or_insert(sessions_, &(request->sessionID), &found));
				if (found)
				{
					request->finished = true;
					auto& localSession = localSessions_.find(request->sessionID)->second;
					localSession->errorMessage = std::string("duplicated session ID: ") +
					                             std::to_string(request->sessionID);
					it = connectRequests_.erase(it);
				}
				else
				{
					request->processing = true;
					shared_session_data_initialize(session,
					                               area_,
					                               request->databaseName,
					                               request->userName,
					                               request->password,
					                               request->clientAddress);
					haveRequest = true;
					++it;
				}
				dshash_release_lock(sessions_, session);
			}
		}
		if (haveRequest)
		{
			kill(sharedData_->mainPID, SIGUSR1);
		}
	}