Commit 7c06dae2 authored by wangyao02's avatar wangyao02

- Add get_sock_opt/set_sock_opt to Controller

parent b5f3ef1e
...@@ -1382,6 +1382,26 @@ x509_st* Controller::get_peer_certificate() const { ...@@ -1382,6 +1382,26 @@ x509_st* Controller::get_peer_certificate() const {
return s ? s->GetPeerCertificate() : NULL; return s ? s->GetPeerCertificate() : NULL;
} }
int Controller::get_sock_opt(int level, int optname, void* optval, socklen_t* optlen) {
Socket* s = _current_call.sending_sock.get();
if (s) {
return getsockopt(s->fd(), level, optname, optval, optlen);
} else {
LOG(WARNING) << "sock is null";
return EINVAL;
}
}
int Controller::set_sock_opt(int level, int optname, void* optval, socklen_t optlen) {
Socket* s = _current_call.sending_sock.get();
if (s) {
return setsockopt(s->fd(), level, optname, optval, optlen);
} else {
LOG(WARNING) << "sock is null";
return EINVAL;
}
}
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
typedef sig_t SignalHandler; typedef sig_t SignalHandler;
#else #else
......
...@@ -592,6 +592,9 @@ private: ...@@ -592,6 +592,9 @@ private:
void set_used_by_rpc() { add_flag(FLAGS_USED_BY_RPC); } void set_used_by_rpc() { add_flag(FLAGS_USED_BY_RPC); }
bool is_used_by_rpc() const { return has_flag(FLAGS_USED_BY_RPC); } bool is_used_by_rpc() const { return has_flag(FLAGS_USED_BY_RPC); }
// Get/set sock option. .e.g get vip info through ttm kernel module hook,
int get_sock_opt(int level, int optname, void* optval, socklen_t* optlen);
int set_sock_opt(int level, int optname, void* optval, socklen_t optlen);
private: private:
// NOTE: align and group fields to make Controller as compact as possible. // NOTE: align and group fields to make Controller as compact as possible.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment