MXS-1951: Add SO_REUSEPORT support
If SO_REUSEPORT is available and the kernel supports it, listeners will now listen on separate file descriptors. This removes the need for cross-worker communication when in normal operation which should make MaxScale scale better.
This commit is contained in:
@ -41,6 +41,13 @@ public:
|
||||
|
||||
~Listener();
|
||||
|
||||
enum class Type
|
||||
{
|
||||
UNIX_SOCKET, // UNIX domain socket shared between workers
|
||||
SHARED_TCP, // TCP listening socket shared between workers
|
||||
UNIQUE_TCP // Unique TCP listening socket for each worker
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new listener
|
||||
*
|
||||
@ -173,6 +180,11 @@ public:
|
||||
*/
|
||||
void print_users(DCB* dcb);
|
||||
|
||||
Type type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
// Functions that are temporarily public
|
||||
bool create_listener_config(const char* filename);
|
||||
struct users* users() const;
|
||||
@ -203,6 +215,8 @@ private:
|
||||
MXS_PROTOCOL m_proto_func; /**< Preloaded protocol functions */
|
||||
MXS_AUTHENTICATOR m_auth_func; /**< Preloaded authenticator functions */
|
||||
|
||||
Type m_type; /**< The type of the listener */
|
||||
|
||||
mxs::rworker_local<int> m_fd {-1}; /**< File descriptor the listener listens on */
|
||||
|
||||
/** A shared pointer to the listener itself that is passed as the argument to
|
||||
@ -242,6 +256,13 @@ private:
|
||||
*/
|
||||
bool listen_shared();
|
||||
|
||||
/**
|
||||
* Listen with a unique file descriptor for each worker
|
||||
*
|
||||
* @return True if the listening was started successfully
|
||||
*/
|
||||
bool listen_unique();
|
||||
|
||||
/**
|
||||
* Close all opened file descriptors for this listener
|
||||
*/
|
||||
|
Reference in New Issue
Block a user