just use INCOMING udp slots/sockets for jam detection.

this will highlight the slow nodes better.
This commit is contained in:
Matt Wells
2015-04-08 15:52:43 -06:00
parent 7fd4310106
commit 97d3b185c1
8 changed files with 29 additions and 14 deletions

@ -1833,7 +1833,7 @@ bool Hostdb::replaceHost ( int32_t origHostId, int32_t spareHostId ) {
oldHost->m_emailCode = 0;
oldHost->m_wasAlive = false;
oldHost->m_pingInfo.m_etryagains = 0;
oldHost->m_pingInfo.m_udpSlotsInUse = 0;
oldHost->m_pingInfo.m_udpSlotsInUseIncoming = 0;
oldHost->m_pingInfo.m_totalResends = 0;
oldHost->m_errorReplies = 0;
oldHost->m_dgramsTo = 0;

@ -106,7 +106,7 @@ class PingInfo {
int32_t m_totalResends;
int32_t m_etryagains;
int32_t m_udpSlotsInUse;
int32_t m_udpSlotsInUseIncoming;
int32_t m_tcpSocketsInUse;
int16_t m_currentSpiders;

@ -562,14 +562,15 @@ skipReplaceHost:
,h->m_pingInfo.m_currentSpiders
);
if ( format == FORMAT_HTML && h->m_pingInfo.m_udpSlotsInUse ) {
if ( format == FORMAT_HTML &&
h->m_pingInfo.m_udpSlotsInUseIncoming ) {
char *f1 = "";
char *f2 = "";
if ( h->m_pingInfo.m_udpSlotsInUse >= 200 ) {
if ( h->m_pingInfo.m_udpSlotsInUseIncoming >= 200 ) {
f1 = "<b>";
f2 = "</b>";
}
if ( h->m_pingInfo.m_udpSlotsInUse >= 400 ) {
if ( h->m_pingInfo.m_udpSlotsInUseIncoming >= 400 ) {
f1 = "<b><font color=red>";
f2 = "</font></b>";
}
@ -580,7 +581,7 @@ skipReplaceHost:
"%s"
"</span>"
,f1
,h->m_pingInfo.m_udpSlotsInUse
,h->m_pingInfo.m_udpSlotsInUseIncoming
,f2
);
}
@ -688,7 +689,7 @@ skipReplaceHost:
sb.safePrintf("\t\t<udpSlotsInUse>%"INT32""
"</udpSlotsInUse>\n",
h->m_pingInfo.m_udpSlotsInUse);
h->m_pingInfo.m_udpSlotsInUseIncoming);
sb.safePrintf("\t\t<tcpSocketsInUse>%"INT32""
"</tcpSocketsInUse>\n",
@ -800,7 +801,7 @@ skipReplaceHost:
sb.safePrintf("\t\t\"errorTryAgains\":%"INT32",\n",
h->m_pingInfo.m_etryagains);
sb.safePrintf("\t\t\"udpSlotsInUse\":%"INT32",\n",
h->m_pingInfo.m_udpSlotsInUse);
h->m_pingInfo.m_udpSlotsInUseIncoming);
sb.safePrintf("\t\t\"tcpSocketsInUse\":%"INT32",\n",
h->m_pingInfo.m_tcpSocketsInUse);

@ -4092,7 +4092,7 @@ bool printRedBox ( SafeBuf *mb , TcpSocket *sock , HttpRequest *hr ) {
for ( int32_t i = 1 ; i < g_hostdb.getNumHosts() ; i++ ) {
Host *h = &g_hostdb.m_hosts[i];
if ( g_hostdb.isDead( h ) ) continue;
if ( h->m_pingInfo.m_udpSlotsInUse >= 400 ) jammedHosts++;
if ( h->m_pingInfo.m_udpSlotsInUseIncoming>= 400)jammedHosts++;
}
if ( jammedHosts > 0 ) {
if ( adds ) mb->safePrintf("<br>");

@ -509,7 +509,7 @@ void PingServer::pingHost ( Host *h , uint32_t ip , uint16_t port ) {
pi->m_localHostTimeMS = gettimeofdayInMillisecondsLocal();
pi->m_udpSlotsInUse = g_udpServer.getNumUsedSlots();
pi->m_udpSlotsInUseIncoming = g_udpServer.getNumUsedSlotsIncoming();
pi->m_tcpSocketsInUse = g_httpServer.m_tcp.m_numUsed;

@ -267,6 +267,7 @@ bool UdpServer::init ( uint16_t port, UdpProtocol *proto, int32_t niceness,
log(LOG_DEBUG,"udp: Allocated %"INT32" bytes for table.",m_bufSize);
m_numUsedSlots = 0;
m_numUsedSlotsIncoming = 0;
// clear this
m_isShuttingDown = false;
// and this
@ -555,7 +556,7 @@ bool UdpServer::sendRequest ( char *msg ,
// . create a new slot to control the transmission of this request
// . should set g_errno on failure
UdpSlot *slot = getEmptyUdpSlot_ass ( key );
UdpSlot *slot = getEmptyUdpSlot_ass ( key , false );
if ( ! slot ) {
if ( flipped ) interruptsOn();
return log("udp: All %"INT32" slots are in use.",m_maxSlots);
@ -1615,7 +1616,7 @@ int32_t UdpServer::readSock_ass ( UdpSlot **slotPtr , int64_t now ) {
if ( getSlot )
// get a new UdpSlot
slot = getEmptyUdpSlot_ass ( key );
slot = getEmptyUdpSlot_ass ( key , true );
// return -1 on failure
if ( ! slot ) {
// return -1
@ -3283,7 +3284,7 @@ bool UdpServer::timeoutDeadHosts ( Host *h ) {
}
// verified that this is not interruptible
UdpSlot *UdpServer::getEmptyUdpSlot_ass ( key_t k ) {
UdpSlot *UdpServer::getEmptyUdpSlot_ass ( key_t k , bool incoming ) {
// turn em off
bool flipped = interruptsOff();
// tmp debug
@ -3329,6 +3330,11 @@ UdpSlot *UdpServer::getEmptyUdpSlot_ass ( key_t k ) {
// }
// count it
m_numUsedSlots++;
if ( incoming ) m_numUsedSlotsIncoming++;
slot->m_incoming = incoming;
// now store ptr in hash table
slot->m_key = k;
addKey ( k , slot );
@ -3436,6 +3442,9 @@ void UdpServer::freeUdpSlot_ass ( UdpSlot *slot ) {
removeFromCallbackLinkedList ( slot );
// discount it
m_numUsedSlots--;
if ( slot->m_incoming ) m_numUsedSlotsIncoming--;
// add to linked list of available slots
slot->m_next = m_head;
m_head = slot;

@ -170,6 +170,8 @@ class UdpServer {
// an estimation as well
//int32_t getNumUsedSlots () { return m_topUsedSlot + 1; };
int32_t getNumUsedSlots () { return m_numUsedSlots; };
int32_t getNumUsedSlotsIncoming () { return m_numUsedSlotsIncoming; };
// . when a request/msg of type "msgType" is received we call the
@ -414,7 +416,7 @@ class UdpServer {
int32_t m_maxSlots;
// routines
UdpSlot *getEmptyUdpSlot_ass ( key_t k );
UdpSlot *getEmptyUdpSlot_ass ( key_t k , bool incoming );
void freeUdpSlot_ass ( UdpSlot *slot );
void addKey ( key_t key , UdpSlot *ptr ) ;
@ -443,6 +445,7 @@ class UdpServer {
UdpSlot *m_tail3;
int32_t m_numUsedSlots;
int32_t m_numUsedSlotsIncoming;
// stats
public:

@ -435,6 +435,8 @@ class UdpSlot {
char m_maxResends;
char m_incoming;
// . for the hot udp server, we cannot call malloc in the sig handler
// so we set m_readBuf to this to read in int16_t requests
// . caller should pre-allocated m_readBuf when calling sendRequest()