mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-04 23:29:25 +00:00
api_lib.c (from Dmitry Potapov) : patch for netconn_write(), fixes a possible race condition which cause to send some garbage. It is not a definitive solution, but the patch does solve the problem for most cases.
This commit is contained in:
parent
e54cd23ecb
commit
005e5f2f72
@ -78,6 +78,11 @@ HISTORY
|
||||
|
||||
++ Bug fixes:
|
||||
|
||||
2007-03-26 Frédéric Bernon (based on patch from Dmitry Potapov)
|
||||
* api_lib.c: patch for netconn_write(), fixes a possible race condition which cause
|
||||
to send some garbage. It is not a definitive solution, but the patch does solve
|
||||
the problem for most cases.
|
||||
|
||||
2007-03-22 Frédéric Bernon
|
||||
* api_msg.h, api_msg.c: Remove obsolete API_MSG_ACCEPT and do_accept (never used).
|
||||
|
||||
|
@ -589,7 +589,7 @@ err_t
|
||||
netconn_write(struct netconn *conn, const void *dataptr, u16_t size, u8_t copy)
|
||||
{
|
||||
struct api_msg msg;
|
||||
u16_t len;
|
||||
u16_t len, sndbuf;
|
||||
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
@ -608,16 +608,15 @@ netconn_write(struct netconn *conn, const void *dataptr, u16_t size, u8_t copy)
|
||||
msg.msg.msg.w.copy = copy;
|
||||
|
||||
if (conn->type == NETCONN_TCP) {
|
||||
if (tcp_sndbuf(conn->pcb.tcp) == 0) {
|
||||
while ((sndbuf = tcp_sndbuf(conn->pcb.tcp)) == 0) {
|
||||
sys_sem_wait(conn->sem);
|
||||
if (conn->err != ERR_OK) {
|
||||
goto ret;
|
||||
}
|
||||
}
|
||||
if (size > tcp_sndbuf(conn->pcb.tcp)) {
|
||||
/* We cannot send more than one send buffer's worth of data at a
|
||||
time. */
|
||||
len = tcp_sndbuf(conn->pcb.tcp);
|
||||
if (size > sndbuf) {
|
||||
/* We cannot send more than one send buffer's worth of data at a time. */
|
||||
len = sndbuf;
|
||||
} else {
|
||||
len = size;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user