aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common.cc2
-rw-r--r--src/connections.cc4
-rw-r--r--src/login.hh2
-rw-r--r--src/query.cc6
4 files changed, 8 insertions, 6 deletions
diff --git a/src/common.cc b/src/common.cc
index 2a40df2..c4786e2 100644
--- a/src/common.cc
+++ b/src/common.cc
@@ -13,6 +13,7 @@ void LogAdd(const char *Prefix, const char *Format, ...){
LocalTime.tm_year + 1900, LocalTime.tm_mon + 1, LocalTime.tm_mday,
LocalTime.tm_hour, LocalTime.tm_min, LocalTime.tm_sec,
Prefix, Entry);
+ fflush(stdout);
}
}
@@ -32,6 +33,7 @@ void LogAddVerbose(const char *Prefix, const char *Function,
LocalTime.tm_year + 1900, LocalTime.tm_mon + 1, LocalTime.tm_mday,
LocalTime.tm_hour, LocalTime.tm_min, LocalTime.tm_sec,
Prefix, Function, Entry);
+ fflush(stdout);
}
}
diff --git a/src/connections.cc b/src/connections.cc
index 5fd885f..ac5d4ca 100644
--- a/src/connections.cc
+++ b/src/connections.cc
@@ -265,8 +265,8 @@ void ProcessConnections(void){
}
if(AssignConnection(Socket, Addr, Port) == NULL){
- LOG_ERR("Rejecting connection from %08X due to max number of"
- " connections being reached (%d)", Addr, g_MaxConnections);
+ LOG_ERR("Rejecting connection from %08X:%d due to max number of"
+ " connections being reached (%d)", Addr, Port, g_MaxConnections);
close(Socket);
}
}
diff --git a/src/login.hh b/src/login.hh
index 99c8ceb..aa391a1 100644
--- a/src/login.hh
+++ b/src/login.hh
@@ -290,7 +290,7 @@ struct TWriteBuffer{
}
void Rewrite16(int Position, uint16 Value){
- if((Position + 2) <= this->Position){
+ if((Position + 2) <= this->Position && !this->Overflowed()){
BufferWrite16LE(this->Buffer + Position, Value);
}
}
diff --git a/src/query.cc b/src/query.cc
index 1335631..21d44ec 100644
--- a/src/query.cc
+++ b/src/query.cc
@@ -147,7 +147,7 @@ int ExecuteQuery(TQueryManagerConnection *Connection, bool AutoReconnect,
}
const int MaxAttempts = 2;
- for(int Attempts = 0; true; Attempts += 1){
+ for(int Attempt = 1; true; Attempt += 1){
int WriteSize = WriteBuffer->Position;
if(!IsConnected(Connection)){
if(!AutoReconnect){
@@ -173,7 +173,7 @@ int ExecuteQuery(TQueryManagerConnection *Connection, bool AutoReconnect,
if(!WriteExact(Connection->Socket, Connection->Buffer, WriteSize)){
Disconnect(Connection);
- if(Attempts >= MaxAttempts){
+ if(Attempt >= MaxAttempts){
LOG_ERR("Failed to write request");
return QUERY_STATUS_FAILED;
}
@@ -183,7 +183,7 @@ int ExecuteQuery(TQueryManagerConnection *Connection, bool AutoReconnect,
uint8 Help[4];
if(!ReadExact(Connection->Socket, Help, 2)){
Disconnect(Connection);
- if(Attempts >= MaxAttempts){
+ if(Attempt >= MaxAttempts){
LOG_ERR("Failed to read response size");
return QUERY_STATUS_FAILED;
}