From 464a8be3a4faf78e63133052191f3acb90d160fa Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Thu, 2 Feb 2023 00:19:55 +0900 Subject: [PATCH] pluginloader-win32: Check pipe state in child process Retry if server is not ready for the connection Part-of: --- .../gstreamer/gst/gstpluginloader-win32.c | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/subprojects/gstreamer/gst/gstpluginloader-win32.c b/subprojects/gstreamer/gst/gstpluginloader-win32.c index dc0f1c1bdc..ffab8386c1 100644 --- a/subprojects/gstreamer/gst/gstpluginloader-win32.c +++ b/subprojects/gstreamer/gst/gstpluginloader-win32.c @@ -1153,10 +1153,24 @@ _gst_plugin_loader_client_run (const gchar * pipe_name) FILE_FLAG_OVERLAPPED, NULL); loader.last_err = GetLastError (); if (loader.pipe == INVALID_HANDLE_VALUE) { - err = g_win32_error_message (loader.last_err); - GST_ERROR ("CreateFileA failed with 0x%x (%s)", - loader.last_err, GST_STR_NULL (err)); - goto out; + /* Server should be pending (waiting for connection) state already, + * but do retry if it's not the case */ + if (loader.last_err == ERROR_PIPE_BUSY) { + if (WaitNamedPipeA (pipe_name, 5000)) { + loader.pipe = CreateFileA (pipe_name, + GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, + FILE_FLAG_OVERLAPPED, NULL); + } + + loader.last_err = GetLastError (); + } + + if (loader.pipe == INVALID_HANDLE_VALUE) { + err = g_win32_error_message (loader.last_err); + GST_ERROR ("CreateFileA failed with 0x%x (%s)", + loader.last_err, GST_STR_NULL (err)); + goto out; + } } /* We use message mode */