Skip to content

reset each ksmclient's state after logout is canceled

reset each ksmclient's state in cancelShutdown function. if we don't do it, after cancelShutdown is executed, if one application ask for interact after the cancelShutdown operation, the interactRequest function will be executed,

	void KSMServer::interactRequest(KSMClient *client, int /*dialogType*/)
	{
		if (state == Shutdown || state == ClosingSubSession)
			client->pendingInteraction = true;
		else
			SmsInteract(client->connection());

		handlePendingInteractions();
	}

since now the state is not Shutdown, ksmserver will directly give the interact permission to the application, then goes into the handlePendingInteractions(),

	void KSMServer::handlePendingInteractions()
	{
		if (clientInteracting)
			return;

		foreach (KSMClient *c, clients) {
			if (c->pendingInteraction) {
			    clientInteracting = c;
			    c->pendingInteraction = false;
			    break;
			}
		}
		if (clientInteracting) {
			endProtection();
			SmsInteract(clientInteracting->connection());
		} else {
			startProtection();
		}
	}

that is where the problem happens, the clientInteracting is nullptr, so the function will continue execute, at the foreach loop, the status of all clients is the same as at the time of the previous logout, that means some of the client are still pendingInteraction, so one of the client will be initialized as the clientInteracting and been given the interact permission, usually the client won't do anything, but it was not the client but the clientInteracting will cause a trouble.

at this moment, if user perform another logout operation, when the logout flow goes to the handlePendingInteractions() function, since the clientInteracting is not nullptr, the handlePendingInteractions function will not be truly execute, causing the delay of the whole logout operation.

Edited by Aleix Pol Gonzalez

Merge request reports