mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2025-04-12 02:38:38 +01:00
Fix TCP Socket Send/Receive not returning upon timeout.
This commit is contained in:
parent
9f0e880fab
commit
6f6c8df2e9
3 changed files with 16 additions and 6 deletions
Binary file not shown.
|
@ -1227,9 +1227,14 @@ I64 TCPSocketReceive(CTCPSocket *tcp_socket, U8 *buffer, I64 length)
|
|||
timeout = counts.jiffies + tcp_socket->timeout * JIFFY_FREQ / 1000;
|
||||
|
||||
while ((tcp_socket->state == TCP_STATE_ESTABLISHED || tcp_socket->state == TCP_STATE_FIN_WAIT1) &&
|
||||
tcp_socket->read_position == tcp_socket->write_position &&
|
||||
counts.jiffies < timeout)
|
||||
tcp_socket->read_position == tcp_socket->write_position)
|
||||
{
|
||||
if (counts.jiffies > timeout)
|
||||
{
|
||||
NetErr("TCP SOCKET RECEIVE: Timed out.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
TCPCheckACKQueue(tcp_socket);
|
||||
Sleep(1);
|
||||
}
|
||||
|
@ -1287,10 +1292,15 @@ I64 TCPSocketSend(CTCPSocket *tcp_socket, U8 *buffer, I64 length)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
while (counts.jiffies < timeout &&
|
||||
(tcp_socket->state == TCP_STATE_ESTABLISHED || tcp_socket->state == TCP_STATE_CLOSE_WAIT) &&
|
||||
while ((tcp_socket->state == TCP_STATE_ESTABLISHED || tcp_socket->state == TCP_STATE_CLOSE_WAIT) &&
|
||||
length)
|
||||
{
|
||||
if (counts.jiffies > timeout)
|
||||
{
|
||||
NetErr("TCP SOCKET SEND: Timed out.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
send_length = (tcp_socket->first_unacked_seq + tcp_socket->send_window - tcp_socket->next_send_seq_num) & 0xFFFFFFFF;
|
||||
|
||||
// Shrine has TODO: Keep trying, tie to timeout: RFC 793 "Managing The Window"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CTCPSocket *tcp = TCPSocket(AF_INET);
|
||||
CTCPSocket *new;
|
||||
U8 buffer_size = 16;
|
||||
U8 buffer_size = TCP_MSS;
|
||||
U8 *buffer = CAlloc(buffer_size);
|
||||
|
||||
CSocketAddressIPV4 *socket_addr = CAlloc(sizeof(CSocketAddressIPV4));
|
||||
|
@ -45,7 +45,7 @@ U0 TCPTest()
|
|||
|
||||
"\n\n";
|
||||
|
||||
Dm(buffer, buffer_size);
|
||||
D(buffer, buffer_size, FALSE);
|
||||
|
||||
"\n\n";
|
||||
|
||||
|
|
Loading…
Reference in a new issue