Author: cgutman
Date: Tue Jun 21 16:23:27 2011
New Revision: 52405
URL:
http://svn.reactos.org/svn/reactos?rev=52405&view=rev
Log:
[IP]
- Don't attempt to service a request if the only flag specified was SEL_FIN
- Handle TDI_DISCONNECT_RELEASE properly
[OSKITTCP]
- Verify that the socket is in a legal state to do a send or receive
- Don't indicate send and receive events when the socket is not connected or has been
been closed in that particular direction
- Add a small hack to soshutdown so shutdown in the send direction works correctly (ie.
doesn't shutdown receive)
- Fixes the hangs in ws2_32_apitest ioctlsocket and ws2_32_apitest recv
Modified:
trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c
trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c
trunk/reactos/lib/drivers/oskittcp/oskittcp/sleep.c
trunk/reactos/lib/drivers/oskittcp/oskittcp/uipc_socket.c
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/t…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] Tue Jun 21 16:23:27
2011
@@ -69,10 +69,17 @@
TI_DbgPrint(DEBUG_TCP,("Getting the socket\n"));
- Status = TCPServiceListeningSocket
- ( Connection->AddressFile->Listener,
- Bucket->AssociatedEndpoint,
- (PTDI_REQUEST_KERNEL)&IrpSp->Parameters );
+ if (Connection->SignalState & SEL_ACCEPT)
+ {
+ Status =
TCPServiceListeningSocket(Connection->AddressFile->Listener,
+ Bucket->AssociatedEndpoint,
+
(PTDI_REQUEST_KERNEL)&IrpSp->Parameters);
+ }
+ else
+ {
+ /* We got here because of a SEL_FIN event */
+ Status = STATUS_CANCELLED;
+ }
TI_DbgPrint(DEBUG_TCP,("Socket: Status: %x\n"));
@@ -121,12 +128,19 @@
Connection->SocketContext));
TI_DbgPrint(DEBUG_TCP, ("RecvBuffer: %x\n", RecvBuffer));
- Status = TCPTranslateError
- ( OskitTCPRecv( Connection->SocketContext,
- RecvBuffer,
- RecvLen,
- &Received,
- 0 ) );
+ if (Connection->SignalState & SEL_READ)
+ {
+ Status = TCPTranslateError(OskitTCPRecv(Connection->SocketContext,
+ RecvBuffer,
+ RecvLen,
+ &Received,
+ 0));
+ }
+ else
+ {
+ /* We got here because of a SEL_FIN event */
+ Status = STATUS_CANCELLED;
+ }
TI_DbgPrint(DEBUG_TCP,("TCP Bytes: %d\n", Received));
@@ -175,12 +189,19 @@
("Connection->SocketContext: %x\n",
Connection->SocketContext));
- Status = TCPTranslateError
- ( OskitTCPSend( Connection->SocketContext,
- SendBuffer,
- SendLen,
- &Sent,
- 0 ) );
+ if (Connection->SignalState & SEL_WRITE)
+ {
+ Status = TCPTranslateError(OskitTCPSend(Connection->SocketContext,
+ SendBuffer,
+ SendLen,
+ &Sent,
+ 0));
+ }
+ else
+ {
+ /* We got here because of a SEL_FIN event */
+ Status = STATUS_CANCELLED;
+ }
TI_DbgPrint(DEBUG_TCP,("TCP Bytes: %d\n", Sent));
@@ -648,7 +669,7 @@
LockObject(Connection, &OldIrql);
if (Flags & TDI_DISCONNECT_RELEASE)
- Status = TCPTranslateError(OskitTCPDisconnect(Connection->SocketContext));
+ Status = TCPTranslateError(OskitTCPShutdown(Connection->SocketContext,
FWRITE));
if ((Flags & TDI_DISCONNECT_ABORT) || !Flags)
Status = TCPTranslateError(OskitTCPShutdown(Connection->SocketContext, FWRITE
| FREAD));
Modified: trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/oskittcp/oskit…
==============================================================================
--- trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/oskittcp/oskittcp/interface.c [iso-8859-1] Tue Jun 21
16:23:27 2011
@@ -148,6 +148,7 @@
OSK_UINT Len,
OSK_UINT *OutLen,
OSK_UINT Flags ) {
+ struct socket *so = connection;
struct uio uio = { 0 };
struct iovec iov = { 0 };
int error = 0;
@@ -155,9 +156,12 @@
if (!connection)
return OSK_ESHUTDOWN;
+
+ if (so->so_state & SS_CANTRCVMORE)
+ return OSK_ESHUTDOWN;
OS_DbgPrint(OSK_MID_TRACE,
- ("so->so_state %x\n", ((struct socket
*)connection)->so_state));
+ ("so->so_state %x\n", so->so_state));
if( Flags & OSK_MSG_OOB ) tcp_flags |= MSG_OOB;
if( Flags & OSK_MSG_DONTWAIT ) tcp_flags |= MSG_DONTWAIT;
@@ -290,11 +294,15 @@
int OskitTCPSend( void *socket, OSK_PCHAR Data, OSK_UINT Len,
OSK_UINT *OutLen, OSK_UINT flags ) {
+ struct socket *so = socket;
int error;
struct uio uio;
struct iovec iov;
if (!socket)
+ return OSK_ESHUTDOWN;
+
+ if (so->so_state & SS_CANTSENDMORE)
return OSK_ESHUTDOWN;
iov.iov_len = Len;
Modified: trunk/reactos/lib/drivers/oskittcp/oskittcp/sleep.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/oskittcp/oskit…
==============================================================================
--- trunk/reactos/lib/drivers/oskittcp/oskittcp/sleep.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/oskittcp/oskittcp/sleep.c [iso-8859-1] Tue Jun 21 16:23:27
2011
@@ -31,11 +31,13 @@
OS_DbgPrint(OSK_MID_TRACE,("Socket accepting q\n"));
flags |= SEL_ACCEPT;
}
- if( so->so_rcv.sb_cc > 0 ) {
+ if( so->so_rcv.sb_cc > 0 && !(so->so_state & SS_CANTRCVMORE)
&&
+ (so->so_state & SS_ISCONNECTED) ) {
OS_DbgPrint(OSK_MID_TRACE,("Socket readable\n"));
flags |= SEL_READ;
}
- if( 0 < sbspace(&so->so_snd) ) {
+ if( 0 < sbspace(&so->so_snd) && !(so->so_state &
SS_CANTSENDMORE) &&
+ (so->so_state & SS_ISCONNECTED) ) {
OS_DbgPrint(OSK_MID_TRACE,("Socket writeable\n"));
flags |= SEL_WRITE;
}
@@ -51,7 +53,7 @@
if( OtcpEvent.SocketState )
OtcpEvent.SocketState( OtcpEvent.ClientData,
so,
- so ? so->so_connection : 0,
+ so->so_connection,
flags );
if( OtcpEvent.Wakeup )
Modified: trunk/reactos/lib/drivers/oskittcp/oskittcp/uipc_socket.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/oskittcp/oskit…
==============================================================================
--- trunk/reactos/lib/drivers/oskittcp/oskittcp/uipc_socket.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/oskittcp/oskittcp/uipc_socket.c [iso-8859-1] Tue Jun 21
16:23:27 2011
@@ -826,7 +826,13 @@
{
register struct protosw *pr = so->so_proto;
+#ifndef __REACTOS__
+ /* Reads are always killed whether we want
+ * them stopped or not. We don't want this
+ * happening on ROS so this code is commented out
+ */
how++;
+#endif
if (how & FREAD)
sorflush(so);
if (how & FWRITE)