lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Possible race condition in netconn_write


From: Craig Graham
Subject: Re: [lwip-users] Possible race condition in netconn_write
Date: Tue, 23 May 2006 15:11:17 +0100
User-agent: KMail/1.8.2

On Tuesday 23 May 2006 11:58, Geir Ertzaas wrote:
> In netconn_write :
>
> ..
> ret:
>  memp_free(MEMP_API_MSG, msg);
>  conn->state = NETCONN_NONE;
>  if (conn->sem != SYS_SEM_NULL) {
>    sys_sem_free(conn->sem);                    //<<-- Potential race
> condition.
>    conn->sem = SYS_SEM_NULL;                   //<<--
>  }
>
>  return conn->err;
> ..

Couldn't it be fixed by doing this instead?

 ret:
  memp_free(MEMP_API_MSG, msg);
  conn->state = NETCONN_NONE;
  if (conn->sem != SYS_SEM_NULL) {
    sys_sem_t semToDelete=conn->sem; // save the semaphore
    conn->sem = SYS_SEM_NULL;        // set the pointer to NULL in the netconn
    sys_sem_free(semToDelete);       // now we can delete it....
  }

Laters,
Craig.




reply via email to

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