mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-05-03 01:02:52 +00:00
Make LWIPStack clean up properly.
This commit is contained in:
parent
fbde40d1fc
commit
557d2b3b0d
@ -97,13 +97,21 @@ typedef ip_addr ip_addr_t;
|
|||||||
#define NETIF_SET_UP_SIG struct netif *netif
|
#define NETIF_SET_UP_SIG struct netif *netif
|
||||||
#define NETIF_POLL_SIG struct netif *netif
|
#define NETIF_POLL_SIG struct netif *netif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads an instance of liblwip.so in a private memory arena
|
||||||
class LWIPStack{
|
*
|
||||||
|
* This uses dlmopen() to load an instance of the LWIP stack into its
|
||||||
|
* own private memory space. This is done to get around the stack's
|
||||||
|
* lack of thread-safety or multi-instance support. The alternative
|
||||||
|
* would be to massively refactor the stack so everything lives in a
|
||||||
|
* state object instead of static memory space.
|
||||||
|
*/
|
||||||
|
class LWIPStack
|
||||||
|
{
|
||||||
|
private:
|
||||||
void* libref;
|
void* libref;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void (*lwip_init)();
|
void (*lwip_init)();
|
||||||
err_t (*tcp_write)(TCP_WRITE_SIG);
|
err_t (*tcp_write)(TCP_WRITE_SIG);
|
||||||
void (*tcp_sent)(TCP_SENT_SIG);
|
void (*tcp_sent)(TCP_SENT_SIG);
|
||||||
@ -141,8 +149,6 @@ public:
|
|||||||
void (*netif_set_up)(NETIF_SET_UP_SIG);
|
void (*netif_set_up)(NETIF_SET_UP_SIG);
|
||||||
void (*netif_poll)(NETIF_POLL_SIG);
|
void (*netif_poll)(NETIF_POLL_SIG);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LWIPStack(const char* path)
|
LWIPStack(const char* path)
|
||||||
{
|
{
|
||||||
libref = dlmopen(LM_ID_NEWLM, path, RTLD_NOW);
|
libref = dlmopen(LM_ID_NEWLM, path, RTLD_NOW);
|
||||||
@ -188,6 +194,12 @@ public:
|
|||||||
netif_set_up = (void(*)(NETIF_SET_UP_SIG))dlsym(libref, "netif_set_up");
|
netif_set_up = (void(*)(NETIF_SET_UP_SIG))dlsym(libref, "netif_set_up");
|
||||||
netif_poll = (void(*)(NETIF_POLL_SIG))dlsym(libref, "netif_poll");
|
netif_poll = (void(*)(NETIF_POLL_SIG))dlsym(libref, "netif_poll");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~LWIPStack()
|
||||||
|
{
|
||||||
|
if (lebref)
|
||||||
|
dlclose(libref);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -96,6 +96,7 @@ NetconEthernetTap::~NetconEthernetTap()
|
|||||||
_phy.whack();
|
_phy.whack();
|
||||||
Thread::join(_thread);
|
Thread::join(_thread);
|
||||||
_phy.close(_unixListenSocket,false);
|
_phy.close(_unixListenSocket,false);
|
||||||
|
delete lwipstack;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetconEthernetTap::setEnabled(bool en)
|
void NetconEthernetTap::setEnabled(bool en)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user