Skip to content

Commit 002f8e1

Browse files
committed
more debug message for async x requests
ping #1516
1 parent e5bbe67 commit 002f8e1

6 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/event.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,15 @@ void ev_update_focused(struct session *ps) {
302302
ps->atoms->a_NET_ACTIVE_WINDOW, XCB_ATOM_WINDOW, 0, 1)
303303
.sequence;
304304
req->base.callback = update_ewmh_active_win;
305+
req->base.name = "get_property";
305306
req->ps = ps;
306307
x_await_request(&ps->c, &req->base);
307308
log_debug("Started async request to get _NET_ACTIVE_WINDOW");
308309
} else {
309310
auto req = ccalloc(1, struct ev_recheck_focus_request);
310311
req->base.sequence = xcb_get_input_focus(ps->c.c).sequence;
311312
req->base.callback = recheck_focus;
313+
req->base.name = "get_input_focus";
312314
req->ps = ps;
313315
x_await_request(&ps->c, &req->base);
314316
log_debug("Started async request to recheck focus");

src/picom.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,7 @@ static void handle_new_windows(session_t *ps) {
14401440
req->base.callback = handle_new_window_attributes_reply,
14411441
req->base.sequence =
14421442
xcb_get_window_attributes(ps->c.c, req->id.x).sequence;
1443+
req->base.name = "get_window_attributes";
14431444
x_await_request(&ps->c, &req->base);
14441445
break;
14451446
case WM_TREE_CHANGE_TOPLEVEL_KILLED:

src/wm/win.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,6 +2067,7 @@ void win_map_start(struct session *ps, struct win *w) {
20672067
req->base = (struct x_async_request_base){
20682068
.callback = win_handle_get_geometry_reply,
20692069
.sequence = xcb_get_geometry(ps->c.c, win_id(w)).sequence,
2070+
.name = "get_geometry",
20702071
};
20712072
req->wid = win_id(w);
20722073
req->ps = ps;

src/wm/wm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ wm_handle_set_event_mask_reply(struct x_connection *c, struct x_async_request_ba
675675
{
676676
auto req2 = ccalloc(1, struct wm_query_tree_request);
677677
req2->base.callback = wm_handle_query_tree_reply;
678+
req2->base.name = "query_tree";
678679
req2->wid = node->id.x;
679680
req2->wm = wm;
680681
req2->atoms = atoms;
@@ -686,6 +687,7 @@ wm_handle_set_event_mask_reply(struct x_connection *c, struct x_async_request_ba
686687
{
687688
auto req2 = ccalloc(1, struct wm_get_property_request);
688689
req2->base.callback = wm_handle_get_wm_state_reply;
690+
req2->base.name = "get_property (wm)";
689691
req2->wm = wm;
690692
req2->wid = node->id.x;
691693
x_async_get_property(c, node->id.x, atoms->aWM_STATE, XCB_ATOM_ANY, 0, 2,
@@ -713,6 +715,7 @@ static void wm_import_start_inner(struct wm *wm, struct x_connection *c, struct
713715

714716
auto req = ccalloc(1, struct wm_set_event_mask_request);
715717
req->base.callback = wm_handle_set_event_mask_reply;
718+
req->base.name = "change_window_attributes";
716719
req->wid = wid;
717720
req->atoms = atoms;
718721
req->wm = wm;

src/x.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <stdalign.h>
55
#include <stdbool.h>
6+
#include <stdint.h>
67
#include <stdlib.h>
78

89
#include <X11/Xlib-xcb.h>
@@ -197,6 +198,7 @@ void x_set_error_action(struct x_connection *c, uint32_t sequence, enum x_error_
197198
req->base.sequence = sequence;
198199
req->base.callback = x_generic_async_callback;
199200
req->base.no_reply = true;
201+
req->base.name = "error_action";
200202
x_await_request(c, &req->base);
201203
}
202204

@@ -1118,6 +1120,18 @@ static inline void x_ingest_event(struct x_connection *c, xcb_generic_event_t *e
11181120

11191121
static const xcb_raw_generic_event_t no_reply_success = {.response_type = 1};
11201122

1123+
static inline void report_has_reply_assertion_failure(struct x_async_request_base *base,
1124+
uint64_t seq, uint64_t head_seq) {
1125+
log_fatal("Already received reply/error for seq %lu", seq);
1126+
log_fatal("Reply to seq %lu should have come before, but we don't have it", head_seq);
1127+
log_fatal("seq %lu is a \"%s\"", head_seq, base->name);
1128+
if (strcmp(base->name, "error_action") == 0) {
1129+
auto req = (struct x_generic_async_request *)base;
1130+
log_fatal("error_action previous set at %s:%d, %s", req->file, req->line,
1131+
req->func);
1132+
}
1133+
}
1134+
11211135
/// Complete all pending async requests that "come before" the given event.
11221136
static void x_complete_async_requests(struct x_connection *c, xcb_generic_event_t *e) {
11231137
auto seq = x_widen_sequence(c, e->full_sequence);
@@ -1139,6 +1153,9 @@ static void x_complete_async_requests(struct x_connection *c, xcb_generic_event_
11391153
xcb_generic_error_t *err = NULL;
11401154
auto has_reply = xcb_poll_for_reply(
11411155
c->c, i->sequence, (void **)&reply_or_error, &err);
1156+
if (!has_reply) {
1157+
report_has_reply_assertion_failure(i, seq, head_seq);
1158+
}
11421159
BUG_ON(has_reply == 0);
11431160
if (reply_or_error == NULL) {
11441161
reply_or_error = (xcb_raw_generic_event_t *)err;

src/x.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ void x_set_error_action(struct x_connection *c, uint32_t sequence, enum x_error_
219219

220220
struct x_async_request_base {
221221
struct list_node siblings;
222+
const char *name;
222223
/// The callback function to call when the reply is received. If `reply_or_error`
223224
/// is NULL, it means the X connection is closed while waiting for the reply.
224225
void (*callback)(struct x_connection *, struct x_async_request_base *,

0 commit comments

Comments
 (0)