imap proxy and untagged commands

Timo Sirainen tss at iki.fi
Wed Mar 13 13:53:16 UTC 2013


Hi,

I noticed that the IMAP proxying code currently doesn't ignore extra
untagged replies from the backend server. For example this would be a
valid session:

S: * OK Server ready
S: * NO We're having some load issues
C: a login {4}
S: * OK foo
S: + OK
S: * OK bar
C: user pass
S: * OK almost done
S: a OK logged in

In real world Dovecot can already send some extra untagged replies if
there is some trouble (e.g. heavy load) with its authentication process.
What happens is:

S: * OK Waiting for authentication process to respond..
C: a LOGIN {3}
S: * OK Waiting for authentication process to respond..

and nginx fails:

2013/03/13 15:38:55 [error] 7257#0: *15 upstream sent invalid response:
"* OK Waiting for authentication process to respond.." while reading
response from upstream, client: 127.0.0.1, server: 0.0.0.0:10143, login:
"tss", upstream: 127.0.0.1:143

I attempted to fix this, but it looks like the current code doesn't make
this very easy. Especially since it seems to be handling data one "read
block" at a time, which can contain multiple lines, each of which should
be handled separately (the untagged and non-untagged replies may arrive
in the same IP packet).



More information about the nginx-devel mailing list