|
45 | 45 | #include "memdbg.h" |
46 | 46 |
|
47 | 47 | #include <sys/select.h> |
| 48 | +#include <sys/socket.h> |
48 | 49 | #include <sys/time.h> |
| 50 | +#include <pthread.h> |
49 | 51 |
|
50 | 52 | counter_type link_read_bytes_global; /* GLOBAL */ |
51 | 53 | counter_type link_write_bytes_global; /* GLOBAL */ |
@@ -2488,8 +2490,24 @@ io_wait_dowork(struct context *c, const unsigned int flags) |
2488 | 2490 | dmsg(D_EVENT_WAIT, "I/O WAIT status=0x%04x", c->c2.event_set_status); |
2489 | 2491 | } |
2490 | 2492 |
|
| 2493 | +void threaded_fwd_inp_intf(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
| 2494 | +{ |
| 2495 | + if (b->p->h == b->p->n) |
| 2496 | + { |
| 2497 | + ssize_t size; |
| 2498 | + uint8_t temp[1]; |
| 2499 | + size = read(c->c1.tuntap->fd, temp, 1); |
| 2500 | + if (size < 1) { /* no-op */ } |
| 2501 | + if (!IS_SIG(c)) |
| 2502 | + { |
| 2503 | + process_incoming_tun(c, sock); |
| 2504 | + } |
| 2505 | + size = write(c->c1.tuntap->fz, temp, 1); |
| 2506 | + } |
| 2507 | +} |
| 2508 | + |
2491 | 2509 | void |
2492 | | -process_io(struct context *c, struct link_socket *sock) |
| 2510 | +process_io(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
2493 | 2511 | { |
2494 | 2512 | const unsigned int status = c->c2.event_set_status; |
2495 | 2513 |
|
@@ -2523,11 +2541,7 @@ process_io(struct context *c, struct link_socket *sock) |
2523 | 2541 | /* Incoming data on TUN device */ |
2524 | 2542 | else if (status & TUN_READ) |
2525 | 2543 | { |
2526 | | - read_incoming_tun(c); |
2527 | | - if (!IS_SIG(c)) |
2528 | | - { |
2529 | | - process_incoming_tun(c, sock); |
2530 | | - } |
| 2544 | + threaded_fwd_inp_intf(c, sock, b); |
2531 | 2545 | } |
2532 | 2546 | else if (status & DCO_READ) |
2533 | 2547 | { |
|
0 commit comments