mirror of
https://github.com/hufrea/byedpi.git
synced 2024-12-22 14:25:44 +00:00
Fix offset after EAGAIN if buffer is locked
This commit is contained in:
parent
a067afe6e4
commit
2240039377
3
desync.c
3
desync.c
@ -489,7 +489,7 @@ ssize_t desync(int sfd, char *buffer, size_t bfsize,
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
long lp = offset;
|
||||
long lp = 0;
|
||||
struct part part;
|
||||
int i = 0, r = 0;
|
||||
|
||||
@ -504,6 +504,7 @@ ssize_t desync(int sfd, char *buffer, size_t bfsize,
|
||||
pos += part.s * (part.r - r);
|
||||
|
||||
if (!(part.flag & OFFSET_START) && offset && pos <= offset) {
|
||||
LOG(LOG_S, "offset: %zd, skip\n", offset);
|
||||
continue;
|
||||
}
|
||||
if (pos < 0 || pos > n || pos < lp) {
|
||||
|
3
extend.c
3
extend.c
@ -166,6 +166,7 @@ static int reconnect(struct poolhd *pool, struct eval *val, int m)
|
||||
client->attempt = m;
|
||||
client->cache = 1;
|
||||
client->buff.offset = 0;
|
||||
client->round_sent = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -367,7 +368,7 @@ ssize_t tcp_send_hook(struct poolhd *pool, struct eval *remote,
|
||||
int m = client->attempt;
|
||||
LOG((m ? LOG_S : LOG_L), "desync params index: %d\n", m);
|
||||
|
||||
ssize_t offset = client->round_sent + client->buff.offset;
|
||||
ssize_t offset = client->round_sent;
|
||||
if (!offset && remote->round_count) offset = -1;
|
||||
|
||||
sn = desync(remote->fd, buffer, bfsize, n,
|
||||
|
10
proxy.c
10
proxy.c
@ -651,12 +651,12 @@ int on_tunnel(struct poolhd *pool, struct eval *val,
|
||||
ssize_t sn = tcp_send_hook(pool, pair,
|
||||
val->buff.data + val->buff.offset, n, n);
|
||||
|
||||
if (sn < n) {
|
||||
if (sn < 0) {
|
||||
uniperror("send");
|
||||
return -1;
|
||||
}
|
||||
if (sn > 0)
|
||||
val->round_sent += sn;
|
||||
if (sn < n) {
|
||||
val->buff.offset += sn;
|
||||
return 0;
|
||||
}
|
||||
@ -692,12 +692,12 @@ int on_tunnel(struct poolhd *pool, struct eval *val,
|
||||
}
|
||||
|
||||
ssize_t sn = tcp_send_hook(pool, pair, buffer, bfsize, n);
|
||||
val->round_sent += sn > 0 ? sn : 0;
|
||||
if (sn < n) {
|
||||
if (sn < 0) {
|
||||
uniperror("send");
|
||||
return -1;
|
||||
}
|
||||
val->round_sent += sn;
|
||||
if (sn < n) {
|
||||
LOG(LOG_S, "send: %zd != %zd (fd: %d)\n", sn, n, pair->fd);
|
||||
assert(val->buff.locked
|
||||
|| !(val->buff.size || val->buff.offset));
|
||||
@ -710,6 +710,8 @@ int on_tunnel(struct poolhd *pool, struct eval *val,
|
||||
}
|
||||
memcpy(val->buff.data, buffer + sn, n - sn);
|
||||
}
|
||||
else val->buff.offset += sn;
|
||||
|
||||
if (mod_etype(pool, val, 0) ||
|
||||
mod_etype(pool, pair, POLLOUT)) {
|
||||
uniperror("mod_etype");
|
||||
|
Loading…
Reference in New Issue
Block a user