Skip to content

Commit

Permalink
Get rid of __MonoCS__
Browse files Browse the repository at this point in the history
Replaced with existing USE_UNIX_IO and MONO for other places.
Also added a few MONOCKECK comments where we should follow up if it
is still needed or not
  • Loading branch information
gregoryyoung authored and pgermishuys committed Jan 13, 2017
1 parent ba9e7f0 commit 6d13189
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 35 deletions.
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ EOF
}

CONFIGURATION="Release"
DEFINES="USE_UNIX_IO MONO"

function checkParams() {
version=$1
Expand Down Expand Up @@ -199,7 +200,7 @@ function buildEventStore {
patchVersionFiles
patchVersionInfo
rm -rf bin/
xbuild src/EventStore.sln /p:Platform="Any CPU" /p:Configuration="$CONFIGURATION" || err
xbuild src/EventStore.sln /p:Platform="Any CPU" /p:DefineConstants="$DEFINES" /p:Configuration="$CONFIGURATION" || err
revertVersionFiles
revertVersionInfo
}
Expand Down
3 changes: 2 additions & 1 deletion src/EventStore.ClientAPI/Transport.Http/HttpAsyncClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ private void Receive(string method, string url, UserCredentials userCredentials,
Action<HttpResponse> onSuccess, Action<Exception> onException, string hostHeader = "")
{
var request = new HttpRequestMessage();
#if __MonoCS__
//MONOCHECK IS THIS STILL NEEDED?
#if MONO
request.Headers.Add("Keep-alive", "false");
#endif
request.RequestUri = new Uri(url);
Expand Down
7 changes: 4 additions & 3 deletions src/EventStore.Core.Tests/Http/HttpBehaviorSpecification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public abstract class HttpBehaviorSpecification : SpecificationWithDirectoryPerT
protected string _lastResponseBody;
protected byte[] _lastResponseBytes;
protected JsonException _lastJsonException;
#if !__MonoCS__
//MONOCHECK Does this work now?
#if !MONO
private Func<HttpWebResponse, byte[]> _dumpResponse;
private Func<HttpWebResponse, int> _dumpResponse2;
private Func<HttpWebRequest, byte[]> _dumpRequest;
Expand All @@ -41,7 +42,7 @@ public abstract class HttpBehaviorSpecification : SpecificationWithDirectoryPerT

public override void TestFixtureSetUp()
{
#if !__MonoCS__
#if !MONO
Helper.EatException(() => _dumpResponse = CreateDumpResponse());
Helper.EatException(() => _dumpResponse2 = CreateDumpResponse2());
Helper.EatException(() => _dumpRequest = CreateDumpRequest());
Expand Down Expand Up @@ -368,7 +369,7 @@ protected HttpWebResponse GetRequestResponse(HttpWebRequest request)
{
response = (HttpWebResponse) ex.Response;
}
#if !__MonoCS__
#if !MONO
if (_dumpRequest != null)
{
var bytes = _dumpRequest(request);
Expand Down
4 changes: 0 additions & 4 deletions src/EventStore.Core.Tests/Http/Streams/basic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,7 @@ public void returns_a_location_header_that_is_to_stream_without_slash()
}
}

#if __MonoCS__
[TestFixture, Category("LongRunning"), Ignore("https://bugzilla.xamarin.com/show_bug.cgi?id=16960")]
#else
[TestFixture, Category("LongRunning")]
#endif
public class when_getting_from_encoded_all_stream_with_slash : HttpBehaviorSpecification
{
private HttpWebResponse _response;
Expand Down
5 changes: 3 additions & 2 deletions src/EventStore.Core/Bus/QueuedHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ namespace EventStore.Core.Bus
{
// on Windows AutoReset version is much slower, but on Linux ManualResetEventSlim version is much slower
public class QueuedHandler :
#if __MonoCS__
//MONOCHECK is this still worthwhile or should we use MPMC?
#if MONO
QueuedHandlerAutoReset,
#else
QueuedHandlerMRES,
Expand Down Expand Up @@ -41,7 +42,7 @@ public static IQueuedHandler CreateQueuedHandler(IHandle<Message> consumer, stri
}

class QueueHandlerUsingMpsc :
#if __MonoCS__
#if MONO
QueuedHandlerAutoResetWithMpsc,
#else
QueuedHandlerMresWithMpsc,
Expand Down
4 changes: 2 additions & 2 deletions src/EventStore.Core/Index/PTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ internal Midpoint[] CacheMidpointsAndVerifyHash(int depth)
var count = Count;
if (count == 0 || depth == 0)
return null;
#if __MonoCS__
#if MONO
var workItem = GetWorkItem();
var stream = workItem.Stream;
try {
Expand Down Expand Up @@ -232,7 +232,7 @@ internal Midpoint[] CacheMidpointsAndVerifyHash(int depth)
throw;
}
}
#if __MonoCS__
#if MONO
finally
{
ReturnWorkItem(workItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private PerformanceCounter CreatePerfCounterForProcess(string category, string c
string processName = null;
try
{
#if __MonoCS__
#if MONO
processName = Process.GetCurrentProcess().Id.ToString();
#else
processName = Process.GetCurrentProcess().ProcessName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public void VerifyFileHash()
throw new InvalidOperationException("You can't verify hash of not-completed TFChunk.");

Log.Trace("Verifying hash for TFChunk '{0}'...", _filename);
#if __MonoCS__
#if MONO
using (var reader = AcquireReader())
{
reader.Stream.Seek(0, SeekOrigin.Begin);
Expand Down
28 changes: 14 additions & 14 deletions src/EventStore.Core/TransactionLog/Unbuffered/NativeFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.Win32.SafeHandles;
using System.Runtime.InteropServices;

#if __MonoCS__ || USE_UNIX_IO
#if USE_UNIX_IO
using Mono.Unix.Native;
using Mono.Unix;
#endif
Expand All @@ -27,7 +27,7 @@ internal unsafe static class NativeFile

public static uint GetDriveSectorSize(string path)
{
#if !__MonoCS__ && !USE_UNIX_IO
#if !USE_UNIX_IO
uint size;
uint dontcare;
WinNative.GetDiskFreeSpace(Path.GetPathRoot(path), out dontcare, out size, out dontcare, out dontcare);
Expand All @@ -39,7 +39,7 @@ public static uint GetDriveSectorSize(string path)

public static long GetPageSize(string path)
{
#if !__MonoCS__ && !USE_UNIX_IO
#if !USE_UNIX_IO
return GetDriveSectorSize(path);
#else
int r =0;
Expand All @@ -53,7 +53,7 @@ public static long GetPageSize(string path)

public static void SetFileSize(SafeFileHandle handle, long count)
{
#if !__MonoCS__ && !USE_UNIX_IO
#if !USE_UNIX_IO
var low = (int)(count & 0xffffffff);
var high = (int)(count >> 32);
WinNative.SetFilePointer(handle, low, out high, WinNative.EMoveMethod.Begin);
Expand All @@ -73,7 +73,7 @@ public static void SetFileSize(SafeFileHandle handle, long count)

private static void FSync(SafeFileHandle handle)
{
#if !__MonoCS__ && !USE_UNIX_IO
#if !USE_UNIX_IO
WinNative.FlushFileBuffers(handle);
#else
Syscall.fsync(handle.DangerousGetHandle().ToInt32());
Expand All @@ -82,7 +82,7 @@ private static void FSync(SafeFileHandle handle)

public static void Write(SafeFileHandle handle, byte* buffer, uint count, ref int written)
{
#if !__MonoCS__ && !USE_UNIX_IO
#if !USE_UNIX_IO
if (!WinNative.WriteFile(handle, buffer, count, ref written, IntPtr.Zero))
{
throw new Win32Exception();
Expand All @@ -100,7 +100,7 @@ public static void Write(SafeFileHandle handle, byte* buffer, uint count, ref in

public static int Read(SafeFileHandle handle, byte* buffer, int offset, int count)
{
#if !__MonoCS__ && !USE_UNIX_IO
#if !USE_UNIX_IO
var read = 0;

if (!WinNative.ReadFile(handle, buffer, count, ref read, 0))
Expand All @@ -121,7 +121,7 @@ public static int Read(SafeFileHandle handle, byte* buffer, int offset, int coun

public static long GetFileSize(SafeFileHandle handle)
{
#if !__MonoCS__ && !USE_UNIX_IO
#if !USE_UNIX_IO
long size = 0;
if (!WinNative.GetFileSizeEx(handle, out size))
{
Expand All @@ -142,7 +142,7 @@ public static long GetFileSize(SafeFileHandle handle)
//TODO UNBUFF use FileAccess etc or do custom?
public static SafeFileHandle Create(string path, FileAccess acc, FileShare readWrite, FileMode mode, int flags)
{
#if !__MonoCS__ && !USE_UNIX_IO
#if !USE_UNIX_IO
var handle = WinNative.CreateFile(path,
acc,
FileShare.ReadWrite,
Expand All @@ -164,7 +164,7 @@ public static SafeFileHandle Create(string path, FileAccess acc, FileShare readW

public static SafeFileHandle CreateUnbufferedRW(string path, FileAccess acc, FileShare share, FileMode mode, bool writeThrough)
{
#if !__MonoCS__ && !USE_UNIX_IO
#if !USE_UNIX_IO
var flags = ExtendedFileOptions.NoBuffering;
if (writeThrough) flags = flags | ExtendedFileOptions.WriteThrough;
var handle = WinNative.CreateFile(path,
Expand Down Expand Up @@ -195,7 +195,7 @@ public static SafeFileHandle CreateUnbufferedRW(string path, FileAccess acc, Fil
#endif
}

#if __MonoCS__ || USE_UNIX_IO
#if USE_UNIX_IO
private static OpenFlags GetFlags(FileAccess acc, FileMode mode)
{
OpenFlags flags = OpenFlags.O_RDONLY; //RDONLY is 0
Expand All @@ -211,7 +211,7 @@ private static OpenFlags GetFlags(FileAccess acc, FileMode mode)
return flags;
}
#endif
#if __MonoCS__ || USE_UNIX_IO
#if USE_UNIX_IO
[DllImport("libc")]
static extern int fcntl(int fd, uint command, int arg);
#endif
Expand All @@ -220,7 +220,7 @@ public static void TurnOffMacCaching(SafeFileHandle handle)
{

if (OS.OsFlavor != OsFlavor.MacOS) return;
#if __MonoCS__ || USE_UNIX_IO
#if USE_UNIX_IO
long r = 0;
do {
r = fcntl (handle.DangerousGetHandle().ToInt32(), MAC_F_NOCACHE, 1);
Expand All @@ -233,7 +233,7 @@ public static void TurnOffMacCaching(SafeFileHandle handle)

public static void Seek(SafeFileHandle handle, long position, SeekOrigin origin)
{
#if !__MonoCS__ && !USE_UNIX_IO
#if !USE_UNIX_IO
var low = (int)(position & 0xffffffff);
var high = (int)(position >> 32);
var f = WinNative.SetFilePointer(handle, low, out high, WinNative.EMoveMethod.Begin);
Expand Down
2 changes: 1 addition & 1 deletion src/EventStore.Core/TransactionLog/Unbuffered/WinNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace EventStore.Core.TransactionLog.Unbuffered
{
#if ! __MonoCS__ && !USE_UNIX_IO
#if !USE_UNIX_IO
internal unsafe static class WinNative
{
[DllImport("KERNEL32", SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
Expand Down
3 changes: 2 additions & 1 deletion src/EventStore.Transport.Http/Client/HttpAsyncClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ private void Receive(string method, string url, IEnumerable<KeyValuePair<string,
Action<HttpResponse> onSuccess, Action<Exception> onException)
{
var request = new HttpRequestMessage();
#if __MonoCS__
//MONOCHECK is this still needed?
#if MONO
request.Headers.Add("Keep-alive", "false");
#endif
request.Method = new System.Net.Http.HttpMethod(method);
Expand Down
4 changes: 2 additions & 2 deletions src/EventStore.Transport.Http/Server/HttpAsyncServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ private void OnRequestReceived(HttpListenerContext context)
if (handler != null)
handler(this, context);
}

#if __MonoCS__
//MONOCHECK is this still needed?
#if MONO
private static Func<HttpListenerRequest, HttpListenerContext> CreateGetContext()
{
var r = System.Linq.Expressions.Expression.Parameter(typeof (HttpListenerRequest), "r");
Expand Down
4 changes: 2 additions & 2 deletions src/esquery/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ private static bool TryValidatePassword(Uri baseuri, NetworkCredential cred)
}
}


#if __MonoCS__
//MONOCHECK
#if MONO
//mono apparently doesnt work with secure strings.
//TODO delete me when its no longer broken
private static string ReadPassword()
Expand Down

0 comments on commit 6d13189

Please sign in to comment.