From mboxrd@z Thu Jan 1 00:00:00 1970 From: arisawa Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-Id: Date: Wed, 18 May 2016 09:43:29 +0900 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: [9fans] bug in authdial() Topicbox-Message-UUID: 8f1bbfae-ead9-11e9-9d60-3106f5b1d025 Hello, authdial() is slow. so I have inspected the code: /sys/src/libauthsrv/authdial.c I suspect netroot causes the problem. int authdial(char *netroot, char *dom) { [snip] if(dom =3D=3D nil) /* look for one relative to my machine */ return dial(netmkaddr("$auth", netroot, "ticket"), 0, 0, = 0); /* look up an auth server in an authentication domain */ p =3D csgetvalue(netroot, "authdom", dom, "auth", &t); /* if that didn't work, just try the IP domain */ if(p =3D=3D nil) p =3D csgetvalue(netroot, "dom", dom, "auth", &t); [snip] for(nt =3D t; nt !=3D nil; nt =3D nt->entry) { if(strcmp(nt->attr, "auth") =3D=3D 0) { p =3D netmkaddr(nt->val, netroot, "ticket"); rv =3D dial(p, 0, 0, 0); if(rv >=3D 0) break; } } [snip] } man authsrv(2) says: the default of netroot in authdial(char *netroot, char *ad) is = =E2=80=9C/net=E2=80=9D and consistent with the synopsis of csgetvalue(char *netroot, char = *attr, char *val,=E2=80=A6.). on the other hand the synopsis of netmkaddr is char* netmkaddr(char *addr, char *defnet, char *defservice) the defnet takes values nil, =E2=80=9Ctcp=E2=80=9D, =E2=80=9Cil=E2=80=9D, = etc. as the result, netroot in the first argument of authdial() works only if = it is nil, which makes authdial() very slow. I think that should be fixed for example: - p =3D netmkaddr(nt->val, netroot, "ticket"); rv =3D dial(p, 0, 0, 0); if(rv >=3D 0) break; + p =3D netmkaddr(nt->val, =E2=80=9Ctcp", = "ticket"); rv =3D dial(p, 0, 0, 0); if(rv >=3D 0) break; + p =3D netmkaddr(nt->val, =E2=80=9Cil", = "ticket"); + rv =3D dial(p, 0, 0, 0); + if(rv >=3D 0) + break; NOTE that return dial(netmkaddr("$auth", netroot, "ticket"), 0, 0, = 0); should be also fixed. Kenji Arisawa