Commit graph

539 commits

Author SHA1 Message Date
Cameron Gutman acd4c15b61 [AFD]
- Fix (hopefully) the final disconnect bugs

svn path=/trunk/; revision=52783
2011-07-22 15:11:01 +00:00
Cameron Gutman cb26a7762f [AFD]
- Only trigger the close event if the pending receive list is empty

svn path=/trunk/; revision=52775
2011-07-22 04:31:33 +00:00
Cameron Gutman 2e54713de3 [AFD]
- Wait to signal a graceful receive shutdown until all buffered transport data is read by the application

svn path=/trunk/; revision=52774
2011-07-22 04:11:50 +00:00
Cameron Gutman 78bd31b30d [AFD]
- Fix typos from my previous commit
- Fix another bug with recv() on a datagram socket
- Fix cancellation bugs

svn path=/trunk/; revision=52725
2011-07-18 11:27:01 +00:00
Cameron Gutman 2f00016a72 - Fix copy paste error
svn path=/trunk/; revision=52724
2011-07-18 04:25:08 +00:00
Cameron Gutman e37e340708 [AFD]
- Fix a nasty datagram corruption bug that would result in an uninitialized buffer data being returned instead of packet data if the client read buffer was smaller than the datagram received
- Fix broken user-mode send datagram IRP completion code which didn't set the completion status
- Implement disabling/enabling event select triggers

svn path=/trunk/; revision=52723
2011-07-18 04:21:40 +00:00
Cameron Gutman b38aed5d19 [IP/OSKITTCP]
- Fix a race condition that occurs when the socket is closed by the remote host while waiting on OSKLock to perform a socket operation and results in accessing freed memory

svn path=/trunk/; revision=52718
2011-07-17 17:37:36 +00:00
Cameron Gutman 13f96c816f [AFD]
- Change some debug prints to reduce useless spam

svn path=/trunk/; revision=52702
2011-07-16 19:16:45 +00:00
Cameron Gutman 6195434c6b [TCPIP]
- Fix the broken TDI_QUERY_CONNECTION_INFO implementation
- Perform buffer size checks on TDI_QUERY_MAX_DATAGRAM_INFO requests
[AFD]
- Greatly simplify AfdGetPeerName by using the remote address stored while connecting

svn path=/trunk/; revision=52698
2011-07-16 17:17:08 +00:00
Cameron Gutman 0ef6eb1c56 [AFD]
- Debugging overhaul

svn path=/trunk/; revision=52697
2011-07-16 16:57:07 +00:00
Cameron Gutman d309cc3c56 [TCPIP]
- Increase the default and overflow size of the TCP/IP packet pool to allow for periods of very high network load (such as using BitTorrent or hosting high load services on a network) without dropping outgoing or incoming packets
- Increase the size of the TCP/IP buffer pool for the same reason

svn path=/trunk/; revision=52641
2011-07-11 19:18:34 +00:00
Jérôme Gardou ef65e8cc09 [AFD]
- fix MSVC build

svn path=/trunk/; revision=52605
2011-07-10 13:28:47 +00:00
Cameron Gutman 38990db5fd [AFD]
- Fix broken TDI address functions which were causing subtle memory corruptions, wasted memory, and incorrect or uninitialized values of the address length field
- Remove some buggy code that wasn't used anywhere
- General refactoring to reduce code duplication
- Handle an invalid address type properly

svn path=/trunk/; revision=52600
2011-07-10 08:25:31 +00:00
Cameron Gutman 41406f9697 [AFD]
- Probe and lock pages with the KernelMode access mode instead of Irp->RequestorMode (UserMode) since we're dealing with memory that we allocated in kernel-mode
- Fixes getpeername() and HTTPS browsing in Firefox

svn path=/trunk/; revision=52597
2011-07-10 02:23:12 +00:00
Cameron Gutman 62cbe9d8f0 [AFD]
- Fix a desired access bug that totally broke event select
- FILE_ALL_ACCESS is NOT equal to EVENT_ALL_ACCESS

svn path=/trunk/; revision=52563
2011-07-07 23:17:23 +00:00
Cameron Gutman 31774f263a [AFD]
- Signal the event immediately if the select triggers have already been satisfied
- This fixes hangs with applications that wait on the select event before performing any socket operations

svn path=/trunk/; revision=52562
2011-07-07 22:43:35 +00:00
Cameron Gutman fff1ab8feb [AFD]
- Implement IOCTL_AFD_RECV for connection-less sockets
- Fix a parameter check
- Fixes recv() on datagram sockets

svn path=/trunk/; revision=52561
2011-07-07 20:44:47 +00:00
Cameron Gutman 14f58265d2 [AFD]
- Rewrite user-mode send IRP handling so send errors get returned to the user properly
- Fixes OskitTCP: ESHUTDOWN/EPIPE debug log spam when a chargen telnet session is terminated by the remote side

svn path=/trunk/; revision=52552
2011-07-07 00:29:30 +00:00
Cameron Gutman 4e5a783a2f [AFD]
- Move the TdiReceiveDatagram call to WarmSocketForBind like it is done for connects

svn path=/trunk/; revision=52539
2011-07-04 19:13:45 +00:00
Cameron Gutman 54f9acbf0d [AFD]
- Add support for AFD_INFO_INLINING_MODE
- Add support for setting AFD_INFO_RECEIVE_WINDOW_SIZE and AFD_INFO_SEND_WINDOW_SIZE
- None of this is used by our current msafd but mswsock_new uses it

svn path=/trunk/; revision=52538
2011-07-04 18:07:55 +00:00
Cameron Gutman 0e8f87ff82 [MSAFD/AFD]
- Pass the non-blocking information as a boolean (mswsock_new does this too)
[AFD]
- Don't block waiting for a connection to accept on a non-blocking listener

svn path=/trunk/; revision=52537
2011-07-04 17:37:45 +00:00
Cameron Gutman fd6bb26299 - Small fix for my last commit to prevent problems if ExAllocatePool fails
svn path=/trunk/; revision=52534
2011-07-04 15:45:58 +00:00
Cameron Gutman 72fe2efcf8 [AFD]
- Fix FIONREAD for datagram sockets

svn path=/trunk/; revision=52533
2011-07-04 15:35:16 +00:00
Cameron Gutman 00651a94cd [AFD]
- Fix a check so FIONREAD works for accepted sockets too

