mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-06 22:44:38 +08:00
fixed bug #46321: Synchronization bug around lwip_select() and tcpip_thread() with thread-local semaphores
This commit is contained in:
parent
2dec8f449a
commit
f518c6578c
@ -1373,6 +1373,9 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
|||||||
struct lwip_select_cb select_cb;
|
struct lwip_select_cb select_cb;
|
||||||
int i;
|
int i;
|
||||||
int maxfdp2;
|
int maxfdp2;
|
||||||
|
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||||
|
int waited = 0;
|
||||||
|
#endif
|
||||||
SYS_ARCH_DECL_PROTECT(lev);
|
SYS_ARCH_DECL_PROTECT(lev);
|
||||||
|
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select(%d, %p, %p, %p, tvsec=%"S32_F" tvusec=%"S32_F")\n",
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select(%d, %p, %p, %p, tvsec=%"S32_F" tvusec=%"S32_F")\n",
|
||||||
@ -1470,6 +1473,9 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
waitres = sys_arch_sem_wait(SELECT_SEM_PTR(select_cb.sem), msectimeout);
|
waitres = sys_arch_sem_wait(SELECT_SEM_PTR(select_cb.sem), msectimeout);
|
||||||
|
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||||
|
waited = 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1512,7 +1518,12 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
|||||||
select_cb_ctr++;
|
select_cb_ctr++;
|
||||||
SYS_ARCH_UNPROTECT(lev);
|
SYS_ARCH_UNPROTECT(lev);
|
||||||
|
|
||||||
#if !LWIP_NETCONN_SEM_PER_THREAD
|
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||||
|
if (select_cb.sem_signalled && (!waited || (waitres == SYS_ARCH_TIMEOUT))) {
|
||||||
|
/* don't leave the thread-local semaphore signalled */
|
||||||
|
sys_arch_sem_wait(select_cb.sem, 1);
|
||||||
|
}
|
||||||
|
#else /* LWIP_NETCONN_SEM_PER_THREAD */
|
||||||
sys_sem_free(&select_cb.sem);
|
sys_sem_free(&select_cb.sem);
|
||||||
#endif /* LWIP_NETCONN_SEM_PER_THREAD */
|
#endif /* LWIP_NETCONN_SEM_PER_THREAD */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user