+ int engine_remove = 1;
+ if(iofd->writebuf.bufpos) {
+ //try to send everything before closing
+#if defined(F_GETFL)
+ flags = fcntl(sockfd, F_GETFL);
+ fcntl(sockfd, F_SETFL, flags & ~O_NONBLOCK);
+ flags = fcntl(sockfd, F_GETFD);
+ fcntl(sockfd, F_SETFD, flags|FD_CLOEXEC);
+#else
+ engine_remove = 0;
+ engine->remove(iofd);
+#endif
+ iohandler_try_write(iofd);
+ }