diff options
| author | Matthew Sackman <matthew@rabbitmq.com> | 2010-06-30 11:57:18 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@rabbitmq.com> | 2010-06-30 11:57:18 +0100 |
| commit | 5cca679cd5057a1962ef23ddbfb6e98b79b92129 (patch) | |
| tree | 5a9c349f83de144b1e8c7863443a1b180cd1e1a3 /src | |
| parent | 8bbcb423fb6f79cce91f29472d745f0b6e986c8c (diff) | |
| parent | ce658f9bbab8ef4df386b4845a5705a8f0728ff9 (diff) | |
| download | rabbitmq-server-git-5cca679cd5057a1962ef23ddbfb6e98b79b92129.tar.gz | |
Merge default into bug 21673
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_channel.erl | 57 | ||||
| -rw-r--r-- | src/rabbit_networking.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_reader.erl | 18 |
3 files changed, 43 insertions, 34 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index d337df294f..8649ecc7f1 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -726,42 +726,33 @@ handle_method(#'queue.declare'{queue = QueueNameBin, end, %% We use this in both branches, because queue_declare may yet return an %% existing queue. - Finish = fun (#amqqueue{name = QueueName, - durable = Durable1, - auto_delete = AutoDelete1} = Q) - when Durable =:= Durable1, AutoDelete =:= AutoDelete1 -> - check_exclusive_access(Q, Owner, strict), - check_configure_permitted(QueueName, State), - %% We need to notify the reader within the channel - %% process so that we can be sure there are no - %% outstanding exclusive queues being declared as the - %% connection shuts down. - case Owner of - none -> ok; - _ -> ok = rabbit_reader_queue_collector:register_exclusive_queue(CollectorPid, Q) - end, - Q; - %% non-equivalence trumps exclusivity arbitrarily - (#amqqueue{name = QueueName}) -> - rabbit_misc:protocol_error( - precondition_failed, - "parameters for ~s not equivalent", - [rabbit_misc:rs(QueueName)]) - end, - Q = case rabbit_amqqueue:with( - rabbit_misc:r(VHostPath, queue, QueueNameBin), - Finish) of - {error, not_found} -> - ActualNameBin = - case QueueNameBin of + ActualNameBin = case QueueNameBin of <<>> -> rabbit_guid:binstring_guid("amq.gen"); Other -> check_name('queue', Other) end, - QueueName = rabbit_misc:r(VHostPath, queue, ActualNameBin), - Finish(rabbit_amqqueue:declare(QueueName, Durable, AutoDelete, - Args, Owner)); - #amqqueue{} = Other -> - Other + QueueName = rabbit_misc:r(VHostPath, queue, ActualNameBin), + Q = case rabbit_amqqueue:declare(QueueName, Durable, AutoDelete, + Args, Owner) of + #amqqueue{name = QueueName, + durable = Durable1, + auto_delete = AutoDelete1} = Q1 + when Durable =:= Durable1, AutoDelete =:= AutoDelete1 -> + check_exclusive_access(Q1, Owner, strict), + check_configure_permitted(QueueName, State), + %% We need to notify the reader within the channel + %% process so that we can be sure there are no + %% outstanding exclusive queues being declared as the + %% connection shuts down. + case Owner of + none -> ok; + _ -> ok = rabbit_reader_queue_collector:register_exclusive_queue(CollectorPid, Q1) + end, + Q1; + %% non-equivalence trumps exclusivity arbitrarily + #amqqueue{name = QueueName} -> + rabbit_misc:protocol_error( + precondition_failed, "parameters for ~s not equivalent", + [rabbit_misc:rs(QueueName)]) end, return_queue_declare_ok(State, NoWait, Q); diff --git a/src/rabbit_networking.erl b/src/rabbit_networking.erl index c3d0b7b786..68ffc98ad7 100644 --- a/src/rabbit_networking.erl +++ b/src/rabbit_networking.erl @@ -102,7 +102,7 @@ boot_ssl() -> {ok, []} -> ok; {ok, SslListeners} -> - ok = rabbit_misc:start_applications([crypto, ssl]), + ok = rabbit_misc:start_applications([crypto, public_key, ssl]), {ok, SslOpts} = application:get_env(ssl_options), [start_ssl_listener(Host, Port, SslOpts) || {Host, Port} <- SslListeners], ok diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index 8ba5874061..f2a903dcca 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -103,6 +103,8 @@ %% heartbeat timeout -> *throw* %% closing: %% socket close -> *terminate* +%% receive connection.close -> send connection.close_ok, +%% *closing* %% receive frame -> ignore, *closing* %% handshake_timeout -> ignore, *closing* %% heartbeat timeout -> *throw* @@ -119,6 +121,8 @@ %% start terminate_connection timer, *closed* %% closed: %% socket close -> *terminate* +%% receive connection.close -> send connection.close_ok, +%% *closed* %% receive connection.close_ok -> self() ! terminate_connection, %% *closed* %% receive frame -> ignore, *closed* @@ -486,10 +490,18 @@ handle_frame(Type, Channel, Payload, State) -> closing -> %% According to the spec, after sending a %% channel.close we must ignore all frames except + %% channel.close and channel.close_ok. In the + %% event of a channel.close, we should send back a %% channel.close_ok. case AnalyzedFrame of {method, 'channel.close_ok', _} -> erase({channel, Channel}); + {method, 'channel.close', _} -> + %% We're already closing this channel, so + %% there's no cleanup to do (notify + %% queues, etc.) + ok = rabbit_writer:send_command(State#v1.sock, + #'channel.close_ok'{}); _ -> ok end, State; @@ -666,6 +678,12 @@ handle_method0(#'connection.close'{}, State = #v1{connection_state = running}) -> lists:foreach(fun rabbit_framing_channel:shutdown/1, all_channels()), maybe_close(State#v1{connection_state = closing}); +handle_method0(#'connection.close'{}, State = #v1{connection_state = CS}) + when CS =:= closing; CS =:= closed -> + %% We're already closed or closing, so we don't need to cleanup + %% anything. + ok = send_on_channel0(State#v1.sock, #'connection.close_ok'{}), + State; handle_method0(#'connection.close_ok'{}, State = #v1{connection_state = closed}) -> self() ! terminate_connection, |
