Skip to content

Commit 91ac3b9

Browse files
committed
XenAdmin: Program: Fix possibly unhandled exception on calling ExistsPipe
The function ExistsPipe could throw an exception on catching the NotFound related error. Add safe try-catch block that skip the error since if the pipe doesn't exist the code does nothing too. Signed-off-by: Ilya Stolyarov <[email protected]>
1 parent 0676739 commit 91ac3b9

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

XenAdmin/Program.cs

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) Cloud Software Group, Inc.
1+
/* Copyright (c) Cloud Software Group, Inc.
22
*
33
* Redistribution and use in source and binary forms,
44
* with or without modification, are permitted provided
@@ -153,10 +153,16 @@ public static void Main(string[] args)
153153
Environment.UserName,
154154
Assembly.GetExecutingAssembly().Location.Replace('\\', '-'));
155155

156-
if (NamedPipes.Pipe.ExistsPipe(_pipePath))
157-
{
158-
NamedPipes.Pipe.SendMessageToPipe(_pipePath, string.Join(" ", args));
159-
return;
156+
try {
157+
if (NamedPipes.Pipe.ExistsPipe(_pipePath))
158+
{
159+
NamedPipes.Pipe.SendMessageToPipe(_pipePath, string.Join(" ", args));
160+
return;
161+
}
162+
}
163+
catch (System.IO.IOException) {
164+
// For example, Mono throws the exception on calling ExistsPipe
165+
// Since if the pipe doesn't exist the code does nothing too.
160166
}
161167

162168
log.Info("Application started");

0 commit comments

Comments
 (0)