Commit graph

10 commits

Author SHA1 Message Date
Michael Meeks
5da4116731 Buffer: remove _size member and calculate it from _offset as needed.
Change-Id: I96bd949f1e9c460fbaf69967072e85cf45141acd
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-11-30 09:32:45 +00:00
Michael Meeks
a958b30d56 Buffer: erase fully when we wrote everything that is left.
This avoids memory hanging around, _buffer.size() is not data
left as seen in pkill -USR1 output:

coolwsd[25677]:  Buffer size: 0 offset: 421811

Change-Id: I0c2eef9435230cf864854cbc95cd587e39d240ac
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2021-11-30 09:32:45 +00:00
Luboš Luňák
897c5df270 make Socket use Buffer for input buffer too
SteamSocket::eraseFirstInputBytes() removes from the beginning
of std::vector, which is generally slow. If the buffer becomes
too big, which it may under a load, then the function will get
slow, which in turn will likely lead to the buffer getting even
bigger because of accumulated backlog.

The Buffer class is optimized for removal at the beginning,
so use it instead of std::vector, including some API additions
for it to be an in-place replacement where it's used.

Signed-off-by: Luboš Luňák <l.lunak@collabora.com>
Change-Id: I4cf7ec56c908c7d3df391dc3f8e230ad32abb162
2021-10-26 12:11:58 +02:00
Ashod Nakashian
dc5ca2738e wsd: http: simplify appending to Buffer
Instead of supporting char appending,
we now support appending literal strings
with size capturing. This covers both
single- and multi-character appending
without the need for an explicit size.

Change-Id: Iee2c20b7aa2cdb6863c88e91cd770205719c2ba6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
(cherry picked from commit 96e3e88a014960a5249fc83a5b2f3b785ac8737d)
2021-05-02 22:35:39 -04:00
Ashod Nakashian
5749d7457d wsd: http: improve StatusLine
And update unit-tests.

Change-Id: I29bcb8232c77d3c0c1fe316854417726671765f1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-22 10:09:22 -04:00
Ashod Nakashian
5467a7f7ef wsd: simplify and document dumpHex
Change-Id: I636dd6548b0712a72dfc162eb7381e3e7ac18b5a
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2021-03-13 19:34:02 -05:00
Michael Meeks
4082975330 Fix unit test to not rely on under-defined behavior.
Change-Id: I4ad9ce7710f7f25884ca2ab31aabd82e2dc5be8e
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-11-29 19:27:23 -05:00
Ashod Nakashian
b87495a791 wsd: test: add Buffer test and minor cosmetics
Change-Id: Ie4ac80984523ecd32fd81238496253b6a4015692
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2020-11-29 19:27:23 -05:00
Michael Meeks
0fc91ef31c Adapt Buffer class to avoid repeated compactions.
Avoid continually shuffling large output buffers down in memory,
it kills CPU caches, does nothing useful, and we can just advance
an offset instead. Of course, we do need to free memory - so do
that for lots of common cases.

Change-Id: I63240661ca87bdc0574acbce856771d9dde3fa94
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-11-29 19:27:23 -05:00
Michael Meeks
e00392647b pure re-factor, creating Buffer class to wrap vector.
For large transfers eg. image previews, particularly with SSL's
protocol limit of 16k byte blocks, we see lots of inefficiency
repeatedly copying a 20Mb image and shuffling it down a
std::vector as we write data out.

Change-Id: I620568cad2e6f41684c35289b0ee77cf7f59c077
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2020-11-29 19:27:23 -05:00