diff options
author | 2019-11-16 14:57:35 -0600 | |
---|---|---|
committer | 2019-11-16 14:59:02 -0600 | |
commit | b0ef759b80013332d8d19e954dd6330d76593602 (patch) | |
tree | 7ec1c0935d2eb0d9ad1779bcf1ae962eef7dcca0 | |
parent | dd86e8408c7ea56ff0999b6a880348f9891f2632 (diff) |
winptty: don't create pipe unless requested (nw)
plugins/discord: disconnect if timed out (nw)
-rw-r--r-- | plugins/discord/init.lua | 11 | ||||
-rw-r--r-- | src/osd/modules/file/winptty.cpp | 3 |
2 files changed, 12 insertions, 2 deletions
diff --git a/plugins/discord/init.lua b/plugins/discord/init.lua index 21ec88ec79a..5e5ce88a514 100644 --- a/plugins/discord/init.lua +++ b/plugins/discord/init.lua @@ -40,9 +40,13 @@ function discord.startplugin() if data:find("code", 1, true) then error("discord: bad RPC reply, " .. data:sub(8) .. "\n") end + if #data == 0 then + error("discord: timed out waiting for response\n"); + end end local function update(status) + if not pipe then return end local running = emu.romname() ~= "___empty" local state = not running and "In menu" or status local details = running and manager:machine():system().description or nil @@ -78,13 +82,18 @@ function discord.startplugin() local res = pipe:read(100) data = data .. res until #res == 0 and #data > 0 or time + 1 < os.time() + if #data == 0 then + emu.print_verbose("discord: timed out waiting for response, closing connection\n"); + pipe = nil + end --print(data) end do local stat, err = pcall(init) if not stat then - emu.print_error(err) + emu.print_verbose(err) + pipe = nil return end end diff --git a/src/osd/modules/file/winptty.cpp b/src/osd/modules/file/winptty.cpp index 943f1fbaa52..61867a869df 100644 --- a/src/osd/modules/file/winptty.cpp +++ b/src/osd/modules/file/winptty.cpp @@ -92,7 +92,8 @@ osd_file::error win_open_ptty(std::string const &path, std::uint32_t openflags, if (INVALID_HANDLE_VALUE == pipe) { - pipe = CreateNamedPipe(t_name.c_str(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, 32, 32, 0, nullptr); + if (openflags & OPEN_FLAG_CREATE) + pipe = CreateNamedPipe(t_name.c_str(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, 32, 32, 0, nullptr); if (INVALID_HANDLE_VALUE == pipe) return osd_file::error::ACCESS_DENIED; } |