diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-18 04:24:34 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-08-18 04:24:34 +0100 |
commit | fd4f2d45610a3f2ce651d08a42f6a3e4a1277dca (patch) | |
tree | 922079a40afa43a76d619acb378d86c464aeb627 | |
parent | b40e8ecf8a3f04cff949dcdb0c273e1e84cb70cb (diff) | |
download | rabbitmq-server-fd4f2d45610a3f2ce651d08a42f6a3e4a1277dca.tar.gz |
take current memory alarms status into account straight away
This does in fact not alter the behaviour at all due to the following:
- if the alarm is active the alarm registration will call the handler
straight way, which will send a {conserve_memory, true} message to the
reader.
- the reply to the alarm registration is sent after that, and from the
same process - the alarm process - so by the time the reader loops
around the mainloop again the {conserve_memory, true} message is
guaranteed to be in the mailbox
- on looping around, the reader request a frame_header from the
socket. The reader has already sent connection.open_ok to the client,
and the client may have started sending commands straight away. But
all the reader is going to see of that to start with is an {inet_async,
...} message for a frame_header. That is guaranteed to end up in the
mailbox after the {conserve_memory, true} message.
Thus the reader is guaranteed to process the {conserve_memory, true}
message before handling any more data from the socket.
With this change it is rather more obvious that the memory alarm
status gets taken into account before any more client data is
processed.
-rw-r--r-- | src/rabbit_reader.erl | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index d5ade90f..a133bf45 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -761,9 +761,10 @@ handle_method0(#'connection.open'{virtual_host = VHostPath}, ok = rabbit_access_control:check_vhost_access(User, VHostPath), NewConnection = Connection#connection{vhost = VHostPath}, ok = send_on_channel0(Sock, #'connection.open_ok'{}, Protocol), - rabbit_alarm:register(self(), {?MODULE, conserve_memory, []}), - State1 = State#v1{connection_state = running, - connection = NewConnection}, + State1 = internal_conserve_memory( + rabbit_alarm:register(self(), {?MODULE, conserve_memory, []}), + State#v1{connection_state = running, + connection = NewConnection}), rabbit_event:notify( connection_created, [{Item, i(Item, State1)} || Item <- ?CREATION_EVENT_KEYS]), |