This commit introduced a test failure in gdb.server/attach-flag.exp.
I didn't spot this failure originally as the problem is fixed by this,
as yet unpushed patch:
  https://sourceware.org/pipermail/gdb-patches/2021-November/183768.html
I unfortunately didn't test each patch in the original series
independently.  I'll repost this patch after the above patch has been
merged.
This reverts commit 
32b1f5e8d6b8ddd3be6e471c26dd85a1dac31dda.
 
   remote_state *rs = get_remote_state ();
 
   /* Start by clearing the flag that asks for our wait method to be called,
-     we'll mark it again at the end if needed.  If the target is not in
-     async mode then the async token should not be marked.  */
+     we'll mark it again at the end if needed.  */
   if (target_is_async_p ())
     clear_async_event_handler (rs->remote_async_inferior_event_token);
-  else
-    gdb_assert (!async_event_handler_marked
-               (rs->remote_async_inferior_event_token));
 
   ptid_t event_ptid;