coreos/go-etcd — pull request #145 by marc-barry (2014-07-15 17:59:46+00:00)
Title: Fix issues with long-term watches exiting and add more debug messages

This PR fixes our issues as seen in #143. Below is a list of things that were added.

- adds more debugging messages
- adds a custom transport which detects the StatusTemporaryRedirect status and updates the cluster leader accordingly
- adds a mutex to the Cluster functions o make them thread safe

**I can remove this from the PR if need be. The more I look at the code the more I think that that ```Client``` is not thread-safe. Although, I can't find any explicit reference to the thread safety of ```Client```.**
- adds zero body size detection to the watch code so that we don't get unmarshal errors which cause the watch function to exit

**This is the root cause of the long-term watches exiting. For some reason ```etcd``` can and will send an empty body which would cause unmarshaling issues for the watch.**