Changeset 1505

Show
Ignore:
Timestamp:
02/01/10 22:54:44 (6 weeks ago)
Author:
ahu
Message:

implement explicit (configurable) limit to number of mthreads - we are usually implicitly limited, this is no change of behaviour for almost all setups

Location:
trunk/pdns/pdns
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/pdns_recursor.cc

    r1504 r1505  
    107107tcpListenSockets_t g_tcpListenSockets;   // shared across threads, but this is fine, never written to from a thread. All threads listen on all sockets 
    108108int g_tcpTimeout; 
     109unsigned int g_maxMThreads; 
    109110struct timeval g_now; // timestamp, updated (too) frequently 
    110111map<int, ComboAddress> g_listenSocketsAddresses; // is shared across all threads right now 
     
    750751  int newsock=(int)accept(fd, (struct sockaddr*)&addr, &addrlen); 
    751752  if(newsock>0) { 
     753    if(MT->numProcesses() > g_maxMThreads) { 
     754      g_stats.overCapacityDrops++; 
     755      Utility::closesocket(newsock); 
     756      return; 
     757    } 
     758 
    752759    g_stats.addRemote(addr); 
    753760    if(t_allowFrom && !t_allowFrom->match(&addr)) { 
     
    788795  socklen_t addrlen=sizeof(fromaddr); 
    789796 
     797   
    790798  if((len=recvfrom(fd, data, sizeof(data), 0, (sockaddr *)&fromaddr, &addrlen)) >= 0) { 
     799 
    791800    g_stats.addRemote(fromaddr); 
    792801 
     
    825834          throw MOADNSException(e.what()); // translate 
    826835        } 
     836        if(MT->numProcesses() > g_maxMThreads) { 
     837          g_stats.overCapacityDrops++; 
     838          return; 
     839        } 
     840   
    827841        DNSComboWriter* dc = new DNSComboWriter(data, len, g_now); 
    828842        dc->setSocket(fd); 
     
    15291543  L<<Logger::Warning<<"Operating in "<<(sizeof(unsigned long)*8) <<" bits mode"<<endl; 
    15301544   
     1545  #if 0 
     1546  unsigned int maxFDs, curFDs; 
     1547  getFDLimits(curFDs, maxFDs); 
     1548  if(curFDs < 2048)  
     1549    L<<Logger::Warning<<"Only "<<curFDs<<" file descriptors available (out of: "<<maxFDs<<"), may not be suitable for high performance"<<endl; 
     1550  #endif 
     1551   
    15311552  seedRandom(::arg()["entropy-source"]); 
    15321553 
     
    16321653  g_tcpTimeout=::arg().asNum("client-tcp-timeout"); 
    16331654  g_maxTCPPerClient=::arg().asNum("max-tcp-per-client"); 
     1655  g_maxMThreads=::arg().asNum("max-mthreads"); 
    16341656   
    16351657  int numThreads = ::arg().asNum("threads"); 
     
    18551877    ::arg().set("query-local-address6","Source IPv6 address for sending queries")=""; 
    18561878    ::arg().set("client-tcp-timeout","Timeout in seconds when talking to TCP clients")="2"; 
     1879    ::arg().set("max-mthreads", "Maximum number of simultaneous Mtasker threads")="2048"; 
    18571880    ::arg().set("max-tcp-clients","Maximum number of simultaneous TCP clients")="128"; 
    18581881    ::arg().set("hint-file", "If set, load root hints from this file")=""; 
  • trunk/pdns/pdns/syncres.hh

    r1496 r1505  
    472472  uint64_t spoofCount; 
    473473  uint64_t resourceLimits; 
     474  uint64_t overCapacityDrops; 
    474475  uint64_t ipv6queries; 
    475476  uint64_t chainResends;