Changeset 699
- Timestamp:
- 04/14/06 13:26:50 (4 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 8 modified
-
dnsparser.cc (modified) (1 diff)
-
dnspbench.cc (modified) (2 diffs)
-
dnswriter.cc (modified) (1 diff)
-
mtasker.cc (modified) (3 diffs)
-
mtasker.hh (modified) (5 diffs)
-
pdns_recursor.cc (modified) (3 diffs)
-
rcpgenerator.cc (modified) (1 diff)
-
syncres.hh (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/dnsparser.cc
r683 r699 379 379 } 380 380 else { 381 // should check for . here and replace by \. 381 382 ret.append(&content.at(frompos), &content.at(frompos+labellen)); 382 383 ret.append(1,'.'); -
trunk/pdns/pdns/dnspbench.cc
r680 r699 45 45 reportAllTypes(); 46 46 47 #if 048 47 Socket s(InterNetwork, Datagram); 48 49 IPEndpoint rem("127.0.0.1",1232), loc("213.156.2.1", 53); 50 s.bind(loc); 49 51 50 52 vector<uint8_t> vpacket; 51 string domain=" www.ds9a.nl";53 string domain="ds9a.nl"; 52 54 uint16_t type=1; 53 55 54 for(unsigned int n=0; n < 1000000; ++n) {56 for(unsigned int n=0; n < 65536; ++n) { 55 57 DNSPacketWriter pw(vpacket, domain, type); 56 58 57 59 pw.getHeader()->rd=1; 60 pw.getHeader()->qr=1; 58 61 pw.getHeader()->id=n; 62 ARecordContent arc("1.2.3.4"); 63 pw.startRecord("ds9a.nl", 1, 9999, 1, DNSPacketWriter::ANSWER); 64 arc.toPacket(pw); 59 65 pw.commit(); 60 IPEndpoint rem("127.0.0.1",5300); 66 61 67 string spacket((char*)(&*vpacket.begin()), vpacket.size()); 62 68 s.sendTo(spacket, rem); 63 69 } 64 70 65 66 71 return 0; 67 # endif72 #if 0 68 73 69 74 vector<uint8_t> packet; … … 83 88 shared_ptr<DNSRecordContent> regen=DNSRecordContent::unserialize(argv[1], type, record); 84 89 cerr<<"Out: "<<argv[1]<<" IN "<<argv[2]<<" "<<regen->getZoneRepresentation()<<endl; 90 #endif 85 91 } 86 92 catch(exception& e) -
trunk/pdns/pdns/dnswriter.cc
r690 r699 124 124 typedef vector<pair<unsigned int, unsigned int> > parts_t; 125 125 parts_t parts; 126 vstringtok(parts, label, "."); 126 vstringtok(parts, label, "."); // XXX FIXME this should deal with escaped . 127 127 128 128 // d_stuff is amount of stuff that is yet to be written out - the dnsrecordheader for example -
trunk/pdns/pdns/mtasker.cc
r695 r699 159 159 */ 160 160 161 template<class EventKey, class EventVal>int MTasker<EventKey,EventVal>::waitEvent( constEventKey &key, EventVal *val, unsigned int timeout)161 template<class EventKey, class EventVal>int MTasker<EventKey,EventVal>::waitEvent(EventKey &key, EventVal *val, unsigned int timeout) 162 162 { 163 163 if(d_waiters.count(key)) { // there was already an exact same waiter … … 181 181 *val=d_waitval; 182 182 d_tid=w.tid; 183 key=d_eventkey; 183 184 return d_waitstatus; 184 185 } … … 217 218 ucontext_t *userspace=waiter->context; 218 219 d_tid=waiter->tid; // set tid 219 220 d_eventkey=waiter->key; // pass waitEvent the exact key it was woken for 220 221 d_waiters.erase(waiter); // removes the waitpoint 221 222 if(swapcontext(&d_kernel,userspace)) { // swaps back to the above point 'A' -
trunk/pdns/pdns/mtasker.hh
r681 r699 51 51 std::queue<int> d_zombiesQueue; 52 52 53 54 typedef std::map<int, ucontext_t*> mthreads_t; 55 mthreads_t d_threads; 56 int d_tid; 57 int d_maxtid; 58 size_t d_stacksize; 59 60 EventVal d_waitval; 61 enum {Error=-1,TimeOut=0,Answer} d_waitstatus; 62 63 public: 53 64 struct Waiter 54 65 { … … 58 69 int tid; 59 70 }; 60 61 // typedef std::map<EventKey,Waiter> waiters_t;62 71 63 72 typedef multi_index_container< … … 71 80 waiters_t d_waiters; 72 81 73 typedef std::map<int, ucontext_t*> mthreads_t;74 mthreads_t d_threads;75 int d_tid;76 int d_maxtid;77 size_t d_stacksize;78 79 EventVal d_waitval;80 enum {Error=-1,TimeOut=0,Answer} d_waitstatus;81 82 public:83 82 //! Constructor 84 83 /** Constructor with a small default stacksize. If any of your threads exceeds this stack, your application will crash. … … 92 91 93 92 typedef void tfunc_t(void *); //!< type of the pointer that starts a thread 94 int waitEvent( constEventKey &key, EventVal *val=0, unsigned int timeout=0);93 int waitEvent(EventKey &key, EventVal *val=0, unsigned int timeout=0); 95 94 void yield(); 96 95 int sendEvent(const EventKey& key, const EventVal* val=0); … … 104 103 private: 105 104 static void threadWrapper(MTasker *self, tfunc_t *tf, int tid, void* val); 105 EventKey d_eventkey; // for waitEvent, contains exact key it was awoken for 106 106 }; 107 107 #include "mtasker.cc" -
trunk/pdns/pdns/pdns_recursor.cc
r698 r699 128 128 static map<int,PacketID> d_tcpclientreadsocks, d_tcpclientwritesocks; 129 129 130 MTasker<PacketID,string>* MT; 130 typedef MTasker<PacketID,string> MT_t; 131 MT_t* MT; 131 132 132 133 int asendtcp(const string& data, Socket* sock) … … 183 184 *d_len=packet.size(); 184 185 memcpy(data,packet.c_str(),min(len,*d_len)); 186 if(pident.nearMisses > 100) { 187 L<<Logger::Error<<"Too many ("<<pident.nearMisses<<") bogus answers came in from "<<sockAddrToString((struct sockaddr_in*)toaddr, sizeof(pident.remote))<<", assuming spoof attempt."<<endl; 188 return -1; 189 } 185 190 } 186 191 return ret; … … 1000 1005 L<<Logger::Warning<<"Discarding unexpected packet from "<<sockAddrToString((struct sockaddr_in*) &fromaddr, addrlen)<<endl; 1001 1006 g_stats.unexpectedCount++; 1007 1008 for(MT_t::waiters_t::iterator mthread=MT->d_waiters.begin(); mthread!=MT->d_waiters.end(); ++mthread) { 1009 if(!memcmp(&mthread->key.remote.sin_addr, &pident.remote.sin_addr, sizeof(pident.remote.sin_addr))) { 1010 mthread->key.nearMisses++; 1011 } 1012 } 1002 1013 } 1003 1014 } -
trunk/pdns/pdns/rcpgenerator.cc
r683 r699 98 98 } 99 99 100 101 void RecordTextReader::xfrLabel(string& val, bool) 100 void RecordTextReader::xfrLabel(string& val, bool) 102 101 { 103 102 skipSpaces(); -
trunk/pdns/pdns/syncres.hh
r697 r699 318 318 struct PacketID 319 319 { 320 PacketID() : sock(0), inNeeded(0), outPos(0) 320 PacketID() : sock(0), inNeeded(0), outPos(0), nearMisses(0) 321 321 {} 322 322 … … 330 330 string outMSG; // the outgoing message that needs to be sent 331 331 string::size_type outPos; // how far we are along in the outMSG 332 333 mutable uint32_t nearMisses; // number of near misses - host correct, id wrong 332 334 333 335 bool operator<(const PacketID& b) const