mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
DRY TCP_KEEPALIVE
This commit is contained in:
parent
eda019b9ac
commit
9a51a64764
@ -1051,6 +1051,21 @@ class Minion(MinionBase):
|
||||
}
|
||||
})
|
||||
|
||||
def _set_tcp_keepalive(self):
|
||||
if hasattr(zmq, 'TCP_KEEPALIVE'):
|
||||
self.socket.setsockopt(
|
||||
zmq.TCP_KEEPALIVE, self.opts['tcp_keepalive']
|
||||
)
|
||||
self.socket.setsockopt(
|
||||
zmq.TCP_KEEPALIVE_IDLE, self.opts['tcp_keepalive_idle']
|
||||
)
|
||||
self.socket.setsockopt(
|
||||
zmq.TCP_KEEPALIVE_CNT, self.opts['tcp_keepalive_cnt']
|
||||
)
|
||||
self.socket.setsockopt(
|
||||
zmq.TCP_KEEPALIVE_INTVL, self.opts['tcp_keepalive_intvl']
|
||||
)
|
||||
|
||||
@property
|
||||
def master_pub(self):
|
||||
'''
|
||||
@ -1198,19 +1213,7 @@ class Minion(MinionBase):
|
||||
# IPv6 sockets work for both IPv6 and IPv4 addresses
|
||||
self.socket.setsockopt(zmq.IPV4ONLY, 0)
|
||||
|
||||
if hasattr(zmq, 'TCP_KEEPALIVE'):
|
||||
self.socket.setsockopt(
|
||||
zmq.TCP_KEEPALIVE, self.opts['tcp_keepalive']
|
||||
)
|
||||
self.socket.setsockopt(
|
||||
zmq.TCP_KEEPALIVE_IDLE, self.opts['tcp_keepalive_idle']
|
||||
)
|
||||
self.socket.setsockopt(
|
||||
zmq.TCP_KEEPALIVE_CNT, self.opts['tcp_keepalive_cnt']
|
||||
)
|
||||
self.socket.setsockopt(
|
||||
zmq.TCP_KEEPALIVE_INTVL, self.opts['tcp_keepalive_intvl']
|
||||
)
|
||||
self._set_tcp_keepalive()
|
||||
self.socket.connect(self.master_pub)
|
||||
self.poller.register(self.socket, zmq.POLLIN)
|
||||
self.poller.register(self.epull_sock, zmq.POLLIN)
|
||||
@ -1344,19 +1347,7 @@ class Minion(MinionBase):
|
||||
self.socket.setsockopt(
|
||||
zmq.RECONNECT_IVL_MAX, self.opts['recon_max']
|
||||
)
|
||||
if hasattr(zmq, 'TCP_KEEPALIVE'):
|
||||
self.socket.setsockopt(
|
||||
zmq.TCP_KEEPALIVE, self.opts['tcp_keepalive']
|
||||
)
|
||||
self.socket.setsockopt(
|
||||
zmq.TCP_KEEPALIVE_IDLE, self.opts['tcp_keepalive_idle']
|
||||
)
|
||||
self.socket.setsockopt(
|
||||
zmq.TCP_KEEPALIVE_CNT, self.opts['tcp_keepalive_cnt']
|
||||
)
|
||||
self.socket.setsockopt(
|
||||
zmq.TCP_KEEPALIVE_INTVL, self.opts['tcp_keepalive_intvl']
|
||||
)
|
||||
self._set_tcp_keepalive()
|
||||
self.socket.connect(self.master_pub)
|
||||
self.poller.register(self.socket, zmq.POLLIN)
|
||||
# Send an event to the master that the minion is live
|
||||
|
Loading…
Reference in New Issue
Block a user