Skip to content

Commit

Permalink
Fix aeron directory resolution on OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
JPWatson committed Jan 21, 2019
1 parent 7153e58 commit f235244
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
25 changes: 23 additions & 2 deletions src/Adaptive.Aeron/Aeron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,28 @@ public class Context : IDisposable
private UnsafeBuffer _countersValuesBuffer;
private IThreadFactory _threadFactory = new DefaultThreadFactory();


static Context()
{
string baseDirName = null;

if (Environment.OSVersion.Platform == PlatformID.Unix)
{
if (Directory.Exists(@"/dev/shm"))
{
baseDirName = "/dev/shm/aeron";
}
}

if (null == baseDirName)
{
baseDirName = Path.Combine(Path.GetTempPath(), "aeron");
}

AERON_DIR_PROP_DEFAULT = baseDirName + '-' + Environment.UserName;

}

/// <summary>
/// The top level Aeron directory used for communication between a Media Driver and client.
/// </summary>
Expand All @@ -419,8 +441,7 @@ public class Context : IDisposable
/// <summary>
/// The value of the top level Aeron directory unless overridden by <seealso cref="AeronDirectoryName()"/>
/// </summary>
public static readonly string AERON_DIR_PROP_DEFAULT =
Path.Combine(IoUtil.TmpDirName(), "aeron-" + Environment.UserName);
public static readonly string AERON_DIR_PROP_DEFAULT;

/// <summary>
/// Media type used for IPC shared memory from <seealso cref="Publication"/> to <seealso cref="Subscription"/> channels.
Expand Down
14 changes: 0 additions & 14 deletions src/Adaptive.Agrona/IoUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,6 @@ public static void CheckFileExists(string path)
}
}

/// <summary>
/// Return the system property for java.io.tmpdir ensuring a '/' is at the end.
/// </summary>
/// <returns> tmp directory for the runtime </returns>
public static string TmpDirName()
{
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
return @"/dev/shm";
}

return Path.GetTempPath();
}

public static void Delete(DirectoryInfo directory, bool b)
{
if (directory.Exists)
Expand Down

0 comments on commit f235244

Please sign in to comment.