lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Detect RST when using non blocking read.


From: Gisle Vanem
Subject: Re: [lwip-users] Detect RST when using non blocking read.
Date: Mon, 07 May 2012 18:58:24 +0200

"Karlsson, Johnny" <address@hidden> wrote:

Ok, that seems much better. But one more question .. You write that
there is a global variable 'errno', but isn't there one errno variable
for each socket?

Normally there should be no need for that since 'errno' should
only be checked immediately after any socket (or system) function fails
(returning '< 0' normally). 'errno' is undefined at other times. But in the case your OS or application is multithreaded, 'errno' should return correct value for the thread in question. Otherwise a race condition occurs. The definition of 'errno' (a macro on Windows) should consider this.

E.g. for Coldfire:

#define errno (*sys_arch_errno())
...

int *sys_arch_errno(void)
{
   struct sys_thread *thread;
   thread = current_thread();
   return &thread->errno_i;
}

--gv



reply via email to

[Prev in Thread] Current Thread [Next in Thread]