remote file:line from decode errors

This commit is contained in:
Michael Davidsaver
2021-01-12 11:32:10 -08:00
parent 76764cf978
commit e9ce80880d
11 changed files with 39 additions and 25 deletions
+3 -1
View File
@@ -591,7 +591,9 @@ bool Context::Pvt::onSearch()
}
if(!M.good()) {
log_hex_printf(io, Level::Err, &searchMsg[0], nrx, "Invalid search reply %d from %s\n", nrx, src.tostring().c_str());
log_hex_printf(io, Level::Err, &searchMsg[0], nrx,
"%s:%d Invalid search reply %d from %s\n",
M.file(), M.line(), nrx, src.tostring().c_str());
}
return true;
+8 -4
View File
@@ -188,7 +188,8 @@ void Connection::handle_CONNECTION_VALIDATION()
}
if(!M.good()) {
log_err_printf(io, "Server %s sends invalid CONNECTION_VALIDATION. Disconnect...\n", peerName.c_str());
log_err_printf(io, "%s:%d Server %s sends invalid CONNECTION_VALIDATION. Disconnect...\n",
M.file(), M.line(), peerName.c_str());
bev.reset();
return;
}
@@ -255,7 +256,8 @@ void Connection::handle_CONNECTION_VALIDATED()
from_wire(M, sts);
if(!M.good()) {
log_crit_printf(io, "Server %s sends invalid CONNECTION_VALIDATED. Disconnecting...\n", peerName.c_str());
log_crit_printf(io, "%s:%d Server %s sends invalid CONNECTION_VALIDATED. Disconnecting...\n",
M.file(), M.line(), peerName.c_str());
bev.reset();
return;
@@ -285,7 +287,8 @@ void Connection::handle_CREATE_CHANNEL()
// "spec" calls for uint16_t Access Rights here, but pvAccessCPP don't include this (it's useless anyway)
if(!M.good()) {
log_crit_printf(io, "Server %s sends invalid CREATE_CHANNEL. Disconnecting...\n", peerName.c_str());
log_crit_printf(io, "%s:%d Server %s sends invalid CREATE_CHANNEL. Disconnecting...\n",
M.file(), M.line(), peerName.c_str());
bev.reset();
return;
}
@@ -350,7 +353,8 @@ void Connection::handle_DESTROY_CHANNEL()
from_wire(M, cid);
if(!M.good()) {
log_crit_printf(io, "Server %s sends invalid DESTROY_CHANNEL. Disconnecting...\n", peerName.c_str());
log_crit_printf(io, "%s:%d Server %s sends invalid DESTROY_CHANNEL. Disconnecting...\n",
M.file(), M.line(), peerName.c_str());
bev.reset();
return;
}
+2 -1
View File
@@ -353,7 +353,8 @@ void Connection::handle_GPR(pva_app_msg_t cmd)
}
if(!M.good() || !gpr) {
log_crit_printf(io, "Server %s sends invalid op%02x. Disconnecting...\n", peerName.c_str(), cmd);
log_crit_printf(io, "%s:%d Server %s sends invalid op%02x. Disconnecting...\n",
M.file(), M.line(), peerName.c_str(), cmd);
bev.reset();
return;
}
+2 -1
View File
@@ -122,7 +122,8 @@ void Connection::handle_GET_FIELD()
from_wire_type(M, rxRegistry, prototype);
if(!M.good()) {
log_crit_printf(io, "Server %s sends invalid GET_FIELD. Disconnecting...\n", peerName.c_str());
log_crit_printf(io, "%s:%d Server %s sends invalid GET_FIELD. Disconnecting...\n",
M.file(), M.line(), peerName.c_str());
bev.reset();
return;
}
+2 -1
View File
@@ -430,7 +430,8 @@ void Connection::handle_MONITOR()
}
if(!M.good() || !mon) {
log_crit_printf(io, "Server %s sends invalid MONITOR. Disconnecting...\n", peerName.c_str());
log_crit_printf(io, "%s:%d Server %s sends invalid MONITOR. Disconnecting...\n",
M.file(), M.line(), peerName.c_str());
bev.reset();
return;
}
+2
View File
@@ -58,6 +58,8 @@ public:
errline = lineno;
}
EPICS_ALWAYS_INLINE bool good() const { return !err; }
inline const char* file() const { return err ? err : "(null)"; }
EPICS_ALWAYS_INLINE int line() const { return errline; }
// ensure (be resize/refill) that size()>=i
inline bool ensure(size_t i) {
+6 -4
View File
@@ -221,7 +221,7 @@ void ServerConn::handle_SEARCH()
}
if(!M.good())
throw std::runtime_error("TCP Search decode error");
throw std::runtime_error(SB()<<M.file()<<':'<<M.line()<<" TCP Search decode error");
{
auto G(iface->server->sourcesLock.lockReader());
@@ -349,7 +349,8 @@ void ServerConn::handle_CREATE_CHANNEL()
// "spec" calls for uint16_t Access Rights here, but pvAccessCPP don't include this (it's useless anyway)
if(!R.good()) {
M.fault(__FILE__, __LINE__);
log_err_printf(connio, "Client %s Encode error in CreateChan\n", peerName.c_str());
log_err_printf(connio, "%s:%d Client %s Encode error in CreateChan\n",
M.file(), M.line(), peerName.c_str());
break;
}
}
@@ -358,7 +359,8 @@ void ServerConn::handle_CREATE_CHANNEL()
}
if(!M.good()) {
log_err_printf(connio, "Client %s Decode error in CreateChan\n", peerName.c_str());
log_err_printf(connio, "%s:%d Client %s Decode error in CreateChan\n",
M.file(), M.line(), peerName.c_str());
bev.reset();
}
}
@@ -372,7 +374,7 @@ void ServerConn::handle_DESTROY_CHANNEL()
from_wire(M, sid);
from_wire(M, cid);
if(!M.good())
throw std::runtime_error("Decode error in DestroyChan");
throw std::runtime_error(SB()<<M.file()<<':'<<M.line()<<" Decode error in DestroyChan");
auto it = chanBySID.find(sid);
if(it==chanBySID.end()) {
+5 -4
View File
@@ -135,7 +135,8 @@ void ServerConn::handle_CONNECTION_VALIDATION()
from_wire_type_value(M, rxRegistry, auth);
if(!M.good()) {
log_err_printf(connio, "Client %s Truncated/Invalid ConnValid from client\n", peerName.c_str());
log_err_printf(connio, "%s:%d Client %s Truncated/Invalid ConnValid from client\n",
M.file(), M.line(), peerName.c_str());
bev.reset();
return;
@@ -181,7 +182,7 @@ void ServerConn::handle_CANCEL_REQUEST()
from_wire(M, sid);
from_wire(M, ioid);
if(!M.good())
throw std::runtime_error("Error decoding DestroyOp");
throw std::runtime_error(SB()<<M.file()<<':'<<M.line()<<" Error decoding DestroyOp");
auto it = opByIOID.find(ioid);
if(it==opByIOID.end()) {
@@ -216,7 +217,7 @@ void ServerConn::handle_DESTROY_REQUEST()
from_wire(M, sid);
from_wire(M, ioid);
if(!M.good())
throw std::runtime_error("Error decoding DestroyOp");
throw std::runtime_error(SB()<<M.file()<<':'<<M.line()<<" Error decoding DestroyOp");
auto& chan = lookupSID(sid);
auto it = opByIOID.find(ioid);
@@ -250,7 +251,7 @@ void ServerConn::handle_MESSAGE()
from_wire(M, msg);
if(!M.good())
throw std::runtime_error("Decode error for Message");
throw std::runtime_error(SB()<<M.file()<<':'<<M.line()<<" Decode error for Message");
auto it = opByIOID.find(ioid);
if(it==opByIOID.end()) {
+4 -4
View File
@@ -382,8 +382,8 @@ void ServerConn::handle_GPR(pva_app_msg_t cmd)
from_wire_type_value(M, rxRegistry, pvRequest);
if(!M.good()) {
log_debug_printf(connio, "Client %s\n Invalid op=%x/%x INIT\n",
peerName.c_str(), cmd, subcmd);
log_debug_printf(connio, "%s:%d Client %s\n Invalid op=%x/%x INIT\n",
M.file(), M.line(), peerName.c_str(), cmd, subcmd);
bev.reset();
return;
}
@@ -462,8 +462,8 @@ void ServerConn::handle_GPR(pva_app_msg_t cmd)
}
if(!M.good()) {
log_debug_printf(connio, "Client %s\n Invalid op=%x/%x Get\n",
peerName.c_str(), cmd, subcmd);
log_debug_printf(connio, "%s:%d Client %s\n Invalid op=%x/%x Get\n",
M.file(), M.line(), peerName.c_str(), cmd, subcmd);
bev.reset();
return;
}
+1 -1
View File
@@ -150,7 +150,7 @@ void ServerConn::handle_GET_FIELD()
from_wire(M, ioid);
from_wire(M, subfield);
if(!M.good())
throw std::runtime_error("Error decoding Introspect");
throw std::runtime_error(SB()<<M.file()<<':'<<M.line()<<" Error decoding Introspect");
auto& chan = lookupSID(sid);
+4 -4
View File
@@ -464,8 +464,8 @@ void ServerConn::handle_MONITOR()
}
if(!M.good()) {
log_debug_printf(connio, "Client %s\n Invalid MONITOR/%x INIT\n",
peerName.c_str(), subcmd);
log_debug_printf(connio, "%s:%d Client %s\n Invalid MONITOR/%x INIT\n",
M.file(), M.line(), peerName.c_str(), subcmd);
bev.reset();
return;
}
@@ -515,8 +515,8 @@ void ServerConn::handle_MONITOR()
}
if(!M.good()) {
log_debug_printf(connio, "Client %s\n Invalid MONITOR/%x CMD\n",
peerName.c_str(), subcmd);
log_debug_printf(connio, "%s:%d Client %s\n Invalid MONITOR/%x CMD\n",
M.file(), M.line(), peerName.c_str(), subcmd);
bev.reset();
return;
}