kill duplicate write_ok()
[paraslash.git] / send.h
diff --git a/send.h b/send.h
index 2c6c7274344a6aaa03c1cf7c844639ca87c4d0ab..3aebb1600ebfdee0450c0100ae8c99921c7c0cd0 100644 (file)
--- a/send.h
+++ b/send.h
@@ -84,3 +84,26 @@ struct sender {
  */
        int (*client_cmds[NUM_SENDER_CMDS])(struct sender_command_data*);
 };
+
+/**
+ * check a file descriptor for writability
+ *
+ * \param fd the file desctiptor
+ *
+ * \return positive if fd is ready for writing, zero if it isn't, negative if
+ * an error occured.
+ */
+
+static inline int write_ok(int fd)
+{
+       struct timeval tv = {0, 0};
+       fd_set wfds;
+       int ret;
+again:
+       FD_ZERO(&wfds);
+       FD_SET(fd, &wfds);
+       ret = select(fd + 1, NULL, &wfds, NULL, &tv);
+       if (ret < 0 && errno == EINTR)
+               goto again;
+       return ret;
+}