Compare function for two NetworkAddressPB. The order is decided first by hostname, then by port, then by uds address.
| 114 | /// Compare function for two NetworkAddressPB. |
| 115 | /// The order is decided first by hostname, then by port, then by uds address. |
| 116 | inline int CompareNetworkAddressPB( |
| 117 | const NetworkAddressPB& lhs, const NetworkAddressPB& rhs) { |
| 118 | int comp = lhs.hostname().compare(rhs.hostname()); |
| 119 | if (comp == 0) comp = lhs.port() - rhs.port(); |
| 120 | if (comp == 0) { |
| 121 | if (lhs.has_uds_address()) { |
| 122 | if (rhs.has_uds_address()) { |
| 123 | comp = lhs.uds_address().compare(rhs.uds_address()); |
| 124 | } else { |
| 125 | comp = 1; // lhs preceed rhs |
| 126 | } |
| 127 | } else if (rhs.has_uds_address()) { |
| 128 | comp = -1; // rhs preceed lhs |
| 129 | } |
| 130 | } |
| 131 | return comp; |
| 132 | } |
| 133 | |
| 134 | /// Return true if two NetworkAddressPB are match. |
| 135 | inline bool KrpcAddressEqual(const NetworkAddressPB& lhs, const NetworkAddressPB& rhs) { |