From 6c7a0d9c0056cab4880b3ad8c076ee5ab49ad2e6 Mon Sep 17 00:00:00 2001 From: dborth Date: Fri, 20 Aug 2010 22:32:41 +0000 Subject: [PATCH] improve net init code --- source/networkop.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/source/networkop.cpp b/source/networkop.cpp index 953a618..45e4358 100644 --- a/source/networkop.cpp +++ b/source/networkop.cpp @@ -185,8 +185,9 @@ static u8 netstack[8192] ATTRIBUTE_ALIGN (32); static void * netcb (void *arg) { - s32 res = 0; + s32 res; int retry; + int wait; while(netHalt != 2) { @@ -194,14 +195,19 @@ static void * netcb (void *arg) while (retry) { - if (net_init_async(NULL, NULL) != 0) + net_deinit(); + res = net_init_async(NULL, NULL); + + if(res != 0) break; // failed res = net_get_status(); - while (res == -EBUSY) + wait = 500; // only wait 10 sec + while (res == -EBUSY && wait > 0) { usleep(20000); res = net_get_status(); + wait--; } if (res != -EAGAIN && res != -ETIMEDOUT) @@ -212,7 +218,7 @@ static void * netcb (void *arg) continue; } - if (res >= 0) + if (res == 0) { networkInit = true; @@ -221,7 +227,6 @@ static void * netcb (void *arg) if (hostip.s_addr) strcpy(wiiIP, inet_ntoa(hostip)); } - LWP_SuspendThread(networkthread); } return NULL;