mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 811596 - Shrink the IPC message buffer after each message is processed. r=cjones.
This commit is contained in:
parent
8ef0755d04
commit
060f9c47ea
@ -363,6 +363,16 @@ bool Channel::ChannelImpl::EnqueueHelloMessage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
ClearAndShrink(std::string& s, size_t capacity)
|
||||
{
|
||||
// This swap trick is the closest thing C++ has to a guaranteed way to
|
||||
// shrink the capacity of a string.
|
||||
std::string tmp;
|
||||
tmp.reserve(capacity);
|
||||
s.swap(tmp);
|
||||
}
|
||||
|
||||
bool Channel::ChannelImpl::Connect() {
|
||||
if (mode_ == MODE_SERVER && uses_fifo_) {
|
||||
if (server_listen_pipe_ == -1) {
|
||||
@ -489,7 +499,7 @@ bool Channel::ChannelImpl::ProcessIncomingMessages() {
|
||||
} else {
|
||||
if (input_overflow_buf_.size() >
|
||||
static_cast<size_t>(kMaximumMessageSize - bytes_read)) {
|
||||
input_overflow_buf_.clear();
|
||||
ClearAndShrink(input_overflow_buf_, Channel::kReadBufferSize);
|
||||
LOG(ERROR) << "IPC message is too big";
|
||||
return false;
|
||||
}
|
||||
@ -573,7 +583,7 @@ bool Channel::ChannelImpl::ProcessIncomingMessages() {
|
||||
}
|
||||
}
|
||||
if (end == p) {
|
||||
input_overflow_buf_.clear();
|
||||
ClearAndShrink(input_overflow_buf_, Channel::kReadBufferSize);
|
||||
} else if (!overflowp) {
|
||||
// p is from input_buf_
|
||||
input_overflow_buf_.assign(p, end - p);
|
||||
|
Loading…
Reference in New Issue
Block a user