Opened 12 years ago
Last modified 11 years ago
#5115 new Patches
iostreams non_blocking_adapter read bug
| Reported by: | Owned by: | Jonathan Turkanis | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | iostreams |
| Version: | Boost Development Trunk | Severity: | Showstopper |
| Keywords: | non_blocking_adapter, read | Cc: |
Description
When reading from device resulting amount of read bytes is ignored.
line 31. of boost/iostreams/detail/adapter/non_blocking_adapter.hpp
explicit non_blocking_adapter(Device& dev) : device_(dev) { }
std::streamsize read(char_type* s, std::streamsize n)
{
std::streamsize result = 0;
while (result < n) {
- std::streamsize amt = iostreams::read(device_, s, n);
+ std::streamsize amt = iostreams::read(device_, s, n - result);
if (amt == -1)
break;
result += amt;
}
return result != 0 ? result : -1;
}
Attachments (2)
Change History (5)
comment:1 by , 12 years ago
comment:2 by , 11 years ago
I've added a test case for this bug and a patch.
Also another issue for this adapter is if a device returns 0 as the amount read/written, that would cause a deadlock - endless loop.
comment:3 by , 11 years ago
| Type: | Bugs → Patches |
|---|
Note:
See TracTickets
for help on using tickets.

actually, it should be: