view src/imap/cmd-x-cancel.c @ 22633:9284bdc3c5c5

director: Don't recreate timeout on every user lookup Recreate it only when the timeout should change.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sat, 04 Nov 2017 01:34:02 +0200
parents 2e2563132d5f
children cb108f786fb4
line wrap: on
line source

/* Copyright (c) 2006-2017 Dovecot authors, see the included COPYING file */

#include "imap-common.h"
#include "imap-commands.h"

bool cmd_x_cancel(struct client_command_context *cmd)
{
	struct client_command_context *cancel_cmd;
	const char *tag;

	/* <tag> */
	if (!client_read_string_args(cmd, 1, &tag))
		return FALSE;

	cancel_cmd = cmd->client->command_queue;
	for (; cancel_cmd != NULL; cancel_cmd = cancel_cmd->next) {
		if (cancel_cmd->tag != NULL && cancel_cmd != cmd &&
		    strcmp(cancel_cmd->tag, tag) == 0) {
			client_command_cancel(&cancel_cmd);
			client_send_tagline(cmd, "OK Command cancelled.");
			return TRUE;
		}
	}

	client_send_tagline(cmd, "NO Command tag not found.");
	return TRUE;
}