Mercurial > dovecot > core-2.2
changeset 21934:76fdf3886569
lib-imap-client: Make command tag counter externally accessible
This allows unit tests to reset it.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 10 Apr 2017 16:18:46 +0300 |
parents | a892db12fd6a |
children | 6bcbb61a2943 |
files | src/lib-imap-client/imapc-client-private.h src/lib-imap-client/imapc-client.c src/lib-imap-client/imapc-connection.c |
diffstat | 3 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-imap-client/imapc-client-private.h Mon Apr 10 15:49:24 2017 +0300 +++ b/src/lib-imap-client/imapc-client-private.h Mon Apr 10 16:18:46 2017 +0300 @@ -49,6 +49,8 @@ bool closing; }; +extern unsigned int imapc_client_cmd_tag_counter; + void imapc_client_ref(struct imapc_client *client); void imapc_client_unref(struct imapc_client **client);
--- a/src/lib-imap-client/imapc-client.c Mon Apr 10 15:49:24 2017 +0300 +++ b/src/lib-imap-client/imapc-client.c Mon Apr 10 16:18:46 2017 +0300 @@ -31,6 +31,8 @@ { NULL, 0 } }; +unsigned int imapc_client_cmd_tag_counter = 0; + static void default_untagged_callback(const struct imapc_untagged_reply *reply ATTR_UNUSED, void *context ATTR_UNUSED)
--- a/src/lib-imap-client/imapc-connection.c Mon Apr 10 15:49:24 2017 +0300 +++ b/src/lib-imap-client/imapc-connection.c Mon Apr 10 16:18:46 2017 +0300 @@ -1873,7 +1873,6 @@ static struct imapc_command * imapc_command_begin(imapc_command_callback_t *callback, void *context) { - static unsigned int cmd_tag_counter = 0; struct imapc_command *cmd; pool_t pool; @@ -1885,9 +1884,11 @@ cmd->callback = callback; cmd->context = context; - if (++cmd_tag_counter == 0) - cmd_tag_counter++; - cmd->tag = cmd_tag_counter; + /* use a globally unique tag counter so looking at rawlogs is + somewhat easier */ + if (++imapc_client_cmd_tag_counter == 0) + imapc_client_cmd_tag_counter++; + cmd->tag = imapc_client_cmd_tag_counter; return cmd; }