Hi Nikhil,

On Sat, Mar 17, 2018 at 05:39:29PM +0000, Nikhil Kapoor wrote:
> Actually, I just wanted to deeply understand the code of haproxy. So just
> wanted to know which tool should i use in order to understand the code. Is it
> only gdb that you all use or any other?

Well, gdb is not suited to read code. You'd rather need an editor or
an IDE to help you follow the code. Gdb can serve to place break points
at certain locations however.

What I could suggest you is to take a look at these places particularly :
  - run_poll_loop() : this one is the main loop, iterating between polling,
    processing I/O and processing tasks ;

  - listener_accept() : it's where an incoming connection is accepted

  - session_new() : it's called some time after listener_accept(), and
    creates a new session ;

  - stream_new() : it creates a fresh new stream on a session ;

  - process_stream() : it calls all analysers subscribed to a stream, and
    deals with timeouts, events etc... It's where the main tcp/http stuff
    happens ; 

  - cfg_parse_listen() : it's where most of the config keywords are still
    parsed (many of them have moved to other locations now). This will
    help you figure how config elements are allocated and initialized,
    how certain callbacks or analysers are enabled and why/when ;

  - check_config_validity() : some validity checks are run on the config
    there late in the boot process, some config elements are resolved,
    and some default values are assigned. I think it's also where we
    assign an ID to the backends and servers if they don't have one yet.
    It will definitely help you understand the relations between various
    elements.

Before this, take a look inside doc/internals, and particularly the file
"entities.pdf" which shows how a stream is attached to objects surrounding
it.

Hoping this helps,
Willy

  • Need help? Nikhil Kapoor
    • Re: Need help? Willy Tarreau

Reply via email to