sh2lib: Fix a bug in send
This commit is contained in:
parent
568da37af7
commit
fe1889b923
1 changed files with 6 additions and 9 deletions
|
@ -58,22 +58,19 @@ static ssize_t callback_send(nghttp2_session *session, const uint8_t *data,
|
||||||
int pending_data = length;
|
int pending_data = length;
|
||||||
|
|
||||||
/* Send data in 1000 byte chunks */
|
/* 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 chunk_len = pending_data > 1000 ? 1000 : pending_data;
|
||||||
int subrv = callback_send_inner(hd, data + copy_offset, chunk_len);
|
int subrv = callback_send_inner(hd, data + copy_offset, chunk_len);
|
||||||
if (subrv <= 0) {
|
if (subrv <= 0) {
|
||||||
if (copy_offset) {
|
if (copy_offset == 0) {
|
||||||
/* If some data was xferred, send the number of bytes
|
/* If no data is transferred, send the error code */
|
||||||
* xferred */
|
|
||||||
rv = copy_offset;
|
|
||||||
} else {
|
|
||||||
/* If not, send the error code */
|
|
||||||
rv = subrv;
|
rv = subrv;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
copy_offset += chunk_len;
|
copy_offset += subrv;
|
||||||
pending_data -= chunk_len;
|
pending_data -= subrv;
|
||||||
|
rv += subrv;
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue