MXS-1220: Simplify admin request handling
The admin requests are now processed in blocking mode. The timing out of connecttions is handled by a specific timeout thread that checks the state of each admin request. The simplification will help with the JSON parsing with PUT/POST commands. If non-blocking IO is used, the network reading code and JSON parsing needs a lot more work to handle partial reads. If the administrative interface requires higher performance and concurrency, a multi-threaded solution could be created.
This commit is contained in:
committed by
Markus Mäkelä
parent
439d67d129
commit
e34b65658e
@ -17,6 +17,12 @@
|
||||
|
||||
#include <map>
|
||||
#include <sys/socket.h>
|
||||
#include <tr1/memory>
|
||||
|
||||
#include <maxscale/atomic.h>
|
||||
#include <maxscale/spinlock.hh>
|
||||
|
||||
using mxs::SpinLock;
|
||||
|
||||
class AdminClient
|
||||
{
|
||||
@ -33,12 +39,30 @@ public:
|
||||
~AdminClient();
|
||||
|
||||
/**
|
||||
* Process one request
|
||||
* @brief Process one request
|
||||
*/
|
||||
void process();
|
||||
|
||||
/**
|
||||
* @brief Close the connection
|
||||
*/
|
||||
void close_connection();
|
||||
|
||||
/**
|
||||
* @brief Get last activity timestamp
|
||||
*
|
||||
* @return The hkheartbeat of the last activity
|
||||
*/
|
||||
int64_t last_activity()
|
||||
{
|
||||
return atomic_read_int64(&m_last_activity);
|
||||
}
|
||||
|
||||
private:
|
||||
int m_fd; /**< The client socket */
|
||||
int m_timeout; /**< Network timeout for reads and writes */
|
||||
int64_t m_last_activity;
|
||||
struct sockaddr_storage m_addr; /**< Network info for the client */
|
||||
SpinLock m_lock;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<AdminClient> SAdminClient;
|
||||
|
||||
Reference in New Issue
Block a user