On 02/03/2018 05:26, Peter Xu wrote: > Frankly speaking I was a bit confused when I started to read > chardev/qio codes with so many hooks, e.g., when I saw: > > qio_net_listener_set_client_func(s->listener, tcp_chr_accept, > chr, NULL); > > I totally have no idea on what happened. I need to go deeper into the > net listener code to know that, hmm, it's setting up something to > accept connections! > > If I can have something like: > > tcp_chr_net_listener_setup(s, true); > > It may be easier for me to understand that there's something either > registered for the listening ports, and I don't need to care about > which function will be called when accept happened. Basically it > "hides" some logic inside, that's IMHO where functions/macros help.
I tend to agree with Daniel, but I probably would be convinced if you had a pair of functions tcp_chr_{start,stop}_listen instead of a bool argument. Paolo