Re: [Mono-dev] Problems with FileStream.Lock();
On Jan 8, 2013, at 3:52 PM, Terry Watts wrote: > I have looked at the exception under the debugger, that's why "E" is in the > catch{ Exception E}. The exception thrown is a "lock violation"; not a "Not > Supported" exception. The exception thrown is "lock violation" because that's what it was mapped to -- io-layer's LockFile() was translating ~every fcntl(2) error into ERROR_LOCK_VIOLATION, even if the actual error was that the parameters were invalid (as was the case here). This is fixed in: https://github.com/mono/mono/commit/6c5d76dd4c953fc26a82e3cce44baa6a06aeaa21 Note that Mono for Android doesn't currently have this patch. - Jon ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Problems with FileStream.Lock();
I have looked at the exception under the debugger, that's why "E" is in the catch{ Exception E}. The exception thrown is a "lock violation"; not a "Not Supported" exception. Regards Terry On Jan 9, 2013 7:10 AM, "Marcel Hellwig" wrote: > Hi, > > I think your worst mistake you do is on this line > > Am 07.01.2013 22:50, schrieb Terry-Watts.com: > > ** try { base.Lock( 0, Int64.MaxValue ); break; } catch( Exception E ) { > Thread.Sleep( SleepCount++ ); } }** > > You catch *all* exceptions. This is horrible. You should definitely > specify your exception you except (haha). You also should look what kind of > exception was thrown, maybe a NotSupported (on this platform) exception > would be fine, else file a bug, that it should be done, cause it's not > supported by android (regarding to Rafael Teixeira) > > Regards, > Marcel > > ___ > Mono-devel-list mailing list > Mono-devel-list@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/mono-devel-list > > ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Problems with FileStream.Lock();
Thanks very much for looking into it. I had realised that the SD card file system was limited, but I didn't realise that the internal Android file system was also limit "small file support". The change works like a treat. Thanks very very much. Terry On 9/01/2013 4:23 PM, Jonathan Pryor wrote: On Jan 7, 2013, at 4:50 PM, Terry-Watts.com wrote: I have a class that work fine in C# under Windows but not under Monodroid. This is a mono bug: https://bugzilla.xamarin.com/show_bug.cgi?id=9411 Thinking about it a but more, though, it's an app bug (+ mono bug). The problem is that Android doesn't have "large file support" (meaning userspace is limited to 32-bit values for file offsets/etc.). Your code, meanwhile, is specifying a 64-bit value for the file range. fcntl(2) cannot accept a 64-bit value for the size of the file region to lock; it needs to be a signed 32-bit value. Fix: use `int.MaxValue`, not `long.MaxValue`. Mono should probably throw an exception in this scenario. - Jon ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Problems with FileStream.Lock();
On Jan 7, 2013, at 4:50 PM, Terry-Watts.com wrote: > I have a class that work fine in C# under Windows but not under Monodroid. This is a mono bug: https://bugzilla.xamarin.com/show_bug.cgi?id=9411 Thinking about it a but more, though, it's an app bug (+ mono bug). The problem is that Android doesn't have "large file support" (meaning userspace is limited to 32-bit values for file offsets/etc.). Your code, meanwhile, is specifying a 64-bit value for the file range. fcntl(2) cannot accept a 64-bit value for the size of the file region to lock; it needs to be a signed 32-bit value. Fix: use `int.MaxValue`, not `long.MaxValue`. Mono should probably throw an exception in this scenario. - Jon ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Problems with FileStream.Lock();
On Jan 8, 2013, at 4:44 PM, Terry-Watts.com wrote: > I have check the Android API docs and file locking has been available on > channels since API Level 1. "on channels"? Anyway, quick perusal of the source shows that FileStream.Lock() is fcntl(2): https://github.com/mono/mono/blob/master/mcs/class/corlib/System.IO/FileStream.cs#L875 https://github.com/mono/mono/blob/master/mcs/class/corlib/System.IO/MonoIO.cs#L414 https://github.com/mono/mono/blob/master/mono/metadata/file-io.c#L1191 https://github.com/mono/mono/blob/master/mono/io-layer/locking.c#L117 https://github.com/mono/mono/blob/master/mono/io-layer/locking.c#L26 So, why is fcntl(2) failing? I don't know, you're swallowing the exception. - Jon ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Problems with FileStream.Lock();
Channels are what they seem to call any I/O path. http://developer.android.com/reference/java/nio/channels/package-summary.html The actual exception thrown is: "Lock violation on path /mnt/sdcard/external_sd/TestDb/Test.Tbl"{System.IO.IOException: Lock violation on path /mnt/sdcard/external_sd/TestDb/Test.Tbl at System.IO.FileStream.Lock (Int64 position, Int64 length) [0x0] in :0 at TrwLinqDb.Streams.LockedStream.Lock () [0x00025] in d:\MyWorkSpace\C Sharp\TrwLinqDb\TrwLinqDb\Streams\LockedStream.cs:90 } Regards Terry On 9/01/2013 9:21 AM, Jonathan Pryor wrote: On Jan 8, 2013, at 4:44 PM, Terry-Watts.com wrote: I have check the Android API docs and file locking has been available on channels since API Level 1. "on channels"? Anyway, quick perusal of the source shows that FileStream.Lock() is fcntl(2): https://github.com/mono/mono/blob/master/mcs/class/corlib/System.IO/FileStream.cs#L875 https://github.com/mono/mono/blob/master/mcs/class/corlib/System.IO/MonoIO.cs#L414 https://github.com/mono/mono/blob/master/mono/metadata/file-io.c#L1191 https://github.com/mono/mono/blob/master/mono/io-layer/locking.c#L117 https://github.com/mono/mono/blob/master/mono/io-layer/locking.c#L26 So, why is fcntl(2) failing? I don't know, you're swallowing the exception. - Jon ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Problems with FileStream.Lock();
Hi, I think your worst mistake you do is on this line Am 07.01.2013 22:50, schrieb Terry-Watts.com: > |try{base.Lock(0,Int64.MaxValue);break;}catch(ExceptionE > ){Thread.Sleep(SleepCount++);}}| You catch *all* exceptions. This is horrible. You should definitely specify your exception you except (haha). You also should look what kind of exception was thrown, maybe a NotSupported (on this platform) exception would be fine, else file a bug, that it should be done, cause it's not supported by android (regarding to Rafael Teixeira) Regards, Marcel signature.asc Description: OpenPGP digital signature ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list