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
11191121static 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.
11221136static 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 ;
0 commit comments