Erlang为什么进程可以';t在使用proc_lib:hibernate后退出

Erlang为什么进程可以';t在使用proc_lib:hibernate后退出,erlang,Erlang,我刚开始学习Erlang并尝试编写comet应用程序 事情是这样的 为了降低内存使用率,我使用了proc_lib:hibernateon-feed函数。但是当套接字断开时,相应的进程仍然存在,而不是退出 代码如下所示: feed({Response, Interval, Socket}) -> ok = mochiweb_socket:setopts(Socket, [{active, once}]), receive

我刚开始学习Erlang并尝试编写comet应用程序

事情是这样的

为了降低内存使用率,我使用了
proc_lib:hibernate
on-feed函数。但是当套接字断开时,相应的进程仍然存在,而不是退出

代码如下所示:

feed({Response, Interval, Socket}) ->            
    ok = mochiweb_socket:setopts(Socket, [{active, once}]),                
receive                                                              
        {Protocal, _, Bin} ->                                                     
            ok;                                                                
  {tcp_closed, _} ->                                                   
          exit(normal);                                                        
    {ssl_closed, _} ->                                                     
          exit(normal);                                                        
  {router_msg, MsgBody} ->                                                    
      RespMsg=Response:write_chunk(MsgBody);                                                                                 
    Other ->                                                                         
      exit(normal)                                                     
after Interval ->                                                              
        Response:write_chunk("HB")                                   
  end,                                                                        
proc_lib:hibernate(?MODULE, feed, [{Response, Interval, Socket}]). 

在休眠之前,您需要再次将套接字选项设置为
{active,once}
。否则,套接字将永远不会向进程发送消息,因此进程不会从休眠中醒来