|
46 | 46 | #include "memdbg.h" |
47 | 47 |
|
48 | 48 | #include <sys/select.h> |
| 49 | +#include <sys/socket.h> |
49 | 50 | #include <sys/time.h> |
| 51 | +#include <pthread.h> |
50 | 52 |
|
51 | 53 | counter_type link_read_bytes_global; /* GLOBAL */ |
52 | 54 | counter_type link_write_bytes_global; /* GLOBAL */ |
@@ -2519,8 +2521,24 @@ io_wait_dowork(struct context *c, const unsigned int flags) |
2519 | 2521 | dmsg(D_EVENT_WAIT, "I/O WAIT status=0x%04x", c->c2.event_set_status); |
2520 | 2522 | } |
2521 | 2523 |
|
| 2524 | +void threaded_fwd_inp_intf(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
| 2525 | +{ |
| 2526 | + if (b->p->h == b->p->n) |
| 2527 | + { |
| 2528 | + ssize_t size; |
| 2529 | + uint8_t temp[1]; |
| 2530 | + size = read(c->c1.tuntap->fd, temp, 1); |
| 2531 | + if (size < 1) { /* no-op */ } |
| 2532 | + if (!IS_SIG(c)) |
| 2533 | + { |
| 2534 | + process_incoming_tun(c, sock); |
| 2535 | + } |
| 2536 | + size = write(c->c1.tuntap->fz, temp, 1); |
| 2537 | + } |
| 2538 | +} |
| 2539 | + |
2522 | 2540 | void |
2523 | | -process_io(struct context *c, struct link_socket *sock) |
| 2541 | +process_io(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
2524 | 2542 | { |
2525 | 2543 | const unsigned int status = c->c2.event_set_status; |
2526 | 2544 |
|
@@ -2554,11 +2572,7 @@ process_io(struct context *c, struct link_socket *sock) |
2554 | 2572 | /* Incoming data on TUN device */ |
2555 | 2573 | else if (status & TUN_READ) |
2556 | 2574 | { |
2557 | | - read_incoming_tun(c); |
2558 | | - if (!IS_SIG(c)) |
2559 | | - { |
2560 | | - process_incoming_tun(c, sock); |
2561 | | - } |
| 2575 | + threaded_fwd_inp_intf(c, sock, b); |
2562 | 2576 | } |
2563 | 2577 | else if (status & DCO_READ) |
2564 | 2578 | { |
|
0 commit comments