summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--plugins/discord/init.lua11
-rw-r--r--src/osd/modules/file/winptty.cpp3
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;
}