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: Geir Ertzaas
Subject: Re: [lwip-users] Possible race condition in netconn_write
Date: Tue, 23 May 2006 16:48:29 +0200
User-agent: Thunderbird 1.5.0.2 (Windows/20060308)

Craig Graham wrote:
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.


_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users


  

I considered doing this, however I did not see any reason to recreate the semaphore for every call to netconn_write. I am having trouble seeing why this semaphore is created/deleted every time, am I missing something here?

Regards,
Geir

reply via email to

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