|
@@ -57,7 +57,7 @@ class SessionImpl {
|
|
|
public:
|
|
|
SessionImpl() : sequence_(-1) { queue_ = Element::createFromString("[]"); }
|
|
|
virtual ~SessionImpl() {}
|
|
|
- virtual void establish() = 0;
|
|
|
+ virtual void establish(const char* socket_file = NULL) = 0;
|
|
|
virtual int getSocket() = 0;
|
|
|
virtual void disconnect() = 0;
|
|
|
virtual void writeData(const void* data, size_t datalen) = 0;
|
|
@@ -76,7 +76,7 @@ public:
|
|
|
ASIOSession(io_service& io_service) :
|
|
|
io_service_(io_service), socket_(io_service_), data_length_(0)
|
|
|
{}
|
|
|
- virtual void establish();
|
|
|
+ virtual void establish(const char* socket_file = NULL);
|
|
|
virtual void disconnect();
|
|
|
virtual int getSocket() { return (socket_.native()); }
|
|
|
virtual void writeData(const void* data, size_t datalen);
|
|
@@ -95,9 +95,13 @@ private:
|
|
|
boost::system::error_code error_;
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+
|
|
|
void
|
|
|
-ASIOSession::establish() {
|
|
|
- const char *socket_file = getenv("BIND10_MSGQ_SOCKET_FILE");
|
|
|
+ASIOSession::establish(const char* socket_file) {
|
|
|
+ if (!socket_file) {
|
|
|
+ socket_file = getenv("BIND10_MSGQ_SOCKET_FILE");
|
|
|
+ }
|
|
|
if (!socket_file) {
|
|
|
socket_file = BIND10_MSGQ_SOCKET_FILE;
|
|
|
}
|
|
@@ -105,6 +109,10 @@ ASIOSession::establish() {
|
|
|
if (error_) {
|
|
|
isc_throw(SessionError, "Unable to connect to message queue.");
|
|
|
}
|
|
|
+ socket_.connect(boost::asio::local::stream_protocol::endpoint(socket_file), error_);
|
|
|
+ if (error_) {
|
|
|
+ isc_throw(SessionError, "Unable to connect to message queue.");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void
|
|
@@ -182,7 +190,7 @@ public:
|
|
|
SocketSession() : sock_(-1) {}
|
|
|
virtual ~SocketSession() { disconnect(); }
|
|
|
virtual int getSocket() { return (sock_); }
|
|
|
- void establish();
|
|
|
+ void establish(const char* socket_file = NULL);
|
|
|
virtual void disconnect()
|
|
|
{
|
|
|
if (sock_ >= 0) {
|
|
@@ -217,7 +225,7 @@ public:
|
|
|
}
|
|
|
|
|
|
void
|
|
|
-SocketSession::establish() {
|
|
|
+SocketSession::establish(const char* socket_file) {
|
|
|
int s;
|
|
|
struct sockaddr_un sun;
|
|
|
|
|
@@ -225,8 +233,10 @@ SocketSession::establish() {
|
|
|
if (s < 0) {
|
|
|
isc_throw(SessionError, "socket() failed");
|
|
|
}
|
|
|
-
|
|
|
- const char *socket_file = getenv("BIND10_MSGQ_SOCKET_FILE");
|
|
|
+
|
|
|
+ if (!socket_file) {
|
|
|
+ socket_file = getenv("BIND10_MSGQ_SOCKET_FILE");
|
|
|
+ }
|
|
|
if (!socket_file) {
|
|
|
socket_file = BIND10_MSGQ_SOCKET_FILE;
|
|
|
}
|
|
@@ -296,8 +306,8 @@ Session::startRead(boost::function<void()> read_callback) {
|
|
|
}
|
|
|
|
|
|
void
|
|
|
-Session::establish() {
|
|
|
- impl_->establish();
|
|
|
+Session::establish(const char* socket_file) {
|
|
|
+ impl_->establish(socket_file);
|
|
|
|
|
|
// once established, encapsulate the implementation object so that we
|
|
|
// can safely release the internal resource when exception happens
|