ref: faebdc376eb7d03cff18cc20d997d328f5fdd9b7
parent: 7875472935a9a130442eaef382db8167921450ae
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Jul 14 10:33:31 EDT 2015
Load host map in __init__.
--- a/libstd/resolve+posixy.myr
+++ b/libstd/resolve+posixy.myr
@@ -71,8 +71,12 @@
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 hostfind = {host
- if !inited
- hostmap = mkht(strhash, streq)
- loadhosts()
- loadresolv()
- inited = true
- ;;
-> htget(hostmap, host)
}
@@ -147,6 +145,7 @@
while true
match word(str)
| `Some (name, rest):
+ str = rest
if hthas(hostmap, name)
continue
;;
@@ -157,7 +156,6 @@
.addr = addr
]
htput(hostmap, name, hinf)
- str = rest
| `None:
->
;;