mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:52:59 +00:00
[lwIP]
- rewrite fix to race condition crash this time in a correct and much more elegant manner svn path=/branches/GSoC_2011/TcpIpDriver/; revision=52730
This commit is contained in:
parent
f0c093af20
commit
356e39f4b7
1 changed files with 12 additions and 10 deletions
|
@ -588,7 +588,12 @@ LibTCPShutdownCallback(void *arg)
|
||||||
{
|
{
|
||||||
struct shutdown_callback_msg *msg = arg;
|
struct shutdown_callback_msg *msg = arg;
|
||||||
|
|
||||||
|
if (msg->Pcb->state == ESTABLISHED || msg->Pcb->state == SYN_RCVD)
|
||||||
|
{
|
||||||
msg->Error = tcp_shutdown(msg->Pcb, msg->shut_rx, msg->shut_tx);
|
msg->Error = tcp_shutdown(msg->Pcb, msg->shut_rx, msg->shut_tx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
msg->Error = ERR_OK;
|
||||||
|
|
||||||
KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE);
|
KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE);
|
||||||
}
|
}
|
||||||
|
@ -599,7 +604,7 @@ LibTCPShutdown(struct tcp_pcb *pcb, const int shut_rx, const int shut_tx)
|
||||||
struct shutdown_callback_msg *msg;
|
struct shutdown_callback_msg *msg;
|
||||||
err_t ret;
|
err_t ret;
|
||||||
|
|
||||||
DbgPrint("[lwIP, LibTCPShutdown] Called on pcb = 0x%x\n", pcb);
|
DbgPrint("[lwIP, LibTCPShutdown] Called on pcb = 0x%x with rx = %d, tx = %d\n", pcb, shut_rx, shut_tx);
|
||||||
|
|
||||||
if (!pcb)
|
if (!pcb)
|
||||||
{
|
{
|
||||||
|
@ -607,7 +612,7 @@ LibTCPShutdown(struct tcp_pcb *pcb, const int shut_rx, const int shut_tx)
|
||||||
return ERR_CLSD;
|
return ERR_CLSD;
|
||||||
}
|
}
|
||||||
|
|
||||||
DbgPrint("[lwIP, LibTCPClose] pcb->state = %s\n", tcp_state_str[pcb->state]);
|
DbgPrint("[lwIP, LibTCPShutdown] pcb->state = %s\n", tcp_state_str[pcb->state]);
|
||||||
|
|
||||||
msg = ExAllocatePool(NonPagedPool, sizeof(struct shutdown_callback_msg));
|
msg = ExAllocatePool(NonPagedPool, sizeof(struct shutdown_callback_msg));
|
||||||
if (msg)
|
if (msg)
|
||||||
|
@ -658,19 +663,18 @@ LibTCPCloseCallback(void *arg)
|
||||||
DbgPrint("[lwIP, LibTCPCloseCallback] Closing a listener\n");
|
DbgPrint("[lwIP, LibTCPCloseCallback] Closing a listener\n");
|
||||||
msg->Error = tcp_close(msg->Pcb);
|
msg->Error = tcp_close(msg->Pcb);
|
||||||
}
|
}
|
||||||
else if (msg->Pcb->state != LAST_ACK && msg->Pcb->state != CLOSED)
|
else
|
||||||
{
|
{
|
||||||
DbgPrint("[lwIP, LibTCPCloseCallback] Aborting a connection\n");
|
DbgPrint("[lwIP, LibTCPCloseCallback] Aborting a connection\n");
|
||||||
tcp_abort(msg->Pcb);
|
tcp_abort(msg->Pcb);
|
||||||
msg->Error = ERR_OK;
|
msg->Error = ERR_OK;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
msg->Error = ERR_OK;
|
|
||||||
|
|
||||||
KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE);
|
KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
err_t
|
err_t
|
||||||
|
//LibTCPClose(struct tcp_pcb *pcb, const int safe)
|
||||||
LibTCPClose(struct tcp_pcb *pcb, const int safe)
|
LibTCPClose(struct tcp_pcb *pcb, const int safe)
|
||||||
{
|
{
|
||||||
err_t ret;
|
err_t ret;
|
||||||
|
@ -712,14 +716,12 @@ LibTCPClose(struct tcp_pcb *pcb, const int safe)
|
||||||
DbgPrint("[lwIP, LibTCPClose] Closing a listener\n");
|
DbgPrint("[lwIP, LibTCPClose] Closing a listener\n");
|
||||||
ret = tcp_close(pcb);
|
ret = tcp_close(pcb);
|
||||||
}
|
}
|
||||||
else if (pcb->state != LAST_ACK && pcb->state != CLOSED)
|
else
|
||||||
{
|
{
|
||||||
DbgPrint("[lwIP, LibTCPClose] Aborting a connection\n");
|
DbgPrint("[lwIP, LibTCPClose] Aborting a connection\n");
|
||||||
tcp_abort(pcb);
|
tcp_abort(pcb);
|
||||||
ret = ERR_OK;
|
ret = ERR_OK;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
ret = ERR_OK;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue