From 7ed9da60ebe2b7cb7f8306860c2b586e336354f1 Mon Sep 17 00:00:00 2001 From: neil Date: Thu, 1 May 2014 15:14:46 +0000 Subject: [PATCH] - Don't call "stop" function when already stopped. Fixes freeing memory twice. - Corrected signal masks. Process now quits on shutdown, which allows the device to be reopened after being expunged. - Avoid race condition on shutdown by waiting until process has really quit. - Expunge device when closed. This is a work-around to allow DHCP to work the second and subsequent times the device is used. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@48977 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/devs/networks/pcnet32/pcnet32.conf | 2 +- workbench/devs/networks/pcnet32/pcnet32_init.c | 6 +++++- workbench/devs/networks/pcnet32/unit.c | 7 +++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/workbench/devs/networks/pcnet32/pcnet32.conf b/workbench/devs/networks/pcnet32/pcnet32.conf index 574016cd3e..ba4e31e2a4 100644 --- a/workbench/devs/networks/pcnet32/pcnet32.conf +++ b/workbench/devs/networks/pcnet32/pcnet32.conf @@ -1,5 +1,5 @@ ##begin config -version 1.1 +version 1.2 basename PCNet32 libbase PCNet32Base libbasetype struct PCN32Base diff --git a/workbench/devs/networks/pcnet32/pcnet32_init.c b/workbench/devs/networks/pcnet32/pcnet32_init.c index 9c5a88da71..9cb843e408 100644 --- a/workbench/devs/networks/pcnet32/pcnet32_init.c +++ b/workbench/devs/networks/pcnet32/pcnet32_init.c @@ -259,7 +259,8 @@ static int GM_UNIQUENAME(Close) D(bug("[pcnet32] init.CloseDevice\n")); - unit->stop(unit); + if((unit->pcnu_flags & IFF_UP) != 0) + unit->stop(unit); opener = (APTR)req->ios2_BufferManagement; if (opener != NULL) @@ -270,6 +271,9 @@ D(bug("[pcnet32] init.CloseDevice\n")); FreeVec(opener); } + /* Without this, DHCP doesn't work the second time the device is used */ + RemDevice((struct Device *)LIBBASE); + return TRUE; } diff --git a/workbench/devs/networks/pcnet32/unit.c b/workbench/devs/networks/pcnet32/unit.c index 2e097502ce..544862afb6 100644 --- a/workbench/devs/networks/pcnet32/unit.c +++ b/workbench/devs/networks/pcnet32/unit.c @@ -987,7 +987,7 @@ D(bug("[pcnet32] PCN32_Schedular: entering forever loop ... \n")); for(;;) { ULONG recvd = Wait(sigset); - if (recvd & dev->pcnu_signal_0) + if (recvd & 1 << dev->pcnu_signal_0) { /* * Shutdown process. Driver should close everything @@ -1346,7 +1346,10 @@ void DeleteUnit(struct PCN32Base *PCNet32Base, struct PCN32Unit *Unit) { if (Unit->pcnu_Process) { - Signal(&Unit->pcnu_Process->pr_Task, Unit->pcnu_signal_0); + /* Tell our process to quit, and wait until it does so */ + Signal(&Unit->pcnu_Process->pr_Task, 1 << Unit->pcnu_signal_0); + while (FindTask(PCNET32_TASK_NAME) != NULL) + Delay(5); } for (i=0; i < REQUEST_QUEUE_COUNT; i++) -- 2.11.4.GIT