Skip to content

Commit ac04f5e

Browse files
committed
Run Fuzzlyn.ExecutionServer.dll from another directory
Avoids mismatching native dependencies with the host when Fuzzlyn itself was published as self-contained.
1 parent fd65746 commit ac04f5e

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

Fuzzlyn/ExecutionServerPool.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Fuzzlyn;
77

8-
internal class ExecutionServerPool(string host, SpmiSetupOptions spmiOptions, LogExecutionServerRequestsOptions logRequestsOptions)
8+
internal class ExecutionServerPool(string host, string executorPath, SpmiSetupOptions spmiOptions, LogExecutionServerRequestsOptions logRequestsOptions)
99
{
1010
// Stop a server once it has not been used for this duration
1111
private static readonly TimeSpan s_inactivityPeriod = TimeSpan.FromMinutes(3);
@@ -44,7 +44,7 @@ private RunningExecutionServer Get(bool keepNonEmptyEagerly)
4444

4545
if (startNew)
4646
{
47-
RunningExecutionServer created = RunningExecutionServer.Create(_serverIndex++, Host, SpmiOptions, LogExceutionServerRequestsOptions);
47+
RunningExecutionServer created = RunningExecutionServer.Create(_serverIndex++, Host, executorPath, SpmiOptions, LogExceutionServerRequestsOptions);
4848
lock (_pool)
4949
{
5050
_pool.Add(created);
@@ -54,7 +54,7 @@ private RunningExecutionServer Get(bool keepNonEmptyEagerly)
5454
if (bestServer != null)
5555
return bestServer;
5656

57-
return RunningExecutionServer.Create(_serverIndex++, Host, SpmiOptions, LogExceutionServerRequestsOptions);
57+
return RunningExecutionServer.Create(_serverIndex++, Host, executorPath, SpmiOptions, LogExceutionServerRequestsOptions);
5858
}
5959

6060
private void Return(RunningExecutionServer server)

Fuzzlyn/Program.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,14 @@ private static bool CreateExecutionServerPool(FuzzlynOptions options)
261261
}
262262
}
263263

264-
s_executionServerPool = new ExecutionServerPool(options.Host, spmiOptions, logExecServerRequestsOptions);
264+
string fuzzlynDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
265+
string executionServerPath = Path.Combine(fuzzlynDir, "Fuzzlyn.ExecutionServer.dll");
266+
string newExecutionServerDir = Path.Combine(fuzzlynDir, "ExecutionServer");
267+
string newExecutionServerPath = Path.Combine(newExecutionServerDir, "Fuzzlyn.ExecutionServer.dll");
268+
Directory.CreateDirectory(newExecutionServerDir);
269+
File.Copy(executionServerPath, newExecutionServerPath, true);
270+
271+
s_executionServerPool = new ExecutionServerPool(options.Host, newExecutionServerPath, spmiOptions, logExecServerRequestsOptions);
265272
return true;
266273
}
267274

Fuzzlyn/RunningExecutionServer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,12 @@ public void Kill()
166166
}
167167
}
168168

169-
public static RunningExecutionServer Create(int serverIndex, string host, SpmiSetupOptions spmiOptions, LogExecutionServerRequestsOptions logExecServerRequestsOptions)
169+
public static RunningExecutionServer Create(int serverIndex, string host, string executorPath, SpmiSetupOptions spmiOptions, LogExecutionServerRequestsOptions logExecServerRequestsOptions)
170170
{
171-
string executorPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Fuzzlyn.ExecutionServer.dll");
172171
ProcessStartInfo info = new()
173172
{
174173
FileName = host,
175-
WorkingDirectory = Environment.CurrentDirectory,
174+
WorkingDirectory = Path.GetDirectoryName(executorPath),
176175
RedirectStandardOutput = true,
177176
RedirectStandardError = true,
178177
RedirectStandardInput = true,

0 commit comments

Comments
 (0)