Skip to content

Commit 294b6d1

Browse files
authored
Fix windows ASIO clobbering scheduler index bug introduced in #4646 (#4652)
In #4646, we started using a dedicated scheduler index for the ASIO thread. This was generally a good thing but on windows due to how IOCP works, we could accidentally overwrite the scheduler index for a normal scheduler if it happened to be the one receiving the ASIO callback. This commit fixes the bug to ensure that we will not overwrite the scheduler index during ASIO callbacks on windows.
1 parent 17bc34f commit 294b6d1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libponyrt/asio/event.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ PONY_API void pony_asio_event_send(asio_event_t* ev, uint32_t flags,
134134
#ifdef PLATFORM_IS_WINDOWS
135135
// On Windows, this can be called from an IOCP callback thread, which may
136136
// not have a pony_ctx() associated with it yet.
137-
ponyint_register_asio_thread();
137+
// Don't call `ponyint_register_asio_thread` because that would overwrite the
138+
// scheduler index if this is run on a normal scheduler thread and that would
139+
// be not good.
140+
pony_register_thread();
138141
#endif
139142

140143
asio_msg_t* m = (asio_msg_t*)pony_alloc_msg(POOL_INDEX(sizeof(asio_msg_t)),

0 commit comments

Comments
 (0)