|
47 | 47 | #include "mstats.h" |
48 | 48 |
|
49 | 49 | #include <sys/select.h> |
| 50 | +#include <sys/socket.h> |
50 | 51 | #include <sys/time.h> |
| 52 | +#include <pthread.h> |
51 | 53 |
|
52 | 54 | counter_type link_read_bytes_global; /* GLOBAL */ |
53 | 55 | counter_type link_write_bytes_global; /* GLOBAL */ |
@@ -2502,8 +2504,24 @@ io_wait_dowork(struct context *c, const unsigned int flags) |
2502 | 2504 | dmsg(D_EVENT_WAIT, "I/O WAIT status=0x%04x", c->c2.event_set_status); |
2503 | 2505 | } |
2504 | 2506 |
|
| 2507 | +void threaded_fwd_inp_intf(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
| 2508 | +{ |
| 2509 | + if (b->p->h == b->p->n) |
| 2510 | + { |
| 2511 | + ssize_t size; |
| 2512 | + uint8_t temp[1]; |
| 2513 | + size = read(c->c1.tuntap->fd, temp, 1); |
| 2514 | + if (size < 1) { /* no-op */ } |
| 2515 | + if (!IS_SIG(c)) |
| 2516 | + { |
| 2517 | + process_incoming_tun(c, sock); |
| 2518 | + } |
| 2519 | + size = write(c->c1.tuntap->fz, temp, 1); |
| 2520 | + } |
| 2521 | +} |
| 2522 | + |
2505 | 2523 | void |
2506 | | -process_io(struct context *c, struct link_socket *sock) |
| 2524 | +process_io(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
2507 | 2525 | { |
2508 | 2526 | const unsigned int status = c->c2.event_set_status; |
2509 | 2527 |
|
@@ -2537,11 +2555,7 @@ process_io(struct context *c, struct link_socket *sock) |
2537 | 2555 | /* Incoming data on TUN device */ |
2538 | 2556 | else if (status & TUN_READ) |
2539 | 2557 | { |
2540 | | - read_incoming_tun(c); |
2541 | | - if (!IS_SIG(c)) |
2542 | | - { |
2543 | | - process_incoming_tun(c, sock); |
2544 | | - } |
| 2558 | + threaded_fwd_inp_intf(c, sock, b); |
2545 | 2559 | } |
2546 | 2560 | else if (status & DCO_READ) |
2547 | 2561 | { |
|
0 commit comments