Skip to content

Commit a92ee3e

Browse files
committed
Merge branch 'ul-gh-fix_#888' into yuboxfixes
2 parents 646eab7 + d4bdf99 commit a92ee3e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/AsyncEventSource.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,17 @@ size_t AsyncEventSourceMessage::ack(size_t len, uint32_t time) {
137137
return 0;
138138
}
139139

140+
// This could also return void as the return value is not used.
141+
// Leaving as-is for compatibility...
140142
size_t AsyncEventSourceMessage::send(AsyncClient *client) {
141-
const size_t len = _len - _sent;
142-
if(client->space() < len){
143-
return 0;
144-
}
145-
size_t sent = client->add((const char *)_data, len);
146-
if(client->canSend())
147-
client->send();
148-
_sent += sent;
149-
return sent;
143+
if (_sent >= _len) {
144+
return 0;
145+
}
146+
const size_t len_to_send = _len - _sent;
147+
auto position = reinterpret_cast<const char*>(_data + _sent);
148+
const size_t sent_now = client->write(position, len_to_send);
149+
_sent += sent_now;
150+
return sent_now;
150151
}
151152

152153
// Client

0 commit comments

Comments
 (0)