AW: How does tux redirect the request to the secondary server?

Max Helmet max at expires-2004.workforce.de
Thu Dec 2 08:57:40 UTC 2004


> Yeah, we can use network hand-off or tcp splicing tech. 
> to do that. But we must modify the tpc/ip protocol stack 
> code. So is tux?

Just have a look at the redirect_sock(*req, port) function 
in linux/net/tux/redirect.c:

1. It "looks up listening user-space socket" (->Apache)
2. "Requeue the 'old' socket as an accept-socket of
   the listening socket. This way we can shuffle
   a socket around. Since we've read the input data
   via the non-destructive MSG_PEEK, the secondary
   server can be used transparently."
3. Closes the request for tux as "it's now completely 
   up to the secondary server to handle this request."

The magic part here is the non-destructive reading of the 
request in read_request(*sock, *buf, max_size) via  
sock->sk->sk_prot->recvmsg(&iocb, sock->sk, &msg, max_size,
                           MSG_DONTWAIT, MSG_PEEK, NULL);

> Thanks much!!

You welcome!!!

Max




More information about the tux-list mailing list