This commit is contained in:
dborth 2011-02-04 04:42:20 +00:00
parent 38f0f2470f
commit af4e153893

View File

@ -179,39 +179,63 @@ static u8 netstack[8192] ATTRIBUTE_ALIGN (32);
static void * netcb (void *arg) static void * netcb (void *arg)
{ {
s32 res; s32 res=-1;
int retry; int retry;
int wait; int wait;
static bool first=true;
while(netHalt != 2) while(netHalt != 2)
{ {
retry = 30; retry = 5;
while (retry) while (retry>0 && (netHalt != 2))
{ {
if(!first)
{
bool reset=false;
int i;
for(i=0;i<500 && (netHalt != 2);i++) // 10 seconds to try to reset
{
res = net_get_status();
if(res != -EBUSY) // trying to init net so we can't kill the net
{
net_wc24cleanup(); //kill the net
reset=true;
break;
}
usleep(20000);
}
if(!reset)
{
retry--;
continue;
}
}
first=false;
net_deinit(); net_deinit();
res = net_init_async(NULL, NULL); res = net_init_async(NULL, NULL);
if(res != 0) if(res != 0)
break; // failed {
sleep(1);
retry--;
continue;
}
res = net_get_status(); res = net_get_status();
wait = 500; // only wait 10 sec wait = 400; // only wait 10 sec
while (res == -EBUSY && wait > 0) while (res == -EBUSY && wait > 0 && (netHalt != 2))
{ {
usleep(20000); usleep(20000);
res = net_get_status(); res = net_get_status();
wait--; wait--;
} }
if (res != -EAGAIN && res != -ETIMEDOUT) if(res==0) break;
break;
retry--; retry--;
usleep(2000); usleep(2000);
continue;
} }
if (res == 0) if (res == 0)
{ {
struct in_addr hostip; struct in_addr hostip;
@ -222,7 +246,7 @@ static void * netcb (void *arg)
networkInit = true; networkInit = true;
} }
} }
LWP_SuspendThread(networkthread); if(netHalt != 2) LWP_SuspendThread(networkthread);
} }
return NULL; return NULL;
} }
@ -305,6 +329,9 @@ bool InitializeNetwork(bool silent)
break; break;
retry = ErrorPromptRetry("Unable to initialize network!"); retry = ErrorPromptRetry("Unable to initialize network!");
if(networkInit && net_gethostip() > 0)
return true;
} }
return networkInit; return networkInit;
} }