Bugfix for proxy

This commit is contained in:
2021-01-08 18:01:19 +01:00
parent debac11f90
commit b676388018
4 changed files with 33 additions and 12 deletions

View File

@ -78,7 +78,7 @@ long sock_splice(sock *dst, sock *src, void *buf, unsigned long buf_len, unsigne
unsigned long send_len = 0;
unsigned long next_len;
while (send_len < len) {
next_len = buf_len < len - send_len ? buf_len : len - send_len;
next_len = (buf_len < (len - send_len)) ? buf_len : (len - send_len);
ret = sock_recv(src, buf, next_len, 0);
if (ret < 0) return -2;
if (ret != next_len) return -3;
@ -102,3 +102,8 @@ int sock_close(sock *s) {
s->ssl = NULL;
return 0;
}
int sock_check(sock *s) {
char buf;
return recv(s->socket, &buf, 1, MSG_PEEK | MSG_DONTWAIT) == 1;
}