Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
Dnsmasq
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Dnsmasq
Commits
915363f9
Commit
915363f9
authored
Jan 11, 2012
by
Simon Kelley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweaks to hostfile performance work.
parent
205fafa5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
src/cache.c
src/cache.c
+12
-11
No files found.
src/cache.c
View file @
915363f9
...
@@ -660,9 +660,7 @@ static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrl
...
@@ -660,9 +660,7 @@ static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrl
whilst reading hosts files: the buckets are then freed, and the
whilst reading hosts files: the buckets are then freed, and the
->next pointer used for other things.
->next pointer used for other things.
We search and bail at the first matching address that came from
Only insert each unique address one into this hashing structure.
a HOSTS file. Since the first host entry gets reverse, we know
then that it must exist without searching exhaustively for it.
This complexity avoids O(n^2) divergent CPU use whilst reading
This complexity avoids O(n^2) divergent CPU use whilst reading
large (10000 entry) hosts files. */
large (10000 entry) hosts files. */
...
@@ -671,7 +669,9 @@ static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrl
...
@@ -671,7 +669,9 @@ static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrl
for
(
j
=
0
,
i
=
0
;
i
<
addrlen
;
i
++
)
for
(
j
=
0
,
i
=
0
;
i
<
addrlen
;
i
++
)
j
+=
((
unsigned
char
*
)
addr
)[
i
]
+
(
j
<<
6
)
+
(
j
<<
16
)
-
j
;
j
+=
((
unsigned
char
*
)
addr
)[
i
]
+
(
j
<<
6
)
+
(
j
<<
16
)
-
j
;
for
(
lookup
=
rhash
[
j
%
RHASHSIZE
];
lookup
;
lookup
=
lookup
->
next
)
j
=
j
%
RHASHSIZE
;
for
(
lookup
=
rhash
[
j
];
lookup
;
lookup
=
lookup
->
next
)
if
((
lookup
->
flags
&
F_HOSTS
)
&&
if
((
lookup
->
flags
&
F_HOSTS
)
&&
(
lookup
->
flags
&
flags
&
(
F_IPV4
|
F_IPV6
))
&&
(
lookup
->
flags
&
flags
&
(
F_IPV4
|
F_IPV6
))
&&
memcmp
(
&
lookup
->
addr
.
addr
,
addr
,
addrlen
)
==
0
)
memcmp
(
&
lookup
->
addr
.
addr
,
addr
,
addrlen
)
==
0
)
...
@@ -680,15 +680,16 @@ static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrl
...
@@ -680,15 +680,16 @@ static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrl
break
;
break
;
}
}
/* maintain address hash chain, insert new unique address */
if
(
!
lookup
)
{
cache
->
next
=
rhash
[
j
];
rhash
[
j
]
=
cache
;
}
cache
->
flags
=
flags
;
cache
->
flags
=
flags
;
cache
->
uid
=
index
;
cache
->
uid
=
index
;
/* maintain address has chain */
cache
->
next
=
rhash
[
j
%
RHASHSIZE
];
rhash
[
j
%
RHASHSIZE
]
=
cache
;
memcpy
(
&
cache
->
addr
.
addr
,
addr
,
addrlen
);
memcpy
(
&
cache
->
addr
.
addr
,
addr
,
addrlen
);
cache_hash
(
cache
);
cache_hash
(
cache
);
/* don't need to do alias stuff for second and subsequent addresses. */
/* don't need to do alias stuff for second and subsequent addresses. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment