From 4f9625f877a950cbcf68f8ab73414d899508f454 Mon Sep 17 00:00:00 2001 From: Luis Lavena Date: Sat, 21 Aug 2010 22:39:41 -0300 Subject: [PATCH] Wrap fcntl to exclude Windows. Naive implementation, get it compiled but crashes. --- ext/mysql2/client.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ext/mysql2/client.c b/ext/mysql2/client.c index 2a4d643..c6a9dab 100644 --- a/ext/mysql2/client.c +++ b/ext/mysql2/client.c @@ -117,16 +117,20 @@ static void rb_mysql_client_free(void * ptr) { * anyways, so ensure the socket write does not block our interpreter */ int fd = client->net.fd; - int flags; if (fd >= 0) { /* * if the socket is dead we have no chance of blocking, * so ignore any potential fcntl errors since they don't matter */ - flags = fcntl(fd, F_GETFL); +#ifndef _WIN32 + int flags = fcntl(fd, F_GETFL); if (flags > 0 && !(flags & O_NONBLOCK)) fcntl(fd, F_SETFL, flags | O_NONBLOCK); +#else + u_long iMode = 1; + ioctlsocket(fd, FIONBIO, &iMode); +#endif } /* It's safe to call mysql_close() on an already closed connection. */