Commit b62efa7d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Pretend to use variable, even if kernel is deficient.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4566 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent c36069c5
......@@ -61,6 +61,45 @@ SVNID("$Id$")
#include "libvarnish.h"
/*--------------------------------------------------------------------
* Recognize errno's we see when the remote end closed the connection.
*
* This "magic" is mostly needed because solaris wrongly returns EBADF
* when they should return ECONNRESET upon receiving a TCP-RST from the
* far end.
*
* My theory is, that some genius decided that since the socket is now
* officially useless, and since they already have found and locked
* the socket/pcb, they might as well get rid off it right away.
*
* On next use from the program, EBADF happens to be the errno, but since
* all programs just call strerror(), who cares ?
*
* Well, I do. EBADF is the canonical "Programmer goofed" errno, and
* it should not be issued for other reasons.
*
* An interesting question here, is if the kernel might conceiveably
* reallocate the fd# before the application closes it, on the mistaken
* belief that it is unused ? That would be bad news...
*
*/
int
TCP_Errno(void)
{
switch (errno) {
case ECONNRESET:
case ENOTCONN:
#if defined (__SVR4) && defined (__sun)
case EBADF:
#endif
return (1);
default:
return (0);
}
}
/*--------------------------------------------------------------------*/
void
......@@ -232,9 +271,8 @@ TCP_connect(int s, const struct sockaddr *name, socklen_t namelen, int msec)
void
TCP_close(int *s)
{
assert (close(*s) == 0 ||
errno == ECONNRESET ||
errno == ENOTCONN);
assert (close(*s) == 0 || TCP_Errno());
*s = -1;
}
......@@ -246,6 +284,8 @@ TCP_set_read_timeout(int s, double seconds)
timeout.tv_usec = (int)(1e6 * (seconds - timeout.tv_sec));
#ifdef SO_RCVTIMEO_WORKS
AZ(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout));
#else
(void)s;
#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