From 16d55651e8b1c9b03798f0f77c4f42015bac24d0 Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Thu, 28 Jun 2012 00:29:24 +0100 Subject: [PATCH] mon: MonmapMonitor: Use default port when the specified on 'add' is zero Fixes a bug triggered by using the ceph tool to 'mon add' with a port set to zero. We now default to the monitor's default port (6789) instead, and we will fail if that port is already assigned to some other monitor. Fixes: bug #2661 Signed-off-by: Joao Eduardo Luis --- src/mon/MonmapMonitor.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index d07714cd9a68b..10605a9b60090 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -310,9 +310,17 @@ bool MonmapMonitor::prepare_command(MMonCommand *m) ss << "addr " << m->cmd[3] << "does not parse"; goto out; } + + if (addr.get_port() == 0) { + ss << "port defaulted to " << CEPH_MON_PORT; + addr.set_port(CEPH_MON_PORT); + } + if (pending_map.contains(addr) || pending_map.contains(name)) { err = -EEXIST; + if (!ss.str().empty()) + ss << "; "; ss << "mon " << name << " " << addr << " already exists"; goto out; } -- 2.39.5