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)
{
s32 res;
s32 res=-1;
int retry;
int wait;
static bool first=true;
while(netHalt != 2)
{
retry = 30;
while (retry)
retry = 5;
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();
res = net_init_async(NULL, NULL);
if(res != 0)
break; // failed
{
sleep(1);
retry--;
continue;
}
res = net_get_status();
wait = 500; // only wait 10 sec
while (res == -EBUSY && wait > 0)
wait = 400; // only wait 10 sec
while (res == -EBUSY && wait > 0 && (netHalt != 2))
{
usleep(20000);
res = net_get_status();
wait--;
}
if (res != -EAGAIN && res != -ETIMEDOUT)
break;
if(res==0) break;
retry--;
usleep(2000);
continue;
}
if (res == 0)
{
struct in_addr hostip;
@ -219,10 +243,10 @@ static void * netcb (void *arg)
if (hostip.s_addr)
{
strcpy(wiiIP, inet_ntoa(hostip));
networkInit = true;
networkInit = true;
}
}
LWP_SuspendThread(networkthread);
if(netHalt != 2) LWP_SuspendThread(networkthread);
}
return NULL;
}
@ -305,6 +329,9 @@ bool InitializeNetwork(bool silent)
break;
retry = ErrorPromptRetry("Unable to initialize network!");
if(networkInit && net_gethostip() > 0)
return true;
}
return networkInit;
}