-
Notifications
You must be signed in to change notification settings - Fork 213
/
Copy pathlisten.patch
49 lines (45 loc) · 2.06 KB
/
listen.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
diff -uraN a/tensorflow_serving/util/net_http/server/internal/evhttp_server.cc b/tensorflow_serving/util/net_http/server/internal/evhttp_server.cc
--- a/tensorflow_serving/util/net_http/server/internal/evhttp_server.cc 2020-10-22 08:44:39.000000000 +0000
+++ b/tensorflow_serving/util/net_http/server/internal/evhttp_server.cc 2020-10-23 09:54:03.911295393 +0000
@@ -215,13 +215,14 @@
}
const int port = server_options_->ports().front();
+ const std::string address = server_options_->address();
// "::" => in6addr_any
ev_uint16_t ev_port = static_cast<ev_uint16_t>(port);
- ev_listener_ = evhttp_bind_socket_with_handle(ev_http_, "::", ev_port);
+ ev_listener_ = evhttp_bind_socket_with_handle(ev_http_, address.c_str(), ev_port);
if (ev_listener_ == nullptr) {
// in case ipv6 is not supported, fallback to inaddr_any
- ev_listener_ = evhttp_bind_socket_with_handle(ev_http_, nullptr, ev_port);
+ ev_listener_ = evhttp_bind_socket_with_handle(ev_http_, address.c_str(), ev_port);
if (ev_listener_ == nullptr) {
NET_LOG(ERROR, "Couldn't bind to port %d", port);
return false;
diff -uraN a/tensorflow_serving/util/net_http/server/public/httpserver_interface.h b/tensorflow_serving/util/net_http/server/public/httpserver_interface.h
--- a/tensorflow_serving/util/net_http/server/public/httpserver_interface.h 2020-10-22 08:44:39.000000000 +0000
+++ b/tensorflow_serving/util/net_http/server/public/httpserver_interface.h 2020-10-23 10:25:10.170275251 +0000
@@ -61,6 +61,17 @@
ports_.emplace_back(port);
}
+ void SetAddress(const std::string& address) {
+ address_ = address;
+ }
+
+ std::string address() {
+ if(address_ == "") {
+ return "0.0.0.0";
+ }
+ return address_;
+ }
+
// The default executor for running I/O event polling.
// This is a mandatory option.
void SetExecutor(std::unique_ptr<EventExecutor> executor) {
@@ -74,6 +85,7 @@
private:
std::vector<int> ports_;
std::unique_ptr<EventExecutor> executor_;
+ std::string address_;
};
// Options to specify when registering a handler (given a uri pattern).