mirror of
https://github.com/BoredDevNL/BoredOS.git
synced 2026-05-15 10:48:38 +00:00
Timeout Fix
Updated the timeout in ping from a busy wait (cpu clock speed based) to a proper timeout using wm_get_ticks()
This commit is contained in:
parent
3722fe33f8
commit
904dc2f1a5
5 changed files with 9 additions and 4 deletions
BIN
brewos.iso
BIN
brewos.iso
Binary file not shown.
BIN
build/brewos.elf
BIN
build/brewos.elf
Binary file not shown.
BIN
build/icmp.o
BIN
build/icmp.o
Binary file not shown.
Binary file not shown.
|
|
@ -1,6 +1,7 @@
|
||||||
#include "net_defs.h"
|
#include "net_defs.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "memory_manager.h"
|
#include "memory_manager.h"
|
||||||
|
#include "wm.h"
|
||||||
|
|
||||||
static volatile bool ping_reply_received = false;
|
static volatile bool ping_reply_received = false;
|
||||||
static uint16_t ping_id_counter = 0;
|
static uint16_t ping_id_counter = 0;
|
||||||
|
|
@ -71,16 +72,20 @@ void cli_cmd_ping(char *args) {
|
||||||
ping_reply_received = false;
|
ping_reply_received = false;
|
||||||
ip_send_packet(dest, IP_PROTO_ICMP, packet, sizeof(packet));
|
ip_send_packet(dest, IP_PROTO_ICMP, packet, sizeof(packet));
|
||||||
|
|
||||||
// Busy wait for reply. Increased timeout to ensure reply is caught.
|
|
||||||
for(volatile int w=0; w<2000000 && !ping_reply_received; w++) {
|
uint32_t start_ticks = wm_get_ticks();
|
||||||
|
while (!ping_reply_received && (wm_get_ticks() - start_ticks) < 180) { // 3 seconds timeout
|
||||||
network_process_frames();
|
network_process_frames();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ping_reply_received) {
|
if (!ping_reply_received) {
|
||||||
cmd_write("Request timed out.\n");
|
cmd_write("Request timed out. (Did you run 'netinit'?)\n");
|
||||||
} else if (i < 3) {
|
} else if (i < 3) {
|
||||||
// Wait a bit before next ping
|
// Wait a bit before next ping
|
||||||
for(volatile int w=0; w<500000; w++) network_process_frames();
|
uint32_t wait_start = wm_get_ticks();
|
||||||
|
while ((wm_get_ticks() - wait_start) < 60) {
|
||||||
|
network_process_frames();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is_pinging = false;
|
is_pinging = false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue