Added a sanity check and more clean-ups.
This commit is contained in:
@@ -105,8 +105,6 @@ extern netdev_t network_devs[32];
|
|||||||
|
|
||||||
/* Function prototypes. */
|
/* Function prototypes. */
|
||||||
extern void network_wait(uint8_t wait);
|
extern void network_wait(uint8_t wait);
|
||||||
extern void network_busy(uint8_t set);
|
|
||||||
extern void network_end(void);
|
|
||||||
|
|
||||||
extern void network_init(void);
|
extern void network_init(void);
|
||||||
extern void network_attach(void *, uint8_t *, NETRXCB, NETWAITCB, NETSETLINKSTATE);
|
extern void network_attach(void *, uint8_t *, NETRXCB, NETWAITCB, NETSETLINKSTATE);
|
||||||
|
@@ -338,8 +338,6 @@ net_pcap_close(void)
|
|||||||
|
|
||||||
/* Tell the thread to terminate. */
|
/* Tell the thread to terminate. */
|
||||||
if (poll_tid != NULL) {
|
if (poll_tid != NULL) {
|
||||||
network_busy(0);
|
|
||||||
|
|
||||||
/* Wait for the thread to finish. */
|
/* Wait for the thread to finish. */
|
||||||
pcap_log("PCAP: waiting for thread to end...\n");
|
pcap_log("PCAP: waiting for thread to end...\n");
|
||||||
thread_wait_event(poll_state, -1);
|
thread_wait_event(poll_state, -1);
|
||||||
|
@@ -446,8 +446,6 @@ net_slirp_close(void)
|
|||||||
|
|
||||||
/* Tell the thread to terminate. */
|
/* Tell the thread to terminate. */
|
||||||
if (slirp->poll_tid) {
|
if (slirp->poll_tid) {
|
||||||
network_busy(0);
|
|
||||||
|
|
||||||
/* Wait for the thread to finish. */
|
/* Wait for the thread to finish. */
|
||||||
slirp_log("SLiRP: waiting for thread to end...\n");
|
slirp_log("SLiRP: waiting for thread to end...\n");
|
||||||
thread_wait_event(slirp->poll_state, -1);
|
thread_wait_event(slirp->poll_state, -1);
|
||||||
|
@@ -124,16 +124,6 @@ static netpkt_t *first_pkt[3] = { NULL, NULL, NULL },
|
|||||||
*last_pkt[3] = { NULL, NULL, NULL };
|
*last_pkt[3] = { NULL, NULL, NULL };
|
||||||
|
|
||||||
|
|
||||||
static struct {
|
|
||||||
volatile int busy,
|
|
||||||
queue_in_use;
|
|
||||||
|
|
||||||
event_t *wake_poll_thread,
|
|
||||||
*poll_complete,
|
|
||||||
*queue_not_in_use;
|
|
||||||
} poll_data;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_NETWORK_LOG
|
#ifdef ENABLE_NETWORK_LOG
|
||||||
int network_do_log = ENABLE_NETWORK_LOG;
|
int network_do_log = ENABLE_NETWORK_LOG;
|
||||||
static FILE *network_dump = NULL;
|
static FILE *network_dump = NULL;
|
||||||
@@ -201,23 +191,6 @@ network_wait(uint8_t wait)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
network_busy(uint8_t set)
|
|
||||||
{
|
|
||||||
poll_data.busy = !!set;
|
|
||||||
|
|
||||||
if (! set)
|
|
||||||
thread_set_event(poll_data.wake_poll_thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
network_end(void)
|
|
||||||
{
|
|
||||||
thread_set_event(poll_data.poll_complete);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the configured network cards.
|
* Initialize the configured network cards.
|
||||||
*
|
*
|
||||||
@@ -362,7 +335,8 @@ network_rx_queue(void *priv)
|
|||||||
|
|
||||||
/* Transmission. */
|
/* Transmission. */
|
||||||
network_queue_get(2, &pkt);
|
network_queue_get(2, &pkt);
|
||||||
network_queue_put(1, pkt->priv, pkt->data, pkt->len);
|
if (pkt != NULL)
|
||||||
|
network_queue_put(1, pkt->priv, pkt->data, pkt->len);
|
||||||
|
|
||||||
// network_busy(0);
|
// network_busy(0);
|
||||||
|
|
||||||
@@ -391,10 +365,6 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx, NETWAITCB wait, NETSETLINKST
|
|||||||
|
|
||||||
network_set_wait(0);
|
network_set_wait(0);
|
||||||
|
|
||||||
/* Create the network events. */
|
|
||||||
poll_data.poll_complete = thread_create_event();
|
|
||||||
poll_data.wake_poll_thread = thread_create_event();
|
|
||||||
|
|
||||||
/* Activate the platform module. */
|
/* Activate the platform module. */
|
||||||
switch(network_type) {
|
switch(network_type) {
|
||||||
case NET_TYPE_PCAP:
|
case NET_TYPE_PCAP:
|
||||||
@@ -443,16 +413,6 @@ network_close(void)
|
|||||||
/* Force-close the SLIRP module. */
|
/* Force-close the SLIRP module. */
|
||||||
net_slirp_close();
|
net_slirp_close();
|
||||||
|
|
||||||
/* Close the network events. */
|
|
||||||
if (poll_data.wake_poll_thread != NULL) {
|
|
||||||
thread_destroy_event(poll_data.wake_poll_thread);
|
|
||||||
poll_data.wake_poll_thread = NULL;
|
|
||||||
}
|
|
||||||
if (poll_data.poll_complete != NULL) {
|
|
||||||
thread_destroy_event(poll_data.poll_complete);
|
|
||||||
poll_data.poll_complete = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Close the network thread mutex. */
|
/* Close the network thread mutex. */
|
||||||
thread_close_mutex(network_mutex);
|
thread_close_mutex(network_mutex);
|
||||||
network_mutex = NULL;
|
network_mutex = NULL;
|
||||||
@@ -541,15 +501,11 @@ network_reset(void)
|
|||||||
void
|
void
|
||||||
network_tx(uint8_t *bufp, int len)
|
network_tx(uint8_t *bufp, int len)
|
||||||
{
|
{
|
||||||
network_busy(1);
|
|
||||||
|
|
||||||
ui_sb_update_icon(SB_NETWORK, 1);
|
ui_sb_update_icon(SB_NETWORK, 1);
|
||||||
|
|
||||||
network_queue_put(2, NULL, bufp, len);
|
network_queue_put(2, NULL, bufp, len);
|
||||||
|
|
||||||
ui_sb_update_icon(SB_NETWORK, 0);
|
ui_sb_update_icon(SB_NETWORK, 0);
|
||||||
|
|
||||||
network_busy(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user