mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-02-06 18:41:30 +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:
|
++ 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
|
2007-03-22 Frédéric Bernon
|
||||||
* api_msg.h, api_msg.c: Remove obsolete API_MSG_ACCEPT and do_accept (never used).
|
* 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)
|
netconn_write(struct netconn *conn, const void *dataptr, u16_t size, u8_t copy)
|
||||||
{
|
{
|
||||||
struct api_msg msg;
|
struct api_msg msg;
|
||||||
u16_t len;
|
u16_t len, sndbuf;
|
||||||
|
|
||||||
if (conn == NULL) {
|
if (conn == NULL) {
|
||||||
return ERR_VAL;
|
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;
|
msg.msg.msg.w.copy = copy;
|
||||||
|
|
||||||
if (conn->type == NETCONN_TCP) {
|
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);
|
sys_sem_wait(conn->sem);
|
||||||
if (conn->err != ERR_OK) {
|
if (conn->err != ERR_OK) {
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (size > tcp_sndbuf(conn->pcb.tcp)) {
|
if (size > sndbuf) {
|
||||||
/* We cannot send more than one send buffer's worth of data at a
|
/* We cannot send more than one send buffer's worth of data at a time. */
|
||||||
time. */
|
len = sndbuf;
|
||||||
len = tcp_sndbuf(conn->pcb.tcp);
|
|
||||||
} else {
|
} else {
|
||||||
len = size;
|
len = size;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user