X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem%2FSystem.IO%2FKeventWatcher.cs;h=f17eb58d28dca262aeb2205bcaa41468a5183292;hb=08a728d237965feb2bbd485f909998b17c0bbb11;hp=b2d964ceb5e0cc451618a2dfc914fd78f8dbc446;hpb=c1d81649cc1d16ee47bd6fb951e220d8aba6a1d0;p=mono.git diff --git a/mcs/class/System/System.IO/KeventWatcher.cs b/mcs/class/System/System.IO/KeventWatcher.cs index b2d964ceb5e..f17eb58d28d 100644 --- a/mcs/class/System/System.IO/KeventWatcher.cs +++ b/mcs/class/System/System.IO/KeventWatcher.cs @@ -317,10 +317,17 @@ namespace System.IO { var eventBuffer = new kevent[0]; // we don't want to take any events from the queue at this point var changes = CreateChangeList (ref initialFds); - int numEvents = kevent (conn, changes, changes.Length, eventBuffer, eventBuffer.Length, ref immediate_timeout); + int numEvents; + int errno = 0; + do { + numEvents = kevent (conn, changes, changes.Length, eventBuffer, eventBuffer.Length, ref immediate_timeout); + if (numEvents == -1) { + errno = Marshal.GetLastWin32Error (); + } + } while (numEvents == -1 && errno == EINTR); if (numEvents == -1) { - var errMsg = String.Format ("kevent() error at initial event registration, error code = '{0}'", Marshal.GetLastWin32Error ()); + var errMsg = String.Format ("kevent() error at initial event registration, error code = '{0}'", errno); throw new IOException (errMsg); } } @@ -384,9 +391,10 @@ namespace System.IO { // Stop () signals us to stop by closing the connection if (requestStop) break; - if (++retries == 3) + int errno = Marshal.GetLastWin32Error (); + if (errno != EINTR && ++retries == 3) throw new IOException (String.Format ( - "persistent kevent() error, error code = '{0}'", Marshal.GetLastWin32Error ())); + "persistent kevent() error, error code = '{0}'", errno)); continue; } @@ -646,6 +654,7 @@ namespace System.IO { const int O_EVTONLY = 0x8000; const int F_GETPATH = 50; const int __DARWIN_MAXPATHLEN = 1024; + const int EINTR = 4; static readonly kevent[] emptyEventList = new System.IO.kevent[0]; int maxFds = Int32.MaxValue; @@ -665,19 +674,19 @@ namespace System.IO { string fixupPath = null; string fullPathNoLastSlash = null; - [DllImport ("libc", EntryPoint="fcntl", CharSet=CharSet.Auto, SetLastError=true)] + [DllImport ("libc", CharSet=CharSet.Auto, SetLastError=true)] static extern int fcntl (int file_names_by_descriptor, int cmd, StringBuilder sb); - [DllImport ("libc")] + [DllImport ("libc", SetLastError=true)] extern static int open (string path, int flags, int mode_t); [DllImport ("libc")] extern static int close (int fd); - [DllImport ("libc")] + [DllImport ("libc", SetLastError=true)] extern static int kqueue (); - [DllImport ("libc")] + [DllImport ("libc", SetLastError=true)] extern static int kevent (int kq, [In]kevent[] ev, int nchanges, [Out]kevent[] evtlist, int nevents, [In] ref timespec time); [MethodImplAttribute(MethodImplOptions.InternalCall)]