[MEDIUM] backend: initialize the server stream_interface upon connect()
It's not normal to initialize the server-side stream interface from the
accept() function, because it may change later. Thus, we introduce a new
stream_sock_prepare_interface() function which is called just before the
connect() and which sets all of the stream_interface's callbacks to the
default ones used for real sockets. The ->connect function is also set
at the same instant so that we can easily add new server-side protocols
soon.
diff --git a/src/stream_sock.c b/src/stream_sock.c
index 171ed29..9159796 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 <w@1wt.eu>
+ * Copyright 2000-2010 Willy Tarreau <w@1wt.eu>
*
* 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 @@
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: