Timo Sirainen [Mon, 22 Feb 2016 18:47:37 +0000 (20:47 +0200)]
lib-http: Clarify http_client_request_*_payload() API and minor change to it
The earlier behavior was pretty confusing, and potentially could have caused
double-freeing memory in some situations. Now it's clear that req is set to NULL
always when the request is finished, regardless of whether it has any references left.
Changed http_client_request_finish_payload() to return 0 on success instead of 1.
This could have been left alone, but it's unlikely that there is any code outside
Dovecot core that calls it and this way is cleaner.
Timo Sirainen [Mon, 22 Feb 2016 18:34:46 +0000 (20:34 +0200)]
lib-http: http_client_request_unref() now always sets *req=NULL
This makes its behavior consistent with other APIs in Dovecot.
Also http_client_request_finish() no longer sets req=NULL, because all of
its callers already keep a reference. Instead added an assert to make sure
the reference is there.
Maildir and mbox formats were using index_sync_changes_read(), which assumed that
they were sorted. So some of the intended expunges weren't actually always being
done. This mainly affected when expunges were being done simultaneously by multiple
processes or by pipelined commands. For example:
Aki Tuomi [Mon, 15 Feb 2016 12:02:19 +0000 (14:02 +0200)]
doveadm: Add infrastructure for doveadm_cmd_ver2
Version 2 commands have named parameters, which also have types. This is
especially useful for reading input from HTTP/JSON API. This also simplifies
the parameter parsing for command line input.
For v2.3 the plan is to replace all the old doveadm_cmds with this new
version and get rid of the _ver2 suffixes. But for now we'll have two
versions of commands.
For backwards compatibility with old commands we have also implemented
wrappers so that v2 structs can be defined and there's a function to convert
the named parameters to old v1 style args[] string, so the old command
handlers can still be run. This will also be removed in v2.3.
This change also adds requirement for getopt_long(). It's already available
in all the Linuxes and BSDs, so this shouldn't be too big of a requirement.
Other systems can install it from an external library.
Timo Sirainen [Thu, 11 Feb 2016 11:25:28 +0000 (13:25 +0200)]
auth: Moved all passdb/userdb template handling to auth_passdb/userdb.
This is because passdb_find() and userdb_find() attempts to avoid
duplicating passdbs and userdbs when they have identical driver+args.
This deduplication is useful when using multiple protocol { .. } blocks
that duplicate some passdb/userdb backends. For example we might want
to have only a single SQL connection regardless of how the protocol-specific
passdbs and userdbs are being set up. All the default/override_fields and
result_* settings aren't relevant to the passdb/userdb backends, so removing
them will again allow the deduplication to work correctly.
Stephan Bosch [Wed, 10 Feb 2016 22:39:25 +0000 (23:39 +0100)]
lib-http: Created test program that tests payload exchange between client and server with various configurations.
It recursively uses all files in the current directory as payload.
It is currenrly not part of `make check', because it is a stress-testing tool that can run for a long time.
Stephan Bosch [Mon, 8 Feb 2016 21:57:13 +0000 (22:57 +0100)]
lib-http: message parser: Made sure that payload stream is always destroyed (hence closed) when the next request is to be parsed.
This makes sure that the connection input is always at the correct position
for the next request. Remaining references to the payload stream could
theoretically mess this up.
Stephan Bosch [Mon, 8 Feb 2016 21:55:09 +0000 (22:55 +0100)]
lib-http: server: Make sure that any pending request is aborted and destroyed before connection FDs are closed.
This way, any payload io struct created from the request callback can be
freed before the associated FD becomes invalid. This would cause an assert
failure otherwise.
Stephan Bosch [Mon, 8 Feb 2016 21:49:28 +0000 (22:49 +0100)]
lib-http: request parser: Made sure that partially parsed requests never have stale string values.
Due to the fact that we assign method and target fields early for proper
error messages, stale fields from previous requests could have ended up in a
partially parsed new request.
Stephan Bosch [Mon, 8 Feb 2016 21:45:54 +0000 (22:45 +0100)]
lib-http: client: Make sure that any pending request is aborted and destroyed before connection FDs are closed.
This way, any payload io struct created from the response callback can be freed before the associated FD becomes invalid.
This would cause an assert failure otherwise.