File tree Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ namespace Concurrency { namespace streams {
104
104
virtual size_t buffer_size (std::ios_base::openmode direction = std::ios_base::in) const { return 0 ; }
105
105
virtual void set_buffer_size (size_t size, std::ios_base::openmode direction = std::ios_base::in) { return ; }
106
106
107
- virtual pplx::task<bool > _sync () { return pplx::task_from_result (m_buffer->pubsync () != std::char_traits<_CharType>:: eof () ); }
107
+ virtual pplx::task<bool > _sync () { return pplx::task_from_result (m_buffer->pubsync () == 0 ); }
108
108
109
109
virtual pplx::task<int_type> _putc (_CharType ch) { return pplx::task_from_result (m_buffer->sputc (ch)); }
110
110
virtual pplx::task<size_t > _putn (const _CharType *ptr, size_t size) { return pplx::task_from_result ((size_t )m_buffer->sputn (ptr, size)); }
Original file line number Diff line number Diff line change @@ -1123,21 +1123,20 @@ namespace Concurrency { namespace streams
1123
1123
auto locs = _locals;
1124
1124
auto trg = _target;
1125
1125
1126
- auto after_putn =
1127
- [=](size_t wr) mutable -> bool
1126
+ return _buffer.getn (locs->outbuf , buf_size).then ([=](size_t rd) mutable -> pplx::task<bool >
1128
1127
{
1129
- locs-> total += wr;
1130
- trg. sync (). wait ( );
1131
- return true ;
1132
- };
1133
-
1134
- return _buffer. getn (locs-> outbuf , buf_size). then (
1135
- [=] ( size_t rd) mutable -> pplx::task< bool >
1136
- {
1137
- if ( rd == 0 )
1138
- return pplx::task_from_result ( false ) ;
1139
- return trg. putn (locs-> outbuf , rd). then (after_putn );
1140
- });
1128
+ if ( rd == 0 )
1129
+ return pplx::task_from_result ( false );
1130
+ return trg. putn (locs-> outbuf , rd). then ([=]( size_t wr) mutable -> bool
1131
+ {
1132
+ locs-> total += wr;
1133
+ trg. sync (). wait ();
1134
+ if (rd != wr)
1135
+ // Number of bytes written is less than number of bytes received.
1136
+ throw std::runtime_error ( " failed to write all bytes " );
1137
+ return true ;
1138
+ } );
1139
+ });
1141
1140
}
1142
1141
private:
1143
1142
size_t _buf_size;
You can’t perform that action at this time.
0 commit comments