Skip to content

Commit 0a47a36

Browse files
committed
fix: restart accept_loop if method_buffer or route_buffer is null
1 parent a5db870 commit 0a47a36

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/main.asm

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ section .data
3939
dd 0
4040
dd 0
4141

42+
cleanup db "cleanup", 10, 0
43+
loop_enter db "entering loop", 10, 0
4244
server_on db "Server is running on port 3000", 0
4345

4446
section .text
@@ -79,6 +81,9 @@ main:
7981
call printf
8082

8183
.accept_loop:
84+
lea rcx, [rel cleanup]
85+
call printf
86+
8287
mov rcx, [rel listen_socket]
8388
xor rdx, rdx
8489
xor r8, r8
@@ -121,6 +126,14 @@ main:
121126
lea rdx, [rel route_buffer]
122127
call printf
123128

129+
mov al, byte [rel method_buffer]
130+
test al, al
131+
je .accept_loop
132+
133+
mov al, byte [rel route_buffer]
134+
test al, al
135+
je .accept_loop
136+
124137
lea rcx, [rel method_buffer]
125138
lea rdx, [rel route_buffer]
126139
call lookup
@@ -134,6 +147,9 @@ main:
134147
call rax
135148

136149
.cleanup:
150+
lea rcx, [rel cleanup]
151+
call printf
152+
137153
mov rcx, [rel client_socket]
138154

139155
mov edx, 1
@@ -142,8 +158,13 @@ main:
142158
mov rcx, [rel client_socket]
143159
call closesocket
144160

161+
lea rcx, [rel cleanup]
162+
call printf
163+
145164
jmp .accept_loop
146165

166+
ret
167+
147168
.fail_socket_ins:
148169
call fail_socket
149170
jmp .exit

0 commit comments

Comments
 (0)