Author: cmihail
Date: Mon Jun 20 15:59:49 2011
New Revision: 52387
URL:
http://svn.reactos.org/svn/reactos?rev=52387&view=rev
Log:
[lwIP]
- Fix crash bug when disconnecting after accepting a connection from a client.
- Move the send and receive callback assignments to make the code more clear
- Change variable types to avoid excessive casting
Modified:
branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c
Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
==============================================================================
--- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] (original)
+++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] Mon Jun 20
15:59:49 2011
@@ -160,8 +160,6 @@
TCPConnectEventHandler(arg, err);
- tcp_recv(pcb, InternalRecvEventHandler);
-
return ERR_OK;
}
@@ -187,7 +185,7 @@
PVOID Arg;
/* Output */
- PVOID NewPcb;
+ struct tcp_pcb *NewPcb;
};
static
@@ -206,8 +204,8 @@
if (msg->NewPcb)
{
- tcp_arg((struct tcp_pcb*)msg->NewPcb, msg->Arg);
- tcp_err((struct tcp_pcb*)msg->NewPcb, InternalErrorEventHandler);
+ tcp_arg(msg->NewPcb, msg->Arg);
+ tcp_err(msg->NewPcb, InternalErrorEventHandler);
}
KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE);
@@ -217,7 +215,7 @@
LibTCPSocket(void *arg)
{
struct socket_callback_msg *msg = ExAllocatePool(NonPagedPool, sizeof(struct
socket_callback_msg));
- void *ret;
+ struct tcp_pcb *ret;
DbgPrint("[lwIP, LibTCPSocket] Called\n");
@@ -239,7 +237,7 @@
ExFreePool(msg);
- return (struct tcp_pcb*)ret;
+ return ret;
}
DbgPrint("[lwIP, LibTCPSocket] Done\n");
@@ -413,8 +411,6 @@
}
else
{
- tcp_sent(msg->Pcb, InternalSendEventHandler);
-
msg->Error = tcp_write(msg->Pcb, msg->Data, msg->DataLength,
TCP_WRITE_FLAG_COPY);
tcp_output(msg->Pcb);
@@ -480,6 +476,9 @@
DbgPrint("[lwIP, LibTCPConnectCallback] Called\n");
ASSERT(arg);
+
+ tcp_recv(msg->Pcb, InternalRecvEventHandler);
+ tcp_sent(msg->Pcb, InternalSendEventHandler);
msg->Error = tcp_connect(msg->Pcb, msg->IpAddress, ntohs(msg->Port),
InternalConnectEventHandler);
if (msg->Error == ERR_OK)
@@ -695,6 +694,7 @@
tcp_arg(pcb, NULL);
tcp_recv(pcb, InternalRecvEventHandler);
tcp_sent(pcb, InternalSendEventHandler);
+ tcp_err(pcb, InternalErrorEventHandler);
tcp_arg(pcb, arg);
tcp_accepted(listen_pcb);