Compare commits

..
Author SHA1 Message Date
Leency 6fc8e7596f kernel/net: send nothing on a connection the peer has reset
Check kernel codestyle / Check kernel codestyle (pull_request) Successful in 33s
Test PR / Build (en_US) (pull_request) Successful in 3m35s
Test PR / Build (es_ES) (pull_request) Successful in 3m32s
Test PR / Build (ru_RU) (pull_request) Successful in 3m6s
2026-09-30 10:14:21 +03:00
Leency 8a4662a4c1 kernel/net: stop the TCP timers when the peer resets the connection 2026-09-30 10:14:21 +03:00
Leency 78d8a28f6c kernel/net: mark a TCP socket disconnected when the peer resets it
.econnreset only set t_state = CLOSED, so SS_CANTSENDMORE stayed clear:
send still succeeded and wiped ECONNRESET. Now it fails with ECONNRESET
and a blocked recv wakes up.
2026-09-30 10:14:20 +03:00
Leency 8d0f70c92d kernel/net: fail socket_send on a connection the peer has closed
socket_send_tcp took the data into the transmit ring, cleared the
socket's errorcode and only then called tcp_output, and it never looked
at SS_CANTSENDMORE. After tcp_drop/tcp_close (a RST or FIN from the
peer) had run socket_is_disconnected, a send therefore "succeeded" until
the ring was full and then returned 0 bytes with errorcode 0 -- byte for
byte the answer a healthy socket gives while the kernel drains the ring.
An application writing a large request never learned the connection was
dead; NetSurf on the 2009 QEMU/slirp sat 20 s per upload at ~100 KB of
25 MB with nothing to distinguish it from a slow uplink.

Return -1 with the error the drop recorded (ECONNRESET, ...), or
ENOTCONN when nothing was recorded, when SS_CANTSENDMORE is set.
2026-09-30 10:14:19 +03:00
8 changed files with 29 additions and 5681 deletions

No files matched your search

-1
View File
@@ -523,7 +523,6 @@ tup.append_table(img_files, {
{"LIB/RASTERWORKS.OBJ", VAR_PROGS .. "/develop/libraries/fontRasterWorks_unicode/RasterWorks.obj"},
{"LIB/SORT.OBJ", VAR_PROGS .. "/develop/libraries/sorter/sort.obj"},
{"LIB/TINYGL.OBJ", VAR_PROGS .. "/develop/libraries/TinyGL/asm_fork/tinygl.obj"},
{"LIB/XML.OBJ", VAR_PROGS .. "/develop/libraries/asm-xml/xml.obj"},
{"MEDIA/ANIMAGE", VAR_PROGS .. "/media/animage/animage"},
{"MEDIA/FILLSCR", VAR_PROGS .. "/media/FillScr/fillscr"},
{"MEDIA/KIV", VAR_PROGS .. "/media/kiv/kiv"},
+15
View File
@@ -1068,6 +1068,11 @@ socket_send_tcp:
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: TCP\n"
; Connection closed or reset by peer?
test [eax + SOCKET.state], SS_CANTSENDMORE
jnz .cantsendmore
push eax
add eax, STREAM_SOCKET.snd
call socket_ring_write
@@ -1082,6 +1087,16 @@ socket_send_tcp:
mov [esp + SYSCALL_STACK.ebx], eax
ret
.cantsendmore:
mov ebx, [eax + SOCKET.errorcode]
test ebx, ebx
jnz @f
mov ebx, ENOTCONN
@@:
mov [esp + SYSCALL_STACK.ebx], ebx
mov dword[esp + SYSCALL_STACK.eax], -1
ret
align 4
socket_send_ip:
+4
View File
@@ -864,6 +864,10 @@ endl
mov [ebx + TCP_SOCKET.t_state], TCPS_CLOSED
inc [TCPS_drops]
; Stop the timers, wake up the application
mov eax, ebx
call tcp_cancel_timers
call socket_is_disconnected
jmp .drop
+10
View File
@@ -63,6 +63,15 @@ endl
.not_idle:
.again:
; Connection was reset by peer, send nothing
cmp [eax + TCP_SOCKET.t_state], TCPS_CLOSED
jne @f
mov ebx, [eax + SOCKET.state]
and ebx, SS_CANTSENDMORE + SS_ISDISCONNECTING
cmp ebx, SS_CANTSENDMORE
je .nothing_to_send
@@:
mov [temp_bits], 0
; Calculate offset
@@ -306,6 +315,7 @@ endl
;----------------------------
; No reason to send a segment
.nothing_to_send:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: No reason to send a segment\n"
pusha
@@ -1,25 +0,0 @@
Copyright (c) 2007-2012, Marc Kerbiquet
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of AsmXml nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,2 +0,0 @@
if tup.getconfig("NO_FASM") ~= "" then return end
tup.rule("xml.asm", "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "xml.obj")
File diff suppressed because it is too large. Load diff
@@ -1,59 +0,0 @@
; SPDX-License-Identifier: GPL-2.0-only
;
; xml.obj - AsmXml parser as a KolibriOS library
; Copyright (C) KolibriOS team 2026
;
; asm-xml.asm and LICENSE.txt are the unmodified AsmXml 1.4 release
; by Marc Kerbiquet (BSD 3-clause), https://tibleiz.net/asm-xml/
format MS COFF
public EXPORTS
section '.flat' code readable align 16
; AsmXml calls malloc/free as cdecl, the heap functions given to lib_init
; are stdcall: the caller pops the argument they have already taken
lib_init:
mov [mem.alloc], eax
mov [mem.free], ebx
mov eax, malloc
mov ebx, free
jmp initialize
malloc:
push dword [esp + 4]
call [mem.alloc]
ret
free:
push dword [esp + 4]
call [mem.free]
ret
align 4
mem.alloc dd ?
mem.free dd ?
align 16
EXPORTS:
dd sz_lib_init, lib_init
dd sz_initializeParser, _initializeParser
dd sz_releaseParser, _releaseParser
dd sz_parse, _parse
dd sz_initializeClassParser, _initializeClassParser
dd sz_releaseClassParser, _releaseClassParser
dd sz_classFromElement, _classFromElement
dd sz_classFromString, _classFromString
dd 0, 0
sz_lib_init db 'lib_init', 0
sz_initializeParser db 'ax_initializeParser', 0
sz_releaseParser db 'ax_releaseParser', 0
sz_parse db 'ax_parse', 0
sz_initializeClassParser db 'ax_initializeClassParser', 0
sz_releaseClassParser db 'ax_releaseClassParser', 0
sz_classFromElement db 'ax_classFromElement', 0
sz_classFromString db 'ax_classFromString', 0
include 'asm-xml.asm'