From 2ebb6073b7eb052984008110e3df4469d2d9c596 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Sat, 21 Apr 2018 14:39:46 +1200 Subject: Remove status command event on error This prevents very high CPU load when the status command dies, and poll continuously awoken with POLLHUP. --- swaybar/bar.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'swaybar/bar.c') diff --git a/swaybar/bar.c b/swaybar/bar.c index d51c4ec7..10a840cc 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -418,7 +418,11 @@ static void ipc_in(int fd, short mask, void *_bar) { static void status_in(int fd, short mask, void *_bar) { struct swaybar *bar = (struct swaybar *)_bar; - if (status_handle_readable(bar->status)) { + if (mask & (POLLHUP | POLLERR)) { + status_error(bar->status, "[error reading from status command]"); + render_all_frames(bar); + remove_event(fd); + } else if (status_handle_readable(bar->status)) { render_all_frames(bar); } } -- cgit v1.2.3-70-g09d2 From c63554885e4aae4e1c8f97ffbd53160f3eb99510 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Sat, 21 Apr 2018 14:45:34 +1200 Subject: Remove void * casts They're pointless. --- swaybar/bar.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'swaybar/bar.c') diff --git a/swaybar/bar.c b/swaybar/bar.c index 10a840cc..669cb11a 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -401,23 +401,23 @@ void bar_setup(struct swaybar *bar, render_all_frames(bar); } -static void display_in(int fd, short mask, void *_bar) { - struct swaybar *bar = (struct swaybar *)_bar; +static void display_in(int fd, short mask, void *data) { + struct swaybar *bar = data; if (wl_display_dispatch(bar->display) == -1) { bar_teardown(bar); exit(0); } } -static void ipc_in(int fd, short mask, void *_bar) { - struct swaybar *bar = (struct swaybar *)_bar; +static void ipc_in(int fd, short mask, void *data) { + struct swaybar *bar = data; if (handle_ipc_readable(bar)) { render_all_frames(bar); } } -static void status_in(int fd, short mask, void *_bar) { - struct swaybar *bar = (struct swaybar *)_bar; +static void status_in(int fd, short mask, void *data) { + struct swaybar *bar = data; if (mask & (POLLHUP | POLLERR)) { status_error(bar->status, "[error reading from status command]"); render_all_frames(bar); -- cgit v1.2.3-70-g09d2