@@ -37,8 +37,8 @@ namespace mozart { namespace boostenv {
37
37
// TCPConnection //
38
38
// /////////////////
39
39
40
- TCPConnection::TCPConnection (BoostVM& boostVM ):
41
- BaseSocketConnection (boostVM ), _resolver(boostVM. env.io_service) {
40
+ TCPConnection::TCPConnection (VM vm ):
41
+ BaseSocketConnection (vm ), _resolver(env.io_service) {
42
42
}
43
43
44
44
void TCPConnection::startAsyncConnect (std::string host, std::string service,
@@ -51,12 +51,12 @@ void TCPConnection::startAsyncConnect(std::string host, std::string service,
51
51
auto connectHandler = [=] (const boost::system::error_code& error,
52
52
protocol::resolver::iterator selected_endpoint) {
53
53
if (!error) {
54
- boostVM .postVMEvent ([=] () {
54
+ env .postVMEvent (vm, [=] (BoostVM& boostVM ) {
55
55
boostVM.bindAndReleaseAsyncIOFeedbackNode (
56
56
statusNode, build (boostVM.vm , self));
57
57
});
58
58
} else {
59
- boostVM .postVMEvent ([=] () {
59
+ env .postVMEvent (vm, [=] (BoostVM& boostVM ) {
60
60
boostVM.raiseAndReleaseAsyncIOFeedbackNode (
61
61
statusNode, " socket" , " connect" , error.value ());
62
62
});
@@ -65,7 +65,7 @@ void TCPConnection::startAsyncConnect(std::string host, std::string service,
65
65
66
66
boost::asio::async_connect (socket (), endpoints, connectHandler);
67
67
} else {
68
- boostVM .postVMEvent ([=] () {
68
+ env .postVMEvent (vm, [=] (BoostVM& boostVM ) {
69
69
boostVM.raiseAndReleaseAsyncIOFeedbackNode (
70
70
statusNode, " socket" , " resolve" , error.value ());
71
71
});
@@ -80,27 +80,28 @@ void TCPConnection::startAsyncConnect(std::string host, std::string service,
80
80
// TCPAcceptor //
81
81
// ///////////////
82
82
83
- TCPAcceptor::TCPAcceptor (BoostVM& boostVM ,
83
+ TCPAcceptor::TCPAcceptor (VM vm ,
84
84
const tcp::endpoint& endpoint):
85
- boostVM (boostVM), _acceptor(boostVM.env.io_service, endpoint) {
85
+ env (BoostEnvironment::forVM(vm)),
86
+ vm (BoostVM::forVM(vm).identifier),
87
+ _acceptor (env.io_service, endpoint) {
86
88
}
87
89
88
- void TCPAcceptor::startAsyncAccept (const ProtectedNode& connectionNode) {
89
- TCPConnection::pointer connection = TCPConnection::create (boostVM);
90
-
90
+ void TCPAcceptor::startAsyncAccept (TCPConnection::pointer connection,
91
+ const ProtectedNode& connectionNode) {
91
92
auto handler = [=] (const boost::system::error_code& error) {
92
93
if (!error) {
93
- boostVM .postVMEvent ([=] () {
94
+ env .postVMEvent (vm, [=] (BoostVM& boostVM ) {
94
95
boostVM.bindAndReleaseAsyncIOFeedbackNode (
95
96
connectionNode, build (boostVM.vm , connection));
96
97
});
97
98
} else if (error == boost::asio::error::operation_aborted) {
98
- boostVM .postVMEvent ([=] () {
99
+ env .postVMEvent (vm, [=] (BoostVM& boostVM ) {
99
100
boostVM.releaseAsyncIONode (connectionNode);
100
101
});
101
102
} else {
102
103
// Try again
103
- startAsyncAccept (connectionNode);
104
+ startAsyncAccept (connection, connectionNode);
104
105
}
105
106
};
106
107
0 commit comments