summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2010-08-18 04:24:34 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2010-08-18 04:24:34 +0100
commit847144a104561c58106125959cf7546c72e6e686 (patch)
tree922079a40afa43a76d619acb378d86c464aeb627
parent3fe7c78a7ac920b5febb9e6073713cc11c581618 (diff)
downloadrabbitmq-server-git-847144a104561c58106125959cf7546c72e6e686.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.erl7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index d5ade90f6f..a133bf450d 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]),