[erlang-questions] Re: Upgrading a gen_tcp acceptor process

Bengt Kleberg <>
Tue Mar 29 08:48:01 CEST 2011


Greetings,

This is only theoretical speculations.

How about a very simple process that does nothing but
1) gen_tcp:accept/1
2) send the new socket to the gen_server
3) repeat
This process you kill and restart, if needed, from the gen_server during
upgrade.


bengt

On Tue, 2011-03-29 at 07:58 +0200, Sam Bobroff wrote:
> Hello again Erlangers,
> 
> I've been teaching myself about code reloading (or "hot upgrades") and
> I've hit problem with my very simple test application.
> 
> The problem occurs in a server that accepts TCP connections and is:
> 
> (1) To do it's work, the process must at some point call
> gen_tcp:accept() to accept new connections, which blocks.
> (2) To be upgraded, the process must handle system messages in a receive
> loop.
> 
> I can't see a way to reconcile (1) and (2) without polling constantly by
> adding a timeout to gen_tcp:accept(), and this seems to be a horrible
> solution. Given that this is probably a very common situation, how am I
> supposed to handle it?
> 
> (I don't want to confuse things, but it seems like the interface to
> gen_tcp:accept() causes another problem: It can't be put in a gen_server
> for the same reason. It seems "obvious" that there should be a message
> passing interface to it but I don't see an EEP for it; is there some
> reason why it couldn't work that way?)
> 
> Thanks in advance for any comments or pointers!
> 
> Peace,
> Sam.
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list