[erlang-questions] Clean/ignore dead process messages

Zoltan Lajos Kis kiszl@REDACTED
Thu Aug 20 17:21:11 CEST 2009


Hi,

One way is to monitor all waiting processes in your fifo process. If the 
process dies, you will receive a 'DOWN' message, so you can remove the 
dead process from the remove queue.

The other way is to change clients to polling: if the fifo is empty, 
send a message immediately immediately, and have the client ask for out 
again after some time.

(http://erlang.org/doc/man/erlang.html#erlang:monitor-2)

Regards,
Zoltan.

Petr Sturc wrote:
> Folks,
>
> being newbee, I am stucked with following problem:
>
> I have a process simulating FIFO queue . You can store something by sending
> "in" message {in,Data} or get data by sending "out" message. When the queue
> is empty, the client gets blocked (waiting in its receive clause).
>
> The problem happens when client dies/disconnects while waiting for the
> response from the queue.
>
> The queue still have the "out" message from the now dead process in its
> inbox. When the queue gets non-empty the message matches and queue sends
> data to dead process and data are lost.
>
> Is there a way to remove all messages from killed/dead process from other's
> process inbox?
> Or do you see some other way to ensure that the data are not lost?
>
> Thanks for your ideas.
> Petr
>
>   



More information about the erlang-questions mailing list