VBE_CheckFd(): Check that a filedescriptor is reusable.
Right now we simply poll it with a zero timeout, and if there are
any events, we can't reuse it.
This check may need refinement down the road.
One option would be to attempt to write a CRNL onto the fd and see
that it works.
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1965
d4fa192b-c00b-0410-8231-
f00ffab90ce4
struct vbe_conn *VBE_NewConn(void);
void VBE_ReleaseConn(struct vbe_conn *);
void VBE_UpdateHealth(struct sess *sp, struct vbe_conn *, int);
+
+/* convenience functions for backend methods */
int VBE_TryConnect(struct sess *sp, struct addrinfo *ai);
+int VBE_CheckFd(int fd);
/* cache_backend_simple.c */
extern struct backend_method backend_method_simple;
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <poll.h>
#include <sys/socket.h>
#include <netdb.h>
return (s);
}
+/*--------------------------------------------------------------------
+ * Check that there is still something at the far end of a given fd.
+ * We poll the fd with instant timeout, if there are any events we can't
+ * use it (backends are not allowed to pipeline).
+ */
+
+int
+VBE_CheckFd(int fd)
+{
+ struct pollfd pfd;
+ pfd.fd = fd;
+ pfd.events = POLLIN;
+ pfd.revents = 0;
+ return(poll(&pfd, 1, 0) == 0);
+}
/*--------------------------------------------------------------------
* Get a http structure for talking to the backend.