aboutsummaryrefslogtreecommitdiff
path: root/src/connections.cc
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-10-06 19:41:32 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-10-06 19:41:32 -0300
commitf3c2d53f1837a7bd8e9e1517579b7354af91ef8c (patch)
treeabc2c97032e96e6fef0470db853dbf47b0efe00b /src/connections.cc
parentfa22d10a9d132ff509cb4b40ced1c6d1c0e98167 (diff)
downloadquerymanager-f3c2d53f1837a7bd8e9e1517579b7354af91ef8c.tar.gz
querymanager-f3c2d53f1837a7bd8e9e1517579b7354af91ef8c.zip
sketch out new query queue/worker for async queries
Diffstat (limited to 'src/connections.cc')
-rw-r--r--src/connections.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/connections.cc b/src/connections.cc
index 3c92a51..26630cc 100644
--- a/src/connections.cc
+++ b/src/connections.cc
@@ -88,7 +88,7 @@ int ListenerAccept(int Listener, uint32 *OutAddr, uint16 *OutPort){
uint32 Addr = ntohl(SocketAddr.sin_addr.s_addr);
uint16 Port = ntohs(SocketAddr.sin_port);
if(Addr != INADDR_LOOPBACK){
- LOG_ERR("Rejecting remote connection from %08X:%d.", Addr, Port);
+ LOG_ERR("Rejecting remote connection from %08X:%d", Addr, Port);
close(Socket);
continue;
}
@@ -220,7 +220,7 @@ void CheckConnectionInput(TConnection *Connection, int Events){
Connection->RWPosition += BytesRead;
if(Connection->RWPosition >= ReadSize){
if(Connection->RWSize != 0){
- Connection->State = CONNECTION_PROCESSING;
+ Connection->State = CONNECTION_PENDING_QUERY;
Connection->LastActive = g_MonotonicTimeMS;
break;
}else if(Connection->RWPosition == 2){
@@ -249,9 +249,15 @@ void CheckConnectionInput(TConnection *Connection, int Events){
}
}
}
+}
- if(Connection->State == CONNECTION_PROCESSING){
- ProcessConnectionQuery(Connection);
+void CheckConnectionQuery(TConnection *Connection){
+ if(Connection->State == CONNECTION_PENDING_QUERY){
+ //ProcessConnectionQuery(Connection);
+ }else if(Connection->State == CONNECTION_PROCESSING_QUERY
+ && QueryRefCount(Connection->Query) == 1){
+ //
+ //Connection->State = CONNECTION_WRITING;
}
}
@@ -355,6 +361,7 @@ void ProcessConnections(void){
TConnection *Connection = &g_Connections[ConnectionIndices[i]];
int Events = (int)ConnectionFds[i].revents;
CheckConnectionInput(Connection, Events);
+ CheckConnectionQuery(Connection);
CheckConnectionOutput(Connection, Events);
CheckConnection(Connection, Events);
}
@@ -419,7 +426,7 @@ void CompoundBanishment(TBanishmentStatus Status, int *Days, bool *FinalWarning)
}
TWriteBuffer PrepareResponse(TConnection *Connection, int Status){
- if(Connection->State != CONNECTION_PROCESSING){
+ if(Connection->State != CONNECTION_PROCESSING_QUERY){
LOG_ERR("Connection %s is not processing query (State: %d)",
Connection->RemoteAddress, Connection->State);
CloseConnection(Connection);
@@ -433,7 +440,7 @@ TWriteBuffer PrepareResponse(TConnection *Connection, int Status){
}
void SendResponse(TConnection *Connection, TWriteBuffer *WriteBuffer){
- if(Connection->State != CONNECTION_PROCESSING){
+ if(Connection->State != CONNECTION_PROCESSING_QUERY){
LOG_ERR("Connection %s is not processing query (State: %d)",
Connection->RemoteAddress, Connection->State);
CloseConnection(Connection);
@@ -2068,7 +2075,7 @@ void ProcessConnectionQuery(TConnection *Connection){
// the disk.
TReadBuffer Buffer(Connection->Buffer, Connection->RWSize);
- uint8 Query = Buffer.Read8();
+ int Query = Buffer.Read8();
if(!Connection->Authorized){
if(Query == QUERY_LOGIN){
ProcessLoginQuery(Connection, &Buffer);