]> git.tdb.fi Git - libs/core.git/blobdiff - source/io/unix/handle.cpp
Fix mismatched fcntls in sys_set_blocking on unix
[libs/core.git] / source / io / unix / handle.cpp
index 9546df9f579c657f61f658ee235db3e172eec7dd..cb3ce4cae54c16aae8ceb83194044aac98aca94c 100644 (file)
@@ -8,15 +8,9 @@
 namespace Msp {
 namespace IO {
 
-Handle::operator const void *() const
-{
-       return priv->handle!=-1 ? this : 0;
-}
-
-
 void sys_set_blocking(Handle &handle, bool b)
 {
-       int flags = fcntl(*handle, F_GETFD);
+       int flags = fcntl(*handle, F_GETFL);
        fcntl(*handle, F_SETFL, (flags&~O_NONBLOCK)|(b?0:O_NONBLOCK));
 }
 
@@ -50,7 +44,11 @@ unsigned sys_write(Handle &handle, const char *buf, unsigned size)
 
 void sys_close(Handle &handle)
 {
-       close(*handle);
+       if(handle)
+       {
+               close(*handle);
+               *handle = INVALID_HANDLE_VALUE;
+       }
 }
 
 } // namespace IO