diff --git a/include/proto/stream_sock.h b/include/proto/stream_sock.h index d0d172f19..e5d4f517a 100644 --- a/include/proto/stream_sock.h +++ b/include/proto/stream_sock.h @@ -39,6 +39,7 @@ void stream_sock_shutr(struct stream_interface *si); void stream_sock_shutw(struct stream_interface *si); void stream_sock_chk_rcv(struct stream_interface *si); void stream_sock_chk_snd(struct stream_interface *si); +void stream_sock_prepare_interface(struct stream_interface *si); /* This either returns the sockname or the original destination address. Code diff --git a/src/backend.c b/src/backend.c index 0e9987962..1fc6b2aaa 100644 --- a/src/backend.c +++ b/src/backend.c @@ -35,9 +35,11 @@ #include #include #include +#include #include #include #include +#include #include /* @@ -902,8 +904,11 @@ int connect_server(struct session *s) return SN_ERR_INTERNAL; } - if (!s->req->cons->connect) - return SN_ERR_INTERNAL; + /* Prepare the stream interface for a TCP connection. Later + * we may assign a protocol-specific connect() function. + */ + stream_sock_prepare_interface(s->req->cons); + s->req->cons->connect = tcpv4_connect_server; assign_tproxy_address(s); diff --git a/src/stream_sock.c b/src/stream_sock.c index 171ed294c..915979695 100644 --- a/src/stream_sock.c +++ b/src/stream_sock.c @@ -1,7 +1,7 @@ /* * Functions operating on SOCK_STREAM and buffers. * - * Copyright 2000-2009 Willy Tarreau + * Copyright 2000-2010 Willy Tarreau * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1221,6 +1221,17 @@ int stream_sock_accept(int fd) return 0; } +/* Prepare a stream interface to be used in socket mode. */ +void stream_sock_prepare_interface(struct stream_interface *si) +{ + si->update = stream_sock_data_finish; + si->shutr = stream_sock_shutr; + si->shutw = stream_sock_shutw; + si->chk_rcv = stream_sock_chk_rcv; + si->chk_snd = stream_sock_chk_snd; + si->iohandler = NULL; +} + /* * Local variables: