| 1628 | } |
| 1629 | |
| 1630 | void Server::RemoveMethodsOf(google::protobuf::Service* service) { |
| 1631 | const google::protobuf::ServiceDescriptor* sd = service->GetDescriptor(); |
| 1632 | const bool is_idl_support = sd->file()->options().GetExtension(idl_support); |
| 1633 | std::string full_name_wo_ns; |
| 1634 | for (int i = 0; i < sd->method_count(); ++i) { |
| 1635 | const google::protobuf::MethodDescriptor* md = sd->method(i); |
| 1636 | MethodProperty* mp = _method_map.seek(md->full_name()); |
| 1637 | if (is_idl_support) { |
| 1638 | full_name_wo_ns.clear(); |
| 1639 | full_name_wo_ns.reserve(sd->name().size() + 1 + md->name().size()); |
| 1640 | full_name_wo_ns.append(sd->name()); |
| 1641 | full_name_wo_ns.push_back('.'); |
| 1642 | full_name_wo_ns.append(md->name()); |
| 1643 | _method_map.erase(full_name_wo_ns); |
| 1644 | } |
| 1645 | if (mp == NULL) { |
| 1646 | LOG(ERROR) << "Fail to find method=" << md->full_name(); |
| 1647 | continue; |
| 1648 | } |
| 1649 | if (mp->http_url) { |
| 1650 | butil::StringSplitter at_sp(mp->http_url->c_str(), '@'); |
| 1651 | for (; at_sp; ++at_sp) { |
| 1652 | butil::StringPiece path(at_sp.field(), at_sp.length()); |
| 1653 | path.trim_spaces(); |
| 1654 | butil::StringSplitter slash_sp( |
| 1655 | path.data(), path.data() + path.size(), '/'); |
| 1656 | if (slash_sp == NULL) { |
| 1657 | LOG(ERROR) << "Invalid http_url=" << *mp->http_url; |
| 1658 | break; |
| 1659 | } |
| 1660 | butil::StringPiece v_svc_name(slash_sp.field(), slash_sp.length()); |
| 1661 | const ServiceProperty* vsp = FindServicePropertyByName(v_svc_name); |
| 1662 | if (vsp == NULL) { |
| 1663 | if (_global_restful_map) { |
| 1664 | std::string path_str; |
| 1665 | path.CopyToString(&path_str); |
| 1666 | if (_global_restful_map->RemoveByPathString(path_str)) { |
| 1667 | continue; |
| 1668 | } |
| 1669 | } |
| 1670 | LOG(ERROR) << "Impossible: service=" << v_svc_name |
| 1671 | << " for restful_map does not exist"; |
| 1672 | break; |
| 1673 | } |
| 1674 | std::string path_str; |
| 1675 | path.CopyToString(&path_str); |
| 1676 | if (!vsp->restful_map->RemoveByPathString(path_str)) { |
| 1677 | LOG(ERROR) << "Fail to find path=" << path |
| 1678 | << " in restful_map of service=" << v_svc_name; |
| 1679 | } |
| 1680 | } |
| 1681 | delete mp->http_url; |
| 1682 | } |
| 1683 | |
| 1684 | if (mp->own_method_status) { |
| 1685 | delete mp->status; |
| 1686 | } |
| 1687 | _method_map.erase(md->full_name()); |
nothing calls this directly
no test coverage detected