face: Implementation of encode/decode of LocalControlHeader
LocalControlHeader can only be used on faces that are derived from
LocalFace. UnixStreamFace is directly inherited from LocalFace,
TCP face has two specializations: generic TcpFace (strictly not local),
and LocalTcpFace.
refs #1213
Change-Id: I8a158c3bc4bb929eedd15757cfddecc0d1049f9f
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index 087a24c..34b734a 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -123,7 +123,12 @@
{
tcp::Endpoint remoteEndpoint = socket->remote_endpoint();
- shared_ptr<TcpFace> face = make_shared<TcpFace>(boost::cref(socket));
+ shared_ptr<Face> face;
+ if (socket->local_endpoint().address().is_loopback())
+ face = make_shared<TcpLocalFace>(boost::cref(socket));
+ else
+ face = make_shared<TcpFace>(boost::cref(socket));
+
face->onFail += bind(&TcpChannel::afterFaceFailed, this, remoteEndpoint);
onFaceCreated(face);