Re: WIN32 PSAPI patch

From: Guido Serassio <serassio@dont-contact.us>
Date: Sun, 21 Oct 2001 10:26:27 +0200

Hi Robert,

Il 09.31 21/10/2001 Robert Collins ha scritto:
>----- Original Message -----
>From: "Guido Serassio" <serassio@libero.it>
>To: <squid-dev@squid-cache.org>
>Sent: Sunday, October 21, 2001 2:52 AM
>Subject: WIN32 PSAPI patch
>
>
> > Hi,
> >
> > This is the second WIN32 patch against HEAD.
> >
> > This code add support for automatic use of PSAPI.DLL when available,
>adding
> > WIN32 process memory informations not available on Cygwin.
> >
> > Anybody can merge this in HEAD ?
> >
> > Guido
>
>
>This one looks suspect. A few questions:
>1)
>+ * You can't rename open files on Microsoft "operating systems"
>+ * so we close before renaming.
>+ */
>+#ifdef _SQUID_MSWIN_
>+ if (debug_log != stderr)
>+ fclose(debug_log);
>+#endif
>
>this looks like to would affect cygwin too... Do you know if it does or
>does not affect cygwin?

_SQUID_CYGWIN_ and _SQUID_MSWIN_ defines are mutually exclusives:

the first is defined at compile time only on Cygwin platforms, the second
only on non-Cygwin platforms (MS VC++ is the only tested at this moment),
and Cygwin has more priority over other Windows platforms.

 From config.h:

#elif defined(__NetBSD__)
#define _SQUID_NETBSD_

#elif defined(__CYGWIN32__) || defined(__CYGWIN__)
#define _SQUID_CYGWIN_

#elif defined(WIN32) || defined(WINNT) || defined(__WIN32__) ||
defined(__WIN32)
#define _SQUID_MSWIN_

#elif defined(__APPLE__)
#define _SQUID_APPLE_

So Cygwin is not affected.

>2)
>
>+#ifndef _SQUID_MSWIN_
>getrusage(RUSAGE_SELF, r);
>+#endif
>
>Should be
>#if HAVE_GETRUSAGE
>getrusage...
>endif
>
>so that if someone has a usuable getrusage on win32 they can use it.

Here we are already in a #if HAVE_GETRUSAGE code section, the idea is to
emulate getrusage function on native port. I know that the better solution
is to add an external getrusage function for MS Compilers, but at this
moment we have a shared code section between Cygwin and native port.
IMO, MS Compilers doesn't have getrusage, and they will never have it.
I know that there is MS Interix environment too, but I think that compile
Squid on it requires a significative porting work.

>3) I note that you overwrite the ru_macrsss and ru_majflt on Cygwin on
>NT platforms - IIRC Cygwin alrready uses PSAPI to provide this
>information, so you are in effect getting it twice. If you've noted that
>cygwin doesn't return this info, then that part is fine. Long term I'll
>get a fix into Cygwin to provide that seamlessly though.

Yes, I've found that Cygwin lacks theses process memory informations.
But, I have just checked the latest cygwin1.dll with the MS Dependency
Walker tool, and I haven't found any reference to psapi.dll on it.
Are You sure that Cygwin uses it ?
IMO, Cygwin lacks theses process memory informations because doesn't use
psapi.

>Lastly, your xrename alteration to remove(to) is IIRC to handle win32
>rename semantics? A comment in the code there would be useful if that is
>indeed the case.

OK, I add a more complete comment, and if this code is ok for you, I will
post a new patch.

Guido

>Rob

-
=======================================================
Serassio Guido
Via Albenga, 11/4 10134 - Torino - ITALY
Tel. : +39.011.610749
E-mail: serassio@interfree.it
         serassio@libero.it
WWW: http://www.serassio.it
Received on Sun Oct 21 2001 - 02:26:32 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:34 MST