Wrap fcntl to exclude Windows.

Naive implementation, get it compiled but crashes.
This commit is contained in:
Luis Lavena 2010-08-21 22:39:41 -03:00 committed by Brian Lopez
parent b3ec7b57de
commit 4f9625f877
1 changed files with 6 additions and 2 deletions

View File

@ -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. */