From 95cdb49cec4237d6349cf38b2b3d5e58d4ff465d Mon Sep 17 00:00:00 2001 From: grossmj Date: Fri, 27 Mar 2020 11:02:48 +1030 Subject: [PATCH] Fix issue with data transfer thread unexpectedly stopping. Ref https://github.com/GNS3/gns3-gui/issues/2951 --- src/hypervisor_iol_bridge.c | 8 ++++---- src/ubridge.c | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hypervisor_iol_bridge.c b/src/hypervisor_iol_bridge.c index ff63b06..fd86517 100644 --- a/src/hypervisor_iol_bridge.c +++ b/src/hypervisor_iol_bridge.c @@ -73,9 +73,9 @@ void *iol_nio_listener(void *data) drop_packet = FALSE; bytes_received = nio_recv(nio, &pkt[IOL_HDR_SIZE], MAX_MTU); if (bytes_received == -1) { - perror("recv"); if (errno == ECONNREFUSED || errno == ENETDOWN) continue; + perror("recv"); exit(EXIT_FAILURE); } @@ -126,9 +126,9 @@ void *iol_nio_listener(void *data) memcpy(pkt, &(iol_nio->header), sizeof(iol_nio->header)); bytes_sent = sendto(iol_nio->iol_bridge_sock, pkt, bytes_received, 0, (struct sockaddr *)&iol_nio->iol_sockaddr, sizeof(iol_nio->iol_sockaddr)); if (bytes_sent == -1) { - perror("sendto"); if (errno == ECONNREFUSED || errno == ENETDOWN || errno == ENOENT) continue; + perror("sendto"); exit(EXIT_FAILURE); } } @@ -153,9 +153,9 @@ void *iol_bridge_listener(void *data) drop_packet = FALSE; bytes_received = read(bridge->iol_bridge_sock, pkt, IOL_HDR_SIZE + MAX_MTU); if (bytes_received == -1) { - perror("recv"); if (errno == ECONNREFUSED || errno == ENETDOWN) continue; + perror("recv"); exit(EXIT_FAILURE); } @@ -205,12 +205,12 @@ void *iol_bridge_listener(void *data) nio->packets_out++; nio->bytes_out += bytes_sent; if (bytes_sent == -1) { - perror("send"); /* EINVAL can be caused by sending to a blackhole route, this happens if a NIC link status changes */ if (errno == ECONNREFUSED || errno == ENETDOWN || errno == EINVAL) continue; + perror("send"); exit(EXIT_FAILURE); } } diff --git a/src/ubridge.c b/src/ubridge.c index fc9a782..ca1798a 100644 --- a/src/ubridge.c +++ b/src/ubridge.c @@ -58,9 +58,9 @@ static int bridge_nios(nio_t *rx_nio, nio_t *tx_nio, bridge_t *bridge) drop_packet = FALSE; bytes_received = nio_recv(rx_nio, &pkt, NIO_MAX_PKT_SIZE); if (bytes_received == -1) { - perror("recv"); if (errno == ECONNREFUSED || errno == ENETDOWN) continue; + perror("recv"); return -1; } @@ -106,7 +106,6 @@ static int bridge_nios(nio_t *rx_nio, nio_t *tx_nio, bridge_t *bridge) /* send what we received to the transmitting NIO */ bytes_sent = nio_send(tx_nio, pkt, bytes_received); if (bytes_sent == -1) { - perror("send"); /* EINVAL can be caused by sending to a blackhole route, this happens if a NIC link status changes */ if (errno == ECONNREFUSED || errno == ENETDOWN || errno == EINVAL) @@ -117,12 +116,14 @@ static int bridge_nios(nio_t *rx_nio, nio_t *tx_nio, bridge_t *bridge) if (tx_nio->type == NIO_TYPE_TAP && errno == EIO) continue; + perror("send"); return -1; } tx_nio->packets_out++; tx_nio->bytes_out += bytes_sent; } + return 0; }