On Tue, Apr 22, 2014 at 01:28:52PM -0400, David S wrote:
> >
> > (...)
> > >  /* returns true is the transport layer is ready */
> > >  static inline int conn_xprt_ready(const struct connection *conn)
> > > diff --git a/include/types/connection.h b/include/types/connection.h
> > > index 5341a86..b3b85ab 100644
> > > --- a/include/types/connection.h
> > > +++ b/include/types/connection.h
> > > @@ -245,6 +245,7 @@ struct connection {
> > >       enum obj_type obj_type;       /* differentiates connection from
> > applet context */
> > >       unsigned char err_code;       /* CO_ER_* */
> > >       signed short send_proxy_ofs;  /* <0 = offset to (re)send from the
> > end, >0 = send all */
> > > +     unsigned int send_proxy_opts; /* PROXY protocol option flags */
> >
> > Adding fields to struct connection is really not welcome, these ones should
> > remain as small as possible. I don't think there's anything in these
> > options
> > that cannot be deduced from the target. So we'd rather check the
> > connection's
> > target from the make_proxy_line() function instead.
> > (...)
> 
> 
> Hi Willy--
>    I'm happy to make all of these changes.   I agree, that having all the
> options in one place (struct server) is better than duplicating them.
>    Would you please point me to a code example of how to find (server *)
> from (connection *)?  That is not obvious to me.

Yes sure, for this there's a "target" pointer in the connection, it
points to an enum obj_type* which lets us check what the target is.

So basically to get a server pointer, you just need to use this :

  srv = objt_server(conn->target);

If the target is not a server, srv will be NULL so the test is easy.
Take a look in backend.c:assign_server(), there's a test to know if
a connection may be reused or not which uses this method to get the
server's pointer.

Cheers,
Willy


Reply via email to