Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Mar 2015 22:22:08 +0100
From:      Ivan Radovanovic <radovanovic@gmail.com>
To:        freebsd-mono@freebsd.org
Subject:   Re: ASP.Net and file changes on FreeBSD
Message-ID:  <5509EC80.1060105@gmail.com>
In-Reply-To: <5509E8B8.3090602@gmail.com>
References:  <54F96252.9040705@gmail.com> <55095322.2070604@gmail.com> <5509E8B8.3090602@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 03/18/15 22:06, Ivan Radovanovic napisa:
> On 03/18/15 11:27, Ivan Radovanovic napisa:
>> On 03/06/15 09:16, Ivan Radovanovic napisa:
>>> Hi,
>>>
>>> I am running latest ASP.Net using latest mono from ports (3.10) on
>>> FreeBSD 10.1 and it seems it is unable to detect changes on (some?)
>>> files. What confuses me is that if I run xsp for testing project it is
>>> unable to realize that project DLL is recompiled, or if I change
>>> web.config it won't restart application manually, or if aspx file is
>>> changed it won't recompile it, but if I add new aspx file then it will
>>> try to compile that. It seems to me like it is able to detect file
>>> addition but not change.
>>>
>>> Is there some workaround for this?
>>>
>>> Kind regards,
>>> Ivan
>>>
>>> P.S.
>>> Is there some dedicated website/forum for mono on FreeBSD - I saw some
>>> page on mono project site but that is completely outdated and I also saw
>>> BSD# page on google, but that also seems little bit old? I did little
>>> bit of work on having up-to-date xsp/fast-cgi and monodevelop to
>>> compile/work on freebsd so I would like to pass that to somebody from
>>> freebsd-mono group so it could eventually reach ports :-)
>>
>> This is actually more interesting problem than what I expected, here are
>> conclusions up to this point:
>>
>> * 3.10.0 has completely broken kevent implentation of FileSystemWatcher
>> - so it couldn't restart application because it is not able to detect
>> any file changes (I gave up on patching this implementation with latest
>> code when I saw that 3.12.1 is ported to FreeBSD)
>>
>> * 3.12.1 has proper support for FileSystemWatcher, but I suspect
>> something in System.Web.dll is broken (for example it properly detects
>> dll change (writes message about that), but doesn't restart
>> application), I am still unable to pinpoint exact problem there
>>
>> * 3.2.3 has partially working FileSystemWatcher (using kevent) - it is
>> not able to catch file changes but only file creations/deletions, for
>> that reason changes using editors like ee which really change file
>> contents (not changing inode number) go undetected, but changes with
>> editors which recreate file (like monodevelop or gedit for example) are
>> properly captured and handled. This version also properly restarts
>> application when dll is changed.
>>
>> I was using identical xsp for all mono versions to rule out differences
>> there (I didn't do any tests using fastcgi server or mod_mono - will
>> probably do that once I have xsp working as expected).
>
> There were 2 problems here (applies to 3.12.1):
>
> * FileSystemWatcher implementation for kevent was relying on Darwin's
> specific behavior (when kevent is executed with NULL timeout, if kqueue
> FD is closed kevent call on Darwin returns with error, however FreeBSD
> doesn't behave that way), so instead of using (almost) blocking version
> of kevent I put reasonable timeout there (instead of 500 seconds they
> had I put 0.5 seconds)
>
> * HttpApplicationFactory wasn't able to restart application domain
> because of deadlock within FileSystemWatcher (basically file changed
> notification is executed from watcher's thread and then there is attempt
> to disable watcher from that same thread). I resolved this by creating
> separate thread to post events.
>
> As far as I can tell at least xsp now works as expected (restaring
> application on DLL changes, recompiling changed files if .aspx file is
> changed), I will probably test at least fastcgi server soon as well, and
> I will try to find solution which would work with blocking kevent.
>
> Attached is patch for latest mono version in ports (3.12.1) - patch file
> should be saved to files subdirectory of port and port should be rebuilt
> after that.

Previous patch had one mistake (timespec struct in fact uses 
nanoseconds, not microseconds (mono guys named member tv_usec, so I 
naturally assumed microseconds were used)) - I realized that when I 
checked CPU usage. This is final patch attached.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5509EC80.1060105>