mirror of
https://github.com/hufrea/byedpi.git
synced 2025-01-03 04:49:47 +00:00
parent
ff65b9f780
commit
6d21aae7b5
14
desync.c
14
desync.c
@ -17,7 +17,6 @@
|
|||||||
#else
|
#else
|
||||||
#include <sys/sendfile.h>
|
#include <sys/sendfile.h>
|
||||||
#include <linux/tcp.h>
|
#include <linux/tcp.h>
|
||||||
|
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
|
|
||||||
#define memfd_create(name, flags) syscall(__NR_memfd_create, name, flags)
|
#define memfd_create(name, flags) syscall(__NR_memfd_create, name, flags)
|
||||||
@ -84,24 +83,25 @@ static inline void delay(long ms)
|
|||||||
void wait_send(int sfd)
|
void wait_send(int sfd)
|
||||||
{
|
{
|
||||||
for (int i = 0; params.wait_send && i < 500; i++) {
|
for (int i = 0; params.wait_send && i < 500; i++) {
|
||||||
struct tcpi tcpi = {};
|
struct tcp_info tcpi = {};
|
||||||
socklen_t ts = sizeof(tcpi);
|
socklen_t ts = sizeof(tcpi);
|
||||||
|
|
||||||
if (getsockopt(sfd, IPPROTO_TCP,
|
if (getsockopt(sfd, IPPROTO_TCP,
|
||||||
TCP_INFO, (char *)&tcpi, &ts) < 0) {
|
TCP_INFO, (char *)&tcpi, &ts) < 0) {
|
||||||
uniperror("getsockopt TCP_INFO");
|
perror("getsockopt TCP_INFO");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (tcpi.state != 1) {
|
if (tcpi.tcpi_state != 1) {
|
||||||
LOG(LOG_E, "state: %d\n", tcpi.state);
|
LOG(LOG_E, "state: %d\n", tcpi.tcpi_state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ts < sizeof(tcpi)) {
|
size_t s = (char *)&tcpi.tcpi_notsent_bytes - (char *)&tcpi.tcpi_state;
|
||||||
|
if (ts < s) {
|
||||||
LOG(LOG_E, "tcpi_notsent_bytes not provided\n");
|
LOG(LOG_E, "tcpi_notsent_bytes not provided\n");
|
||||||
params.wait_send = 0;
|
params.wait_send = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (tcpi.notsent_bytes == 0) {
|
if (tcpi.tcpi_notsent_bytes == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG(LOG_S, "not sent after %d ms\n", i);
|
LOG(LOG_S, "not sent after %d ms\n", i);
|
||||||
|
Loading…
Reference in New Issue
Block a user