ok serialising tun::FlushSend should get rid of that crash from #192

This commit is contained in:
Rick V 2019-02-25 16:55:05 -06:00
parent f0ce9a0afb
commit 6e91547b39
No known key found for this signature in database
GPG Key ID: C0EDC8723FDC3465

View File

@ -151,7 +151,9 @@ tun_ev_loop(void* unused)
{ {
if(tun->t->tick) if(tun->t->tick)
tun->t->tick(tun->t); tun->t->tick(tun->t);
EnterCriticalSection(&HandlerMtx);
tun->flush_write(); tun->flush_write();
LeaveCriticalSection(&HandlerMtx);
} }
continue; // let's go at it once more continue; // let's go at it once more
} }
@ -160,7 +162,6 @@ tun_ev_loop(void* unused)
// if we're here, then we got something interesting :> // if we're here, then we got something interesting :>
pkt = (asio_evt_pkt*)ovl; pkt = (asio_evt_pkt*)ovl;
win32_tun_io* ev = reinterpret_cast< win32_tun_io* >(listener); win32_tun_io* ev = reinterpret_cast< win32_tun_io* >(listener);
// XXX: should we give up after a certain time and drop packet?
if(!pkt->write) if(!pkt->write)
{ {
// llarp::LogInfo("read tun ", size, " bytes, pass to handler"); // llarp::LogInfo("read tun ", size, " bytes, pass to handler");
@ -172,24 +173,24 @@ tun_ev_loop(void* unused)
delete pkt; delete pkt;
continue; continue;
} }
//EnterCriticalSection(&HandlerMtx); // EnterCriticalSection(&HandlerMtx);
if(ev->t->recvpkt) if(ev->t->recvpkt)
ev->t->recvpkt(ev->t, llarp_buffer_t(pkt->buf, size)); ev->t->recvpkt(ev->t, llarp_buffer_t(pkt->buf, size));
ev->read(ev->readbuf, sizeof(ev->readbuf)); ev->read(ev->readbuf, sizeof(ev->readbuf));
//LeaveCriticalSection(&HandlerMtx); // LeaveCriticalSection(&HandlerMtx);
} }
else else
{ {
// ok let's queue another read! // ok let's queue another read!
//EnterCriticalSection(&HandlerMtx); // EnterCriticalSection(&HandlerMtx);
ev->read(ev->readbuf, sizeof(ev->readbuf)); ev->read(ev->readbuf, sizeof(ev->readbuf));
//LeaveCriticalSection(&HandlerMtx); // LeaveCriticalSection(&HandlerMtx);
} }
EnterCriticalSection(&HandlerMtx);
if(ev->t->tick) if(ev->t->tick)
ev->t->tick(ev->t); ev->t->tick(ev->t);
LeaveCriticalSection(&HandlerMtx); EnterCriticalSection(&HandlerMtx);
ev->flush_write(); ev->flush_write();
LeaveCriticalSection(&HandlerMtx);
delete pkt; // don't leak delete pkt; // don't leak
} }
llarp::LogDebug("exit TUN event loop thread from system managed thread pool"); llarp::LogDebug("exit TUN event loop thread from system managed thread pool");