summaryrefslogtreecommitdiff
path: root/libstd
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-07-14 14:33:31 -0700
committerOri Bernstein <ori@eigenstate.org>2015-07-15 11:06:22 -0700
commitfaebdc376eb7d03cff18cc20d997d328f5fdd9b7 (patch)
treed58bf742a1406364048bb18b9332e5d97ad20912 /libstd
parent7875472935a9a130442eaef382db8167921450ae (diff)
downloadmc-faebdc376eb7d03cff18cc20d997d328f5fdd9b7.tar.gz
Load host map in __init__.
Diffstat (limited to 'libstd')
-rw-r--r--libstd/resolve+posixy.myr14
1 files changed, 6 insertions, 8 deletions
diff --git a/libstd/resolve+posixy.myr b/libstd/resolve+posixy.myr
index e4cf555..185c9d7 100644
--- a/libstd/resolve+posixy.myr
+++ b/libstd/resolve+posixy.myr
@@ -71,8 +71,12 @@ const Resolvfile = "/etc/resolv.conf"
var hostmap : htab(byte[:], hostinfo)#
var search : byte[:][:]
var nameservers : netaddr[:]
-var inited : bool = false
+const __init__ = {
+ hostmap = mkht(strhash, streq)
+ loadhosts()
+ loadresolv()
+}
const resolve = {host
-> resolverec(host, DnsA)
@@ -92,12 +96,6 @@ const resolverec = {host, t
}
const hostfind = {host
- if !inited
- hostmap = mkht(strhash, streq)
- loadhosts()
- loadresolv()
- inited = true
- ;;
-> htget(hostmap, host)
}
@@ -147,6 +145,7 @@ const addhosts = {addr, as, str
while true
match word(str)
| `Some (name, rest):
+ str = rest
if hthas(hostmap, name)
continue
;;
@@ -157,7 +156,6 @@ const addhosts = {addr, as, str
.addr = addr
]
htput(hostmap, name, hinf)
- str = rest
| `None:
->
;;