handle http union transition properly
authorAndy Green <andy.green@linaro.org>
Mon, 18 Feb 2013 01:48:31 +0000 (09:48 +0800)
committerAndy Green <andy.green@linaro.org>
Mon, 18 Feb 2013 01:48:31 +0000 (09:48 +0800)
commit0caf9c5acb00083ee21a70bd219079289c0ff02f
tree6128cd9c59699313a688b6ca9b045b9b63a9bc41
parent51b20ee92ab96dfc4a231e57bc4e631f06183bef
handle http union transition properly

There's no proper transition to http union state until now.

It only becomes apparant there's a problem when you try to
return -1 from the HTTP callback, during the close action
it will try to close() a nonsense, nonzero fd pointer in
the uninitialized u.http union member.

This patch takes a copy of the allocated headers struct from
the u.hdr union state, transitions to u.http clearing down u
and then calls the HTTP callback with URI args pointing to
the still-in-scope ah allocation.  After the call, the copy ah
is freed.

That makes sure we are in the correct union state while still
giving the HTTP callback access to the URI without having to
copy it around.

Reported-by: Edwin can den Oetelaar <oetelaar.automatisering@gmail.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
lib/handshake.c