From 1237804b2b164486009d1dbc23bb9843bfbe2400 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 25 Sep 2011 09:39:48 +0800 Subject: [PATCH] Modules/IPStack - Updated worker thread invocation --- Modules/IPStack/link.c | 44 +++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/Modules/IPStack/link.c b/Modules/IPStack/link.c index e5e789a9..8bca51fc 100644 --- a/Modules/IPStack/link.c +++ b/Modules/IPStack/link.c @@ -92,30 +92,13 @@ void Link_SendPacket(tAdapter *Adapter, Uint16 Type, tMacAddr To, int Length, vo VFS_Write(Adapter->DeviceFD, bufSize, buf); } -/** - * \fn void Link_WatchDevice(tAdapter *Adapter) - * \brief Spawns a worker thread to watch the specified adapter - */ -void Link_WatchDevice(tAdapter *Adapter) +void Link_WorkerThread(void *Ptr) { - int tid = Proc_SpawnWorker(); // Create a new worker thread - - if(tid < 0) { - Log_Warning("Net Link", "Unable to create watcher thread for '%s'", Adapter->Device); - return ; - } - - if(tid > 0) { - Log_Log("Net Link", "Watching '%s' using tid %i", Adapter->Device, tid); - return ; - } - - if( !gbLink_CRCTableGenerated ) - Link_InitCRC(); + tAdapter *Adapter = Ptr; Threads_SetName(Adapter->Device); Log_Log("Net Link", "Thread %i watching '%s'", Threads_GetTID(), Adapter->Device); - + // Child Thread while(Adapter->DeviceFD != -1) { @@ -173,6 +156,27 @@ void Link_WatchDevice(tAdapter *Adapter) Threads_Exit(0, 0); } +/** + * \fn void Link_WatchDevice(tAdapter *Adapter) + * \brief Spawns a worker thread to watch the specified adapter + */ +void Link_WatchDevice(tAdapter *Adapter) +{ + int tid; + + if( !gbLink_CRCTableGenerated ) + Link_InitCRC(); + + tid = Proc_SpawnWorker(Link_WorkerThread, Adapter); // Create a new worker thread + + if(tid < 0) { + Log_Warning("Net Link", "Unable to create watcher thread for '%s'", Adapter->Device); + return ; + } + + Log_Log("Net Link", "Watching '%s' using tid %i", Adapter->Device, tid); +} + // From http://www.cl.cam.ac.uk/research/srg/bluebook/21/crc/node6.html #define QUOTIENT 0x04c11db7 void Link_InitCRC(void) -- 2.20.1