Fix: set metadata closed on a push/close metadata error

Check the metadata closed flag before pushing and closing the metadata
on the consumer side. On any error from those two actions, the closed
flag is set to indicate to stop using the metadata registry until a
destroy is done.

Also, before creating a metadata, a check is done to see if the registry
metadata was closed previously or else a new metadata key is created and
the old values from the previous channel in the registry are used
causing a bad state on the consumer.

With per UID buffers, the metadata cache is shared accross multiple
applications so if the metadata buffers were deleted on the consumer for
whatever reasons, we must STOP using it or else undesired behaviors have
been observed such as causing synchronization issues between the state
of the consumer and sessiond.

A destroy session command will wipe the faulty metadata.

Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Fix: add more conditions and a lock to metadata cache flushed

Some more conditions applies to return if the metadata cache is indeed
flushed. If no metadata stream is found or the endpoint status is set to
something other than ACTIVE, this means the channel is being (or will
be) destroyed thus the metadata cache can't be updated so is indeed
"flushed".

Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>