]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - fd.c
In handle_connect() we really need a blocking fd for the client.
[paraslash.git] / fd.c
diff --git a/fd.c b/fd.c
index ecd87cdccb555bafea525c3a5ded0063f2b63438..b78d266a613422f0319e4e6b4fb1d15c05cd2b60 100644 (file)
--- a/fd.c
+++ b/fd.c
@@ -60,6 +60,24 @@ int para_select(int n, fd_set *readfds, fd_set *writefds,
        return ret;
 }
 
+/**
+ * Set a file descriptor to blocking mode.
+ *
+ * \param fd The file descriptor.
+ *
+ * \return Standard.
+ */
+int mark_fd_blocking(int fd)
+{
+       int flags = fcntl(fd, F_GETFL);
+       if (flags < 0)
+               return -ERRNO_TO_PARA_ERROR(errno);
+       flags = fcntl(fd, F_SETFL, ((long)flags) & ~O_NONBLOCK);
+       if (flags < 0)
+               return -ERRNO_TO_PARA_ERROR(errno);
+       return 1;
+}
+
 /**
  * Set a file descriptor to non-blocking mode.
  *