MCPcopy Create free account
hub / github.com/apache/brpc / RemoveService

Method RemoveService

src/brpc/server.cpp:1691–1726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1689}
1690
1691int Server::RemoveService(google::protobuf::Service* service) {
1692 if (NULL == service) {
1693 LOG(ERROR) << "Parameter[service] is NULL";
1694 return -1;
1695 }
1696 if (status() != READY) {
1697 LOG(ERROR) << "Can't remove service="
1698 << service->GetDescriptor()->full_name() << " from Server["
1699 << version() << "] which is " << status_str(status());
1700 return -1;
1701 }
1702
1703 const google::protobuf::ServiceDescriptor* sd = service->GetDescriptor();
1704 ServiceProperty* ss = _fullname_service_map.seek(butil::EnsureString(sd->full_name()));
1705 if (ss == NULL) {
1706 RPC_VLOG << "Fail to find service=" << sd->full_name();
1707 return -1;
1708 }
1709 RemoveMethodsOf(service);
1710 if (ss->ownership == SERVER_OWNS_SERVICE) {
1711 delete ss->service;
1712 }
1713 const bool is_builtin_service = ss->is_builtin_service;
1714 _fullname_service_map.erase(sd->full_name());
1715 _service_map.erase(sd->name());
1716
1717 // Note: ss is invalidated.
1718 if (is_builtin_service) {
1719 --_builtin_service_count;
1720 } else {
1721 if (_first_service == service) {
1722 _first_service = NULL;
1723 }
1724 }
1725 return 0;
1726}
1727
1728void Server::ClearServices() {
1729 if (status() != READY) {

Callers 2

TEST_FFunction · 0.80
TestStatusMethod · 0.80

Calls 6

status_strFunction · 0.85
EnsureStringFunction · 0.85
GetDescriptorMethod · 0.45
seekMethod · 0.45
eraseMethod · 0.45
nameMethod · 0.45

Tested by 2

TEST_FFunction · 0.64
TestStatusMethod · 0.64