Commit 3f1c4cc9 authored by Artur Bergman's avatar Artur Bergman

On Solaris we occasionally get EBADF when we use the ioctl

to toggle blocking. This then results in the connects failing.

The way Solaris seems to want it to be done is using fcntl
over two syscalls. So make it so conditionally for Solaris.

Should fix #482 and #535

Compiled on Solaris and Victori tested a prelminary version
of the patch that solved it. Sadly test cases don't 
seem to run at all on my solaris dev zone.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4161 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 7696f68e
......@@ -57,6 +57,11 @@ SVNID("$Id$")
#include "libvarnish.h"
/* Solaris can't use the ioctl" */
#ifdef __sun
#include <fcntl.h>
#endif
/*--------------------------------------------------------------------*/
void
......@@ -127,22 +132,23 @@ TCP_filter_http(int sock)
* us to do two syscalls, one to get and one to set, the latter of
* which mucks about a bit before it ends up calling ioctl(FIONBIO),
* at least on FreeBSD.
*
* On some platforms we need to use fcntl because the ioctl is unreliable
* The one that we know this is the case for is solaris.
*/
/*
* XXXXX -- Artur after debugging with victory
* This needs to rewrotten to use fcntl on solaris
* since the ioctl breaks connects.
* How to know we are on solaris?
*/
void
TCP_blocking(int sock)
{
int i;
#ifdef __sun
i = fcntl (sock, F_GETFL,0);
fcntl(sock, F_SETFL, i & ~O_NONBLOCK);
#else
i = 0;
AZ(ioctl(sock, FIONBIO, &i));
#endif
}
void
......@@ -150,8 +156,13 @@ TCP_nonblocking(int sock)
{
int i;
#ifdef __sun
i = fcntl (sock, F_GETFL,0);
fcntl(sock, F_SETFL, i | O_NONBLOCK);
#else
i = 1;
AZ(ioctl(sock, FIONBIO, &i));
#endif
}
/*--------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment