On 6/10/05, Zoran Vasiljevic <[EMAIL PROTECTED]> wrote:
> Hi!
> 
> I'm in the process of cleaning up the code in order to
> re-enable Windows compilation.
> I've found several things we'd need to unify somehow:
> 
> We have (until recently) had only TCP protocol support
> hence the calls like:
> 
>    Ns_SockBind
>    Ns_SockListen
>    etc.
> 
> As of now, there are multiple other connection options
> supported (raw sockets, udp sockets, unix domain sockets).
> There are couple of places in the code where I see:
> 
> 
> Ns_SockBindUdp
> 
> Ns_SockListenEx
> Ns_SockListenUdp
> Ns_SockListenRaw
> Ns_SockListenUnix
> 
> I'd like to bring in some logic there. Therefore the proposal:
> 
> All TCP related calls should stay as-is.
> 
> We'd add additional calls to better identify what's being done:
> 
>    Ns_SockListenTcp   (new, should be called by Ns_SocketListen)
>    Ns_SockListenUdp   (exists)
>    Ns_SockListenRaw   (exists)
>    Ns_SockListenUnix  (exists)


Ns_SockListenTcp() should probably replace Ns_SockListenEx() with it's
backlog parameter?  The passed backlog should be checked, and if it's
< 1, use the default from the config file.

If this is the new recommended way to listen on sockets, I'd update
all callers of the old Ns_SockListen(Ex) functions.  People will cut
'n paste old code and continue the confusion.


> Then:
> 
>    Ns_SockBindTcp   (new, should be called by Ns_SocketBind)
>    Ns_SockBindUdp   (exists)
>    Ns_SockBindRaw   (new)
>    Ns_SockBindUnix  (new)
>
> In binder.c there are some calls which are only used withing the
> file hence we'd need to adjust the call interface to illustrate
> this:
> 
>    Ns_SockRaw  - > SockRaw
> 
> Also, the Ns_SockListenUnix is a combination of create + bind
> but unlike other pendants, does not honour the preboundUnix sockets.
> We should split this. Make the Ns_SockListenUnix actually
> honour prebound sockets (which it does not do now) and use
> internally the Ns_SockBindUnix to bind so it'd be on-pair with
> the TCP.


Hmm, Ns_SockListenUnix() doesn't actually call listen().  Is this
right?  Also, is a backlog parameter appropraite here, as in
Ns_SockListenEx()?


> All in all, this will not change the functionality but will
> *definitely* improve understanding and code maintenance.
> There are other places in sock.c which seem pretty odd like
> 
>    Ns_SockBind calls Ns_BindSock
> 
> what is the reason of having those two (backward-compat?)


You can decalare Ns_BindSock() NS_GNUC_DEPRECATED and no one else need
be confused  :-)


> I will like to cleanup this now. Are there any voices against
> or any other ideas?
> 
> Cheers
> Zoran

Reply via email to