status

statusbar program for dwm
git clone anongit@rnpnr.xyz:status.git
Log | Files | Refs | Feed | README | LICENSE

Commit: c06f0185fdc03158efa5d9f0e3f1d08e8039c5eb
Parent: 7f4479fec7e5f1f4ca1c86d50b13a7ca92b855b9
Author: Randy Palamar
Date:   Wed, 25 Dec 2024 10:00:01 -0700

ensure no blocks are missed when updating dirty block index

Diffstat:
Mbuild.sh | 1+
Mstatus.c | 13+++++++++----
2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/build.sh b/build.sh @@ -4,6 +4,7 @@ cflags="-march=native -O3 -std=c11 -Wall -pedantic" cflags="$cflags -D_XOPEN_SOURCE=700" cflags="$cflags -I /usr/X11R6/include" #cflags="${cflags} -O0 -ggdb -D_DEBUG" +#cflags="${cflags} -fsanitize=address,undefined" ldflags="-lX11" #ldflags="$ldflags -lmpdclient" # needed for blocks/mpd.c diff --git a/status.c b/status.c @@ -269,6 +269,13 @@ terminate(int signo) } static void +update_dirty_block_index(i32 new_index) +{ + if (dirty_block_index == -1 || new_index < dirty_block_index) + dirty_block_index = new_index; +} + +static void dispatch_file_watch_events(Arena a) { u8 *mem = alloc_(&a, 4096, 64, 1); @@ -288,9 +295,7 @@ dispatch_file_watch_events(Arena a) file_changed |= (ie->mask & IN_MODIFY) != 0; /* TODO(rnp): it seems like this hits multiple times per update */ if (file_changed && fw->update_fn(blocks + fw->block_index, 0)) { - /* TODO(rnp): there might be an ordering issue here */ - if (dirty_block_index == -1 || fw->block_index < dirty_block_index) - dirty_block_index = fw->block_index; + update_dirty_block_index(fw->block_index); } } } @@ -324,7 +329,7 @@ static void update_blocks(f32 dt) { i32 count = 0; - #define X(name, fmt, args) if (name ##_update(blocks + count++, dt)) dirty_block_index = count - 1; + #define X(name, fmt, args) if (name ##_update(blocks + count++, dt)) update_dirty_block_index(count - 1); BLOCKS #undef X }