diff --git a/src/network/net_pcap.c b/src/network/net_pcap.c index e704d1b00..5acc9c170 100644 --- a/src/network/net_pcap.c +++ b/src/network/net_pcap.c @@ -185,7 +185,7 @@ poll_thread(void *arg) if (pcap == NULL) break; /* Wait for the next packet to arrive. */ - if (network_wait) + if (network_get_wait()) data = NULL; else data = (uint8_t *)f_pcap_next((void *)pcap, &h); diff --git a/src/network/net_slirp.c b/src/network/net_slirp.c index a726d133d..8b8304854 100644 --- a/src/network/net_slirp.c +++ b/src/network/net_slirp.c @@ -148,7 +148,7 @@ poll_thread(void *arg) /* Wait for the next packet to arrive. */ data_valid = 0; - if (!network_wait && (QueuePeek(slirpq) != 0)) { + if (!network_get_wait() && (QueuePeek(slirpq) != 0)) { /* Grab a packet from the queue. */ // ui_sb_update_icon(SB_NETWORK, 1); diff --git a/src/network/network.c b/src/network/network.c index 869da50b3..6cff7945d 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -99,7 +99,7 @@ static netcard_t net_cards[] = { int network_type; int network_ndev; int network_card; -volatile int network_wait = 0; +static volatile int net_wait = 0; char network_host[522]; netdev_t network_devs[32]; #ifdef ENABLE_NIC_LOG @@ -221,7 +221,7 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx) net_cards[network_card].rx = rx; network_mac = mac; - network_wait = 0; + network_set_wait(0); /* Create the network events. */ poll_data.wake_poll_thread = thread_create_event(); @@ -450,5 +450,19 @@ network_card_get_from_internal_name(char *s) void network_set_wait(int wait) { - network_wait = wait; + network_wait(1); + net_wait = wait; + network_wait(0); +} + + +int +network_get_wait(void) +{ + int ret; + + network_wait(1); + ret = net_wait; + network_wait(0); + return ret; } diff --git a/src/network/network.h b/src/network/network.h index e5c72ce5e..feae064ee 100644 --- a/src/network/network.h +++ b/src/network/network.h @@ -89,7 +89,6 @@ extern "C" { /* Global variables. */ extern int nic_do_log; /* config */ extern int network_ndev; -extern volatile int network_wait; extern netdev_t network_devs[32]; @@ -126,6 +125,7 @@ extern int network_card_get_from_internal_name(char *); extern const device_t *network_card_getdevice(int); extern void network_set_wait(int wait); +extern int network_get_wait(void); #ifdef __cplusplus }