| 651 | |
| 652 | |
| 653 | void Server::createServer( |
| 654 | Poco::Util::AbstractConfiguration & config, |
| 655 | const std::string & listen_host, |
| 656 | const char * port_name, |
| 657 | bool listen_try, |
| 658 | bool start_server, |
| 659 | std::vector<ProtocolServerAdapter> & servers, |
| 660 | CreateServerFunc && func) const |
| 661 | { |
| 662 | if (DB::createServer(config, listen_host, port_name, listen_try, start_server, servers, std::move(func), &logger())) |
| 663 | { |
| 664 | /// Register the configured port rather than the actual bound port. `getServerPort` keeps a |
| 665 | /// single value per `port_name`, so with `tcp_port=0` (OS-assigned) and several `listen_host` |
| 666 | /// values (e.g. the default `::1` + `127.0.0.1`) each host binds a distinct ephemeral port and |
| 667 | /// registering the actual port would let the last host overwrite the others, leaving |
| 668 | /// `getServerPort` pointing at a port that is not listening on the host a client uses. When the |
| 669 | /// configured port is non-zero it equals the bound port anyway, so this preserves the previous |
| 670 | /// behavior in all cases. (`clickhouse-local` registers the actual bound port because it needs |
| 671 | /// the OS-assigned value, but it rejects the ambiguous `port=0` + multiple `listen_host` combo.) |
| 672 | global_context->registerServerPort(port_name, static_cast<UInt16>(config.getInt(port_name))); |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | |
| 677 | #if defined(OS_LINUX) |
nothing calls this directly
no test coverage detected