From d95938179b4f605d9315cecec8b80b52f23fb11d Mon Sep 17 00:00:00 2001 From: Hongli Chen <94642294+Honglichenn@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:16:50 -0700 Subject: [PATCH] fix: specify max named pipe instances (#86) Signed-off-by: Hongli Chen --- src/openjd/adaptor_runtime/_background/server_config.py | 3 +++ .../adaptor_runtime/_named_pipe/named_pipe_helper.py | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/openjd/adaptor_runtime/_background/server_config.py b/src/openjd/adaptor_runtime/_background/server_config.py index beea6d4..c12fe2e 100644 --- a/src/openjd/adaptor_runtime/_background/server_config.py +++ b/src/openjd/adaptor_runtime/_background/server_config.py @@ -3,3 +3,6 @@ # Windows Named Pipe Server Configuration NAMED_PIPE_BUFFER_SIZE = 8192 DEFAULT_NAMED_PIPE_TIMEOUT_MILLISECONDS = 5000 +# This number must be >= 2, one instance is for normal operation communication +# and the other one is for immediate shutdown communication +DEFAULT_MAX_NAMED_PIPE_INSTANCES = 2 diff --git a/src/openjd/adaptor_runtime/_named_pipe/named_pipe_helper.py b/src/openjd/adaptor_runtime/_named_pipe/named_pipe_helper.py index 1b908a1..41bbfc1 100644 --- a/src/openjd/adaptor_runtime/_named_pipe/named_pipe_helper.py +++ b/src/openjd/adaptor_runtime/_named_pipe/named_pipe_helper.py @@ -19,7 +19,10 @@ import os -from openjd.adaptor_runtime._background.server_config import NAMED_PIPE_BUFFER_SIZE +from openjd.adaptor_runtime._background.server_config import ( + NAMED_PIPE_BUFFER_SIZE, + DEFAULT_MAX_NAMED_PIPE_INSTANCES, +) _logger = logging.getLogger(__name__) @@ -181,7 +184,7 @@ def create_named_pipe_server(pipe_name: str, time_out_in_seconds: float) -> Opti # A bi-directional pipe; both server and client processes can read from and write to the pipe. win32pipe.PIPE_ACCESS_DUPLEX, win32pipe.PIPE_TYPE_MESSAGE | win32pipe.PIPE_READMODE_MESSAGE | win32pipe.PIPE_WAIT, - win32pipe.PIPE_UNLIMITED_INSTANCES, + DEFAULT_MAX_NAMED_PIPE_INSTANCES, NAMED_PIPE_BUFFER_SIZE, # nOutBufferSize NAMED_PIPE_BUFFER_SIZE, # nInBufferSize time_out_in_seconds,