devserver: Better accounting of limited update responses.

This is a revision of the dedupe mechanism used for limiting the number
of updates that a client can get from a devserver (a feature that was
originally added to compensate for the lack of a true rule-based
handling of update requests). The way it is currently implemented
sometimes results in a situation where a client receives a "no update"
response instead of the expected "update available" response.

With this change, the devserver only decrements the allowed updates
counter when it receives an event notification from the client that the
download of an update has actually started. Unlike the update request,
whose handling may time out and lead to retransmits, this event is
a unique indication that a client has actually consumed the update. As
before, this accounting is done within a critical section, to prevent
race conditions.

This also takes care of another TODO item: when the devserver receives
a non-update ping, it will correctly return an ack (instead of a "no
update" response, as it currently does).

Finally, this prepends an underscore to internal constant names in
autoupdate_lib.

BUG=chromium:348097
TEST=None

Change-Id: I3cf5a7554e6cbc08df4df4cdadb2706c1747f9ba
Reviewed-on: https://chromium-review.googlesource.com/196314
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
2 files changed