svn path=/trunk/; revision=52532
2011-07-04 00:30:04 +00:00
Cameron Gutman ba4ec529be [TCPIP]
- Only wait to bind to a port if INADDR_ANY is specified
- Fixes EADDRNOTAVAIL when running Firefox and ws2_32_winetest sock (which now gets further but still doesn't complete)

svn path=/trunk/; revision=52511
2011-07-03 02:13:57 +00:00
Cameron Gutman afa2c1d664 [AFD]
- We really do need to count the outstanding send IRP in our pending send count (with a detailed explanation of the reason included in the code)
- Wait on an outstanding send IRP to dispatch the disconnect
- When we receive a FIN from the other side and our receive comes back with 0 data, only close receiving on the socket because sending is still legal in this state
- Fixes many bugs on the ws2_32_winetest sock and likely lots of other partial disconnect related stuff
- Retest network related hanging bugs after this please (ftp dir hang is fixed)

svn path=/trunk/; revision=52510
2011-07-03 01:53:10 +00:00
Cameron Gutman 0669007af7 [TCPIP]
- Implement support for timing out disconnects
- Add debug prints for oskittcp errors
[MSAFD]
- Set a disconnect timeout value that actually makes sense (1 second vs 100 nanoseconds)

svn path=/trunk/; revision=52503
2011-07-02 20:36:35 +00:00
Cameron Gutman f828c2431c [AFD]
- Fix a corrupted disconnect timeout pointer being sent to the TDI transport driver

svn path=/trunk/; revision=52502
2011-07-02 20:26:21 +00:00
Cameron Gutman 16ded1b13b [TCPIP]
- Fix binding to an unspecified port on a connect so that it works reliably by asking the TCP library for a free port instead of assuming that one we have is free
- Fix binding to an unspecified port on a listen which previously would result in the address file not having information stored about the port number assigned
- Fix a nasty bug which resulted in us binding to an arbitrary port during a connect even when the client wanted a specific port
- Revert the hack that partially fixed this before

svn path=/trunk/; revision=52501
2011-07-02 15:37:37 +00:00
Cameron Gutman a45e92a406 [AFD]
- Rewrite disconnect to work asynchronously

svn path=/trunk/; revision=52497
2011-07-01 14:31:37 +00:00
Cameron Gutman 97b25874fc [AFD]
- Fix several bugs related to the FD_WRITE event
- We would not set the sendable poll state if the socket had data waiting to be sent even if there was buffer space
- We did not set the poll state after performing a send
- We did not clear the sendable poll state if we ran out of buffer space

svn path=/trunk/; revision=52492
2011-06-30 06:04:09 +00:00
Timo Kreuzer 871ee92c7b [CMAKE]
revert r52460, r52463, r52468 on behalf of Jerome
it wrongly gave name decorations to export

svn path=/trunk/; revision=52473
2011-06-26 21:29:55 +00:00
Jérôme Gardou 01a4049405 [CMAKE]
- unify spec2def and add_importlib_target, thanks to cmake_parse_arguments.
  - also generate stub files only when necessary.
  - better precompiled header support, commented out as it wasn't tested on any other machine than mine, and it depends on cmake features which don't exist yet.
For now only for gcc toolchain

svn path=/trunk/; revision=52460
2011-06-25 18:34:03 +00:00
Cameron Gutman f6485fab90 [AFD]
- Queue the user-mode connect IRP before calling TdiConnect to avoid a race if the TDI_CONNECT IRP is completed before we get a chance to queue the user-mode IRP to accept the connection
- Change the non-blocking TDI helper functions to always return STATUS_PENDING if the completion function will be called to avoid duplicate handling of IRPs

svn path=/trunk/; revision=52441
2011-06-24 14:06:48 +00:00
James Tabor a50aff948b - Fix debug build.
svn path=/trunk/; revision=52434
2011-06-23 22:25:50 +00:00
Cameron Gutman 6b7b487e8c [TCPIP/IP]
- Wait until the all pending sends are serviced before shutting down the socket on a graceful disconnect
- Cancel pending sends and receives on abortive disconnect
- Remove the nasty hack that was the completion queue and replace it with async completions like the lwIP implementation does
- There is a bug with the graceful disconnects which occurs if the graceful disconnect cannot be serviced immediately (a very rare case in my testing) and results in the shutdown() call stalling forever because oskittcp never indicates that send is possible again (which would allow pending send IRPs to be serviced and the shutdown IRP to be completed)

svn path=/trunk/; revision=52416
2011-06-22 00:41:40 +00:00
Cameron Gutman d7a7a20e8b [AFD]
- Hold on to the disconnect IRP until all pending sending IRPs are sent to the transport driver if a controlled disconnect was requested

svn path=/trunk/; revision=52415
2011-06-22 00:17:19 +00:00
Cameron Gutman 0fbf8e4374 [AFD]
- Remove extra cruft around the TdiReceive call
- Handle send and receive requests better after a socket closure

svn path=/trunk/; revision=52402
2011-06-21 13:59:49 +00:00
Cameron Gutman 2b116b187c [AFD]
- Complete receive requests with the correct status if the socket is unexpectedly closed

svn path=/trunk/; revision=52400
2011-06-21 13:02:42 +00:00
Cameron Gutman cbeac4750e [AFD]
- Only indicate that receive is possible if there are no pending receive IRPs waiting for data
- Don't attempt to receive on a connection which has been closed in the receive direction

svn path=/trunk/; revision=52224
2011-06-14 02:18:20 +00:00
Cameron Gutman 2c808bda98 [AFD]
- FD_CLOSE is only for remote disconnects so don't send it when the app closes its own socket
- Validate the user-mode event handle properly

svn path=/trunk/; revision=52223
2011-06-14 00:56:49 +00:00
Cameron Gutman f855ea9bdb [AFD]
- Fix packet size overflow check

svn path=/trunk/; revision=52195
2011-06-11 20:10:55 +00:00
Cameron Gutman dcf65c0e08 [AFD]
- Rewrite user-mode request locking to fix several bugs
- IRP_MJ_READ and IRP_MJ_WRITE doesn't crash
- Revert the IoModifyAccess change (the Write parameter was relevant to the buffer not the request)
- Use GetLockedData to retrieve a locked buffer instead of accessing it manually
- Lock several requests which were not locked and could cause a crash
- ASSERT that the in flight request is the IRP being completed
- Fix a socket closure bug so shutdown(SO_SEND) will not prevent packets being received
- Don't count bytes used in the receive content
- Don't free the datagram buffer if it is a peek request
- Requeue the datagram buffer at the head of the list if it is a peek request
- Fix a bug which could cause corrupted data to be received if multiple datagrams come in before the app receives them 
- Make sure that we're not overwriting an existing in flight request when creating a new one
- Perform an implicit bind in AfdPacketSocketWriteData if it is not already bound
- Implement batching several user-mode send IRPs into one TDI request (if there is already one pending)
- Fix a potential crash if a connectionless send IRP is cancelled

svn path=/trunk/; revision=52186
2011-06-11 12:46:04 +00:00
Cameron Gutman 4f74cccd2d [AFD]
- Cleanup the pending connection list before closing the FCB
- Fixes yet another socket closure bug

svn path=/trunk/; revision=52166
2011-06-09 22:38:38 +00:00
Cameron Gutman 17de5b1c0f [AFD]
- Fix a bug in some completion routines that resulted in failures being treated as successes
- Fix various cancellation bugs
- Fixes termination of programs that open listening sockets (Firefox, server.exe, tcpsvcs.exe, telnetd.exe, etc) and should increase stability in these programs as well

svn path=/trunk/; revision=52152
2011-06-08 22:15:27 +00:00
Cameron Gutman 84a9cedb4e [AFD]
- Fix IoModifyAccess vs IoReadAccess confusion

svn path=/trunk/; revision=52125
2011-06-06 22:55:17 +00:00
Cameron Gutman 768cc14b79 [AFD]
- Create an empty TRANSPORT_ADDRESS for the local address when doing an implicit bind so TCP/IP can choose its own local port and address instead of trying to bind the remote address and port
- Fixes another critical networking bug

svn path=/trunk/; revision=52092
2011-06-05 17:08:37 +00:00
Cameron Gutman b92d45b853 [IP/TCPIP]
- Add a Next member to CONNECTION_ENDPOINT to allow multiple connections to be associated with a single address file while not overwriting pointers, dereferencing other people's connection objects, and causing horrific amounts of memory corruption
- Add several sanity checks to prevent this from happening again
- Don't try dereference address files and connection endpoints in the free functions; there should be none associated since r52083 (sanity checks ensure this)
- Don't hold an extra reference to the address file when creating a listener; this reference is implicit
- This should greatly increase reliability of activities that open lots of sockets such as web browsing and running servers on ROS
- This also fixes most issues of not releasing a server port when the listener is closed

svn path=/trunk/; revision=52086
2011-06-05 02:16:45 +00:00
Cameron Gutman 588db734b0 [AFD]
- Disassociate the connection from the address file before closing them

svn path=/trunk/; revision=52083
2011-06-04 20:31:05 +00:00
Jérôme Gardou 989c121257 [CMAKE]
fix pch support, with proper dependancies.
  Use cmake built-in functions instead of doing weird "magic" with tabs and spaces.
  According to gcc doc, if header.h is precompiled, the output should be named "header.h.gch" and not anything else.

svn path=/trunk/; revision=52058
2011-06-02 12:18:22 +00:00