|
|
| Author |
Message |
|
| mahandler |
Posted: Tue Apr 29, 2008 9:38 pm |
|
|
|
Joined: 23 Apr 2008
Posts: 5
|
The current application I am working on is similar to a general chat server except that chatrooms have a shared xml state that the users can perform all sorts of actions on. I initially set this up as a gen_server where the state of the server is the xml and the list of the users in the "chatroom." My intent was that once this was done, i could then have a supervisor control the spawning of multiple gen_server's for different groups of clients. It turns out this is the wrong approach, and now I am thinking that what i should do is have another gen_server that controls the functionality of spawning/managing the chatrooms, and in turn spawns a supervisor and registers each spawned chatroom gen_server with that supervisor. As far as I can tell this will work the way I want it to, but I wanted to see if anyone had any tips for this kind of problem.
More generally, what is the OTP style solution when you want to have a gen_server that controls other gen_servers (with more functionality than a supervisor)? |
|
|
| Back to top |
|
| francesco |
Posted: Mon Jun 02, 2008 12:00 pm |
|
|
|
User
Joined: 07 Jul 2006
Posts: 249
Location: London
|
From your gen_server, spawn new processes calling process_lib:spawn_link. Make sure you link yourself to the parent, because if your application is restarted, you might end up with zombie processes. This might not appear as a problem at first, but think that Erlang programs run years and years without being stopped. Zombie processes would cause a memory leak, forcing you to restart the whole system. Linking to the parent would allow you to fix the bug by restarting the parent only.
Francesco
--
http://www.erlang-consulting.com |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|