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
[email protected]
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
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to