|
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 */ |
@@ -2528,8 +2530,24 @@ io_wait_dowork(struct context *c, const unsigned int flags) |
2528 | 2530 | dmsg(D_EVENT_WAIT, "I/O WAIT status=0x%04x", c->c2.event_set_status); |
2529 | 2531 | } |
2530 | 2532 |
|
| 2533 | +void threaded_fwd_inp_intf(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
| 2534 | +{ |
| 2535 | + if (b->p->h == b->p->n) |
| 2536 | + { |
| 2537 | + ssize_t size; |
| 2538 | + uint8_t temp[1]; |
| 2539 | + size = read(c->c1.tuntap->fd, temp, 1); |
| 2540 | + if (size < 1) { /* no-op */ } |
| 2541 | + if (!IS_SIG(c)) |
| 2542 | + { |
| 2543 | + process_incoming_tun(c, sock); |
| 2544 | + } |
| 2545 | + size = write(c->c1.tuntap->fz, temp, 1); |
| 2546 | + } |
| 2547 | +} |
| 2548 | + |
2531 | 2549 | void |
2532 | | -process_io(struct context *c, struct link_socket *sock) |
| 2550 | +process_io(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
2533 | 2551 | { |
2534 | 2552 | const unsigned int status = c->c2.event_set_status; |
2535 | 2553 |
|
@@ -2563,11 +2581,7 @@ process_io(struct context *c, struct link_socket *sock) |
2563 | 2581 | /* Incoming data on TUN device */ |
2564 | 2582 | else if (status & TUN_READ) |
2565 | 2583 | { |
2566 | | - read_incoming_tun(c); |
2567 | | - if (!IS_SIG(c)) |
2568 | | - { |
2569 | | - process_incoming_tun(c, sock); |
2570 | | - } |
| 2584 | + threaded_fwd_inp_intf(c, sock, b); |
2571 | 2585 | } |
2572 | 2586 | else if (status & DCO_READ) |
2573 | 2587 | { |
|
0 commit comments