aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Modules/overlapped.c
diff options
context:
space:
mode:
authorAlexSm <alex@ydb.tech>2024-05-06 18:27:11 +0200
committerGitHub <noreply@github.com>2024-05-06 18:27:11 +0200
commit068e8291de67631f063304b76dda3c1fd6601c12 (patch)
treef9058c69ef88f04c55ff9c92949dffa8cd6b83a5 /contrib/tools/python3/Modules/overlapped.c
parent653a427438ab0fa69068180c34233b015af0d405 (diff)
parent41f0129e44731de1ba129fbae27008f8a4048fdc (diff)
downloadydb-068e8291de67631f063304b76dda3c1fd6601c12.tar.gz
Merge pull request #4325 from ydb-platform/mergelibs-240506-1255
Library import 240506-1255
Diffstat (limited to 'contrib/tools/python3/Modules/overlapped.c')
-rw-r--r--contrib/tools/python3/Modules/overlapped.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/contrib/tools/python3/Modules/overlapped.c b/contrib/tools/python3/Modules/overlapped.c
index afdd78d1bc..686ecf8b33 100644
--- a/contrib/tools/python3/Modules/overlapped.c
+++ b/contrib/tools/python3/Modules/overlapped.c
@@ -719,6 +719,24 @@ Overlapped_dealloc(OverlappedObject *self)
if (!HasOverlappedIoCompleted(&self->overlapped) &&
self->type != TYPE_NOT_STARTED)
{
+ // NOTE: We should not get here, if we do then something is wrong in
+ // the IocpProactor or ProactorEventLoop. Since everything uses IOCP if
+ // the overlapped IO hasn't completed yet then we should not be
+ // deallocating!
+ //
+ // The problem is likely that this OverlappedObject was removed from
+ // the IocpProactor._cache before it was complete. The _cache holds a
+ // reference while IO is pending so that it does not get deallocated
+ // while the kernel has retained the OVERLAPPED structure.
+ //
+ // CancelIoEx (likely called from self.cancel()) may have successfully
+ // completed, but the OVERLAPPED is still in use until either
+ // HasOverlappedIoCompleted() is true or GetQueuedCompletionStatus has
+ // returned this OVERLAPPED object.
+ //
+ // NOTE: Waiting when IOCP is in use can hang indefinitely, but this
+ // CancelIoEx is superfluous in that self.cancel() was already called,
+ // so I've only ever seen this return FALSE with GLE=ERROR_NOT_FOUND
Py_BEGIN_ALLOW_THREADS
if (CancelIoEx(self->handle, &self->overlapped))
wait = TRUE;
@@ -2039,6 +2057,7 @@ overlapped_exec(PyObject *module)
WINAPI_CONSTANT(F_DWORD, ERROR_OPERATION_ABORTED);
WINAPI_CONSTANT(F_DWORD, ERROR_SEM_TIMEOUT);
WINAPI_CONSTANT(F_DWORD, ERROR_PIPE_BUSY);
+ WINAPI_CONSTANT(F_DWORD, ERROR_PORT_UNREACHABLE);
WINAPI_CONSTANT(F_DWORD, INFINITE);
WINAPI_CONSTANT(F_HANDLE, INVALID_HANDLE_VALUE);
WINAPI_CONSTANT(F_HANDLE, NULL);