[MEDIUM] moved the sockaddr pointer to the fdtab structure
The stream_sock_* functions had to know about sessions just in
order to get the server's address for a connect() operation. This
is not desirable, particularly for non-IP protocols (eg: PF_UNIX).
Put a pointer to the peer's sockaddr_storage or sockaddr address
in the fdtab structure so that we never need to look further.
With this small change, the stream_sock.c file is now 100% protocol
independant.
diff --git a/src/stream_sock.c b/src/stream_sock.c
index 4541343..8c47d31 100644
--- a/src/stream_sock.c
+++ b/src/stream_sock.c
@@ -27,7 +27,6 @@
#include <types/buffers.h>
#include <types/global.h>
#include <types/polling.h>
-#include <types/session.h>
#include <proto/client.h>
#include <proto/fd.h>
@@ -229,8 +228,6 @@
if (max == 0) {
/* may be we have received a connection acknowledgement in TCP mode without data */
if (likely(fdtab[fd].state == FD_STCONN)) {
- struct session *s = fdtab[fd].owner->context;
-
/* We have no data to send to check the connection, and
* getsockopt() will not inform us whether the connection
* is still pending. So we'll reuse connect() to check the
@@ -240,7 +237,7 @@
* - connecting (EALREADY, EINPROGRESS)
* - connected (EISCONN, 0)
*/
- if ((connect(fd, (struct sockaddr *)&s->srv_addr, sizeof(s->srv_addr)) == 0))
+ if ((connect(fd, fdtab[fd].peeraddr, fdtab[fd].peerlen) == 0))
errno = 0;
if (errno == EALREADY || errno == EINPROGRESS) {