|
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 */ |
@@ -1353,8 +1355,7 @@ read_incoming_tun_part2(struct context *c) |
1353 | 1355 | ASSERT(buf_safe(&c->c2.buf, c->c2.frame.buf.payload_size)); |
1354 | 1356 | if (c->c1.tuntap->backend_driver == DRIVER_AFUNIX) |
1355 | 1357 | { |
1356 | | - c->c2.buf.len = |
1357 | | - (int)read_tun_afunix(c->c1.tuntap, BPTR(&c->c2.buf), c->c2.frame.buf.payload_size); |
| 1358 | + c->c2.buf.len = (int)read_tun_afunix(c->c1.tuntap, BPTR(&c->c2.buf), c->c2.frame.buf.payload_size); |
1358 | 1359 | } |
1359 | 1360 | else |
1360 | 1361 | { |
@@ -2484,8 +2485,28 @@ io_wait(struct context *c, const unsigned int flags) |
2484 | 2485 | dmsg(D_EVENT_WAIT, "I/O WAIT status=0x%04x", c->c2.event_set_status); |
2485 | 2486 | } |
2486 | 2487 |
|
| 2488 | +void threaded_fwd_inp_intf(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
| 2489 | +{ |
| 2490 | + if (b->p->h == b->p->n) |
| 2491 | + { |
| 2492 | + ssize_t size; |
| 2493 | + uint8_t temp[1]; |
| 2494 | + size = read(c->c1.tuntap->fd, temp, 1); |
| 2495 | + if (size < 1) { /* no-op */ } |
| 2496 | + if (!IS_SIG(c)) |
| 2497 | + { |
| 2498 | + if (!BULK_MODE(c)) |
| 2499 | + { |
| 2500 | + c->c2.buf = c->c2.buffers->read_tun_buf; |
| 2501 | + } |
| 2502 | + process_incoming_tun(c, sock); |
| 2503 | + } |
| 2504 | + size = write(c->c1.tuntap->fz, temp, 1); |
| 2505 | + } |
| 2506 | +} |
| 2507 | + |
2487 | 2508 | void |
2488 | | -process_io(struct context *c, struct link_socket *sock) |
| 2509 | +process_io(struct context *c, struct link_socket *sock, struct thread_pointer *b) |
2489 | 2510 | { |
2490 | 2511 | const unsigned int status = c->c2.event_set_status; |
2491 | 2512 |
|
@@ -2519,11 +2540,7 @@ process_io(struct context *c, struct link_socket *sock) |
2519 | 2540 | /* Incoming data on TUN device */ |
2520 | 2541 | else if (status & TUN_READ) |
2521 | 2542 | { |
2522 | | - read_incoming_tun(c); |
2523 | | - if (!IS_SIG(c)) |
2524 | | - { |
2525 | | - process_incoming_tun(c, sock); |
2526 | | - } |
| 2543 | + threaded_fwd_inp_intf(c, sock, b); |
2527 | 2544 | } |
2528 | 2545 | else if (status & DCO_READ) |
2529 | 2546 | { |
|
0 commit comments