24#ifndef SEMISYNC_SOURCE_SOCKET_LISTENER
25#define SEMISYNC_SOURCE_SOCKET_LISTENER
44 m_fds[index].events = 0;
50 for (uint i = 0; i < slaves.size(); i++) {
60 poll_fd.fd = slaves[i].sock_fd();
81class Select_socket_listener {
85 bool listen_on_sockets() {
88 struct timeval tv = {1, 0};
90 return select(m_max_fd + 1, &m_fds,
nullptr,
nullptr, &tv);
93 bool is_socket_active(
int index) {
94 return FD_ISSET(m_slaves[index].sock_fd(), &m_fds);
97 void clear_socket_info(
int index) {
98 FD_CLR(m_slaves[index].sock_fd(), &m_init_fds);
103 FD_ZERO(&m_init_fds);
104 for (uint i = 0; i < slaves.size(); i++) {
113 my_socket socket_id = slaves[i].sock_fd();
114 m_max_fd = (socket_id > m_max_fd ? socket_id : m_max_fd);
122 FD_SET(socket_id, &m_init_fds);
123 m_slaves.push_back(slaves[i]);
127 uint number_of_slave_sockets() {
return m_slaves.size(); }
129 Slave get_slave_obj(
int index) {
return m_slaves[index]; }
Definition: semisync_source_socket_listener.h:32
Poll_socket_listener()=default
std::vector< pollfd > m_fds
Definition: semisync_source_socket_listener.h:74
Slave get_slave_obj(int index)
Definition: semisync_source_socket_listener.h:70
uint number_of_slave_sockets()
Definition: semisync_source_socket_listener.h:68
Slave_vector m_slaves
Definition: semisync_source_socket_listener.h:73
bool is_socket_active(int index)
Definition: semisync_source_socket_listener.h:40
bool init_replica_sockets(Slave_vector &slaves)
Definition: semisync_source_socket_listener.h:47
void clear_socket_info(int index)
Definition: semisync_source_socket_listener.h:42
bool listen_on_sockets()
Definition: semisync_source_socket_listener.h:36
#define LogErr(severity, ecode,...)
Definition: log_builtins.h:843
#define INVALID_SOCKET
Definition: my_io.h:190
@ ERROR_LEVEL
Definition: my_loglevel.h:43
int my_socket
Definition: mysql.h:65
pollfd poll_fd
Definition: poll.h:50
stdx::expected< size_t, std::error_code > poll(poll_fd *fds, size_t num_fds, std::chrono::milliseconds timeout)
Definition: poll.h:53
std::vector< Slave > Slave_vector
Definition: semisync_source_ack_receiver.h:48
class Poll_socket_listener Socket_listener
Definition: semisync_source_socket_listener.h:77
#define FD_SETSIZE
Utility functions to check if a network address or name matches an interface on the machine we are ru...
Definition: sock_probe_win32.h:34
Definition: semisync_source_ack_receiver.h:37
struct pollfd pollfd
Definition: task_os.h:114