Fixing deadlocks with caldecott tunneling.
Fixing deadlocks with caldecott tunneling.

The caldecott server can send more than the BUFFER_SIZE due to the way it is written.
It only stops receiving data if more than 1mb (currently) is pulled. So it can be just over
1mb.

The current code passes the 1mb to the client application then goes to read from the tunnel again
with data still in the buffer. If the client application is waiting for this data before sending a response
and the server is waiting for the response we get into a dead lock.

Lets makes sure we have sent all data in the buffer before we try to read again.

cloudfoundry-attic/caldecott-client,cloudfoundry-attic/caldecott-client