- fixup iterator operating in no cache conditions (RD flag unset
after a CNAME).
- streamlined code for RD flag setting.
+ - profiled code and changed dname compares to be faster.
+ The speedup is about +3% to +8% (depending on the test).
+ - minievent tests for eintr and eagain.
15 February 2008: Wouter
- added FreeBSD rc.d script to contrib.
return len;
}
+/** compare uncompressed, noncanonical, registers are hints for speed */
int
-query_dname_compare(uint8_t* d1, uint8_t* d2)
+query_dname_compare(register uint8_t* d1, register uint8_t* d2)
{
- uint8_t lab1, lab2;
+ register uint8_t lab1, lab2;
log_assert(d1 && d2);
lab1 = *d1++;
lab2 = *d2++;
log_assert(lab1 == lab2 && lab1 != 0);
/* compare lowercased labels. */
while(lab1--) {
- if(tolower((int)*d1) != tolower((int)*d2)) {
+ /* compare bytes first for speed */
+ if(*d1 != *d2 &&
+ tolower((int)*d1) != tolower((int)*d2)) {
if(tolower((int)*d1) < tolower((int)*d2))
return -1;
return 1;
int i;
/* preserve case of query, make hash label by label */
- lablen = *dname;
+ lablen = *dname++;
while(lablen) {
log_assert(lablen <= LDNS_MAX_LABELLEN);
labuf[0] = lablen;
- dname++;
i=0;
while(lablen--)
labuf[++i] = (uint8_t)tolower((int)*dname++);
h = hashlittle(labuf, labuf[0] + 1, h);
- lablen = *dname;
+ lablen = *dname++;
}
return h;
memlowercmp(uint8_t* p1, uint8_t* p2, uint8_t len)
{
while(len--) {
- if(tolower((int)*p1++) != tolower((int)*p2++)) {
- if(tolower((int)p1[-1]) < tolower((int)p2[-1]))
+ if(*p1 != *p2 && tolower((int)*p1) != tolower((int)*p2)) {
+ if(tolower((int)*p1) < tolower((int)*p2))
return -1;
return 1;
}
+ p1++;
+ p2++;
}
return 0;
}
else lastdiff = 1;
lastmlabs = atlabel;
} else if((c=memlowercmp(d1, d2, len1)) != 0) {
- if(c<0)
- lastdiff = -1;
- else lastdiff = 1;
+ lastdiff = c;
lastmlabs = atlabel;
}
memmove(&w, &base->writes, sizeof(fd_set));
if((ret = select(base->maxfd+1, &r, &w, NULL, wait)) == -1) {
+ if(errno == EAGAIN || errno == EINTR)
+ return 0;
return -1;
}