Skip to content

Commit

Permalink
[FSCP] Disables buffer recycling mechanism as it may introduce an issue
Browse files Browse the repository at this point in the history
of circular references.

More specifically in current way of recycling, we use some lambda
expressions that at one time capture the SharedBuffer variable. The lambda
is stored as the deleter of the shared_ptr holding the SharedBuffer.
  • Loading branch information
s-vincent committed Dec 14, 2018
1 parent 8c0e872 commit 82830f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libs/freelan/src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2054,16 +2054,21 @@ namespace freelan
return result;
}();

// disable buffer recycling from now (possible issue with SharedBuffer
// which references itself due to lambda capture)
m_tap_adapter->async_read(
buffer(receive_buffer),
boost::bind(
&core::do_handle_tap_adapter_read,
this,
/*
SharedBuffer(receive_buffer, [this](const SharedBuffer& buffer) {
m_tap_adapter_io_service.post([this, buffer] () {
m_tap_adapter_buffers.push_back(buffer);
});
}),
*/
receive_buffer,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred
)
Expand Down
18 changes: 18 additions & 0 deletions libs/fscp/src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1537,12 +1537,17 @@ namespace fscp
);
}

// disable buffer recycling from now (possible issue with SharedBuffer
// which references itself due to lambda capture)
async_send_to(
/*
SharedBuffer(send_buffer, [this](const SharedBuffer& buffer) {
m_session_strand.post([this, buffer]() {
m_session_buffers.push_back(buffer);
});
}),
*/
send_buffer,
size,
target,
handler
Expand Down Expand Up @@ -1824,12 +1829,17 @@ namespace fscp
);
}

// disable buffer recycling from now (possible issue with SharedBuffer
// which references itself due to lambda capture)
async_send_to(
/*
SharedBuffer(send_buffer, [this](const SharedBuffer& buffer) {
m_session_strand.post([this, buffer]() {
m_session_buffers.push_back(buffer);
});
}),
*/
send_buffer,
size,
target,
[] (const boost::system::error_code&) {}
Expand Down Expand Up @@ -2139,12 +2149,17 @@ namespace fscp
buffer_size(p_session.current_session().local_nonce_prefix)
);

// disable buffer recycling from now (possible issue with SharedBuffer
// which references itself due to lambda capture)
async_send_to(
/*
SharedBuffer(send_buffer, [this](const SharedBuffer& buffer) {
m_session_strand.post([this, buffer]() {
m_session_buffers.push_back(buffer);
});
}),
*/
send_buffer,
size,
target,
handler
Expand Down Expand Up @@ -2370,11 +2385,14 @@ namespace fscp
do_handle_data_message(
sender,
type,
/*
SharedBuffer(cleartext_buffer, [this] (const SharedBuffer& buffer) {
m_session_strand.post([this, buffer] () {
m_session_buffers.push_back(buffer);
});
}),
*/
cleartext_buffer,
buffer(cleartext_buffer, cleartext_len)
);
}
Expand Down

0 comments on commit 82830f2

Please sign in to comment.