|
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 */ |
@@ -1358,8 +1360,7 @@ read_incoming_tun_part2(struct context *c) |
1358 | 1360 | ASSERT(buf_safe(&c->c2.buf, c->c2.frame.buf.payload_size)); |
1359 | 1361 | if (c->c1.tuntap->backend_driver == DRIVER_AFUNIX) |
1360 | 1362 | { |
1361 | | - c->c2.buf.len = |
1362 | | - read_tun_afunix(c->c1.tuntap, BPTR(&c->c2.buf), c->c2.frame.buf.payload_size); |
| 1363 | + c->c2.buf.len = read_tun_afunix(c->c1.tuntap, BPTR(&c->c2.buf), c->c2.frame.buf.payload_size); |
1363 | 1364 | } |
1364 | 1365 | else |
1365 | 1366 | { |
@@ -2511,8 +2512,28 @@ io_wait_dowork(struct context *c, const unsigned int flags) |
2511 | 2512 | dmsg(D_EVENT_WAIT, "I/O WAIT status=0x%04x", c->c2.event_set_status); |
2512 | 2513 | } |
2513 | 2514 |
|
| 2515 | +void threaded_fwd_inp_intf(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
| 2516 | +{ |
| 2517 | + if (b->p->h == b->p->n) |
| 2518 | + { |
| 2519 | + ssize_t size; |
| 2520 | + uint8_t temp[1]; |
| 2521 | + size = read(c->c1.tuntap->fd, temp, 1); |
| 2522 | + if (size < 1) { /* no-op */ } |
| 2523 | + if (!IS_SIG(c)) |
| 2524 | + { |
| 2525 | + if (!BULK_MODE(c)) |
| 2526 | + { |
| 2527 | + c->c2.buf = c->c2.buffers->read_tun_buf; |
| 2528 | + } |
| 2529 | + process_incoming_tun(c, sock); |
| 2530 | + } |
| 2531 | + size = write(c->c1.tuntap->fz, temp, 1); |
| 2532 | + } |
| 2533 | +} |
| 2534 | + |
2514 | 2535 | void |
2515 | | -process_io(struct context *c, struct link_socket *sock) |
| 2536 | +process_io(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
2516 | 2537 | { |
2517 | 2538 | const unsigned int status = c->c2.event_set_status; |
2518 | 2539 |
|
@@ -2546,11 +2567,7 @@ process_io(struct context *c, struct link_socket *sock) |
2546 | 2567 | /* Incoming data on TUN device */ |
2547 | 2568 | else if (status & TUN_READ) |
2548 | 2569 | { |
2549 | | - read_incoming_tun(c); |
2550 | | - if (!IS_SIG(c)) |
2551 | | - { |
2552 | | - process_incoming_tun(c, sock); |
2553 | | - } |
| 2570 | + threaded_fwd_inp_intf(c, sock, b); |
2554 | 2571 | } |
2555 | 2572 | else if (status & DCO_READ) |
2556 | 2573 | { |
|
0 commit comments