mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
sh2lib: Fix a bug in send
This commit is contained in:
parent
568da37af7
commit
fe1889b923
@ -58,22 +58,19 @@ static ssize_t callback_send(nghttp2_session *session, const uint8_t *data,
|
||||
int pending_data = length;
|
||||
|
||||
/* Send data in 1000 byte chunks */
|
||||
while (copy_offset != (length - 1)) {
|
||||
while (copy_offset != length) {
|
||||
int chunk_len = pending_data > 1000 ? 1000 : pending_data;
|
||||
int subrv = callback_send_inner(hd, data + copy_offset, chunk_len);
|
||||
if (subrv <= 0) {
|
||||
if (copy_offset) {
|
||||
/* If some data was xferred, send the number of bytes
|
||||
* xferred */
|
||||
rv = copy_offset;
|
||||
} else {
|
||||
/* If not, send the error code */
|
||||
if (copy_offset == 0) {
|
||||
/* If no data is transferred, send the error code */
|
||||
rv = subrv;
|
||||
}
|
||||
break;
|
||||
}
|
||||
copy_offset += chunk_len;
|
||||
pending_data -= chunk_len;
|
||||
copy_offset += subrv;
|
||||
pending_data -= subrv;
|
||||
rv += subrv;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user