Mail Archives: cygwin/2001/10/05/06:57:23
Hi Paul,
[...]
> performance is spectacularly bad. At first I thought it was a network
[...]
> WinNT Ver 4.0 build 1381 Service Pack 6
Are you connected to an NT domain? I believe I have found
a performance problem in uinfo.cc, and if you have the
ability to download the source and build it, you could
try my patch -- I would be interested to know if it helps.
Good luck :)
Blue skies,
.Ian.
Tue Oct 2 16:18:09 2001 Ian Ray <ran_iay AT yahoo DOT com>
* uinfo.cc (internal_getlogin): use default HOMEPATH
and HOMEDRIVE from environment if both are present,
else query NetUserGetInfo; this is a performance
optimization.
diff -up uinfo.cc-orig uinfo.cc > uinfo.cc-patch 2>&1
--- uinfo.cc-orig Tue Oct 2 16:18:09 2001
+++ uinfo.cc Tue Oct 2 16:53:34 2001
@@ -76,28 +76,48 @@ internal_getlogin (cygheap_user &user)
user.set_logsrv (buf + 2);
setenv ("LOGONSERVER", buf, 1);
}
+
LPUSER_INFO_3 ui = NULL;
- WCHAR wuser[UNLEN + 1];
- WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];
- /* HOMEDRIVE and HOMEPATH are wrong most of the time, too,
- after changing user context! */
- sys_mbstowcs (wuser, user.name (), UNLEN + 1);
- wlogsrv[0] = '\0';
- if (user.logsrv ())
- {
- strcat (strcpy (buf, "\\\\"), user.logsrv ());
- sys_mbstowcs (wlogsrv, buf, INTERNET_MAX_HOST_NAME_LENGTH +
3);
+ /*
+ * NetUserGetInfo() can be slow in NT domain environment, thus we
+ * only obtain HOMEDRIVE and HOMEPATH if they are not already set
+ * in the environment.
+ */
+ if (!getenv ("HOMEPATH") || !getenv ("HOMEDRIVE"))
+ {
+ WCHAR wuser[UNLEN + 1];
+
+ sys_mbstowcs (wuser, user.name (),
sizeof(wuser)/sizeof(*wuser));
+ ret = NetUserGetInfo (NULL, wuser, 3, (LPBYTE *)&ui);
+
+ if (ret)
+ {
+ if (user.logsrv ())
+ {
+ WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];
+ strcat (strcpy (buf, "\\\\"), user.logsrv ());
+
+ sys_mbstowcs (wlogsrv, buf,
sizeof(wlogsrv)/sizeof(*wlogsrv));
+ ret = NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE
*)&ui);
+ }
+ }
+ }
+ else
+ {
+ ret = 1;
}
- if (!NetUserGetInfo (NULL, wuser, 3, (LPBYTE *)&ui)
- || (wlogsrv[0] && !NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE
*)&ui)))
+
+ if (ret == 0)
{
sys_wcstombs (buf, ui->usri3_home_dir, MAX_PATH);
if (!buf[0])
{
sys_wcstombs (buf, ui->usri3_home_dir_drive, MAX_PATH);
if (buf[0])
- strcat (buf, "\\");
+ {
+ strcat (buf, "\\");
+ }
else
{
env = getenv ("SYSTEMDRIVE");
@@ -110,8 +130,14 @@ internal_getlogin (cygheap_user &user)
setenv ("HOMEPATH", buf + 2, 1);
buf[2] = '\0';
setenv ("HOMEDRIVE", buf, 1);
+ }
+
+ if (ui)
+ {
NetApiBufferFree (ui);
+ ui = NULL;
}
+
debug_printf ("Domain: %s, Logon Server: %s, Windows Username:
%s",
user.domain (), user.logsrv (), user.name ());
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -