Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f5BCkSE56072 for ; Mon, 11 Jun 2001 08:46:28 -0400 (EDT) (envelope-from pgsql-docs-owner@postgresql.org) Received: from jeffjohnson.net (colo16.traci.net [216.242.235.49] (may be forged)) by postgresql.org (8.11.3/8.11.1) with ESMTP id f54J9iE78745; Mon, 4 Jun 2001 15:09:45 -0400 (EDT) (envelope-from jeff@jeffjohnson.net) Received: from ffsdev01 [64.135.29.202] by jeffjohnson.net with ESMTP (SMTPD32-6.05) id AC91A2600F8; Mon, 04 Jun 2001 15:08:01 -0400 Reply-To: From: "Jeff Johnson" To: "'Bruce Momjian'" , Cc: , Subject: RE: [INTERFACES] libpq sockets on win32 Date: Mon, 4 Jun 2001 15:03:35 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2910.0) In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal X-Archive-Number: 200106/21 X-Sequence-Number: 816 Bruce Momjian wrote: > Can you try this patch and let me know if it helps? It is a different > approach. This was the only place I saw errno checked for a > non-predefined value. Setting errno = 0 doesn't help, the error handling code is entered when recv returns -1, then even if errno == 0, it'll bomb out. > I hate to litter this through the whole source. I wonder if > we have to > bracket the errno checkes with #define/#undef. Can you try that with > the fix described on the web page. The above would convert to: > > #ifdef WIN32 > #define errno WSAGetLastError > #endif > if (errno == EINPROGRESS || errno == 0) > #ifdef WIN32 > #undef errno > #endif > > Maybe make these into their own macros somehow. Even when I was a C programmer I never did much more than simple defines with the pre-compiler so I'll leave this to those that know how :) As Tom Lane points out in another post, the "define errno WSAGetLastError" seems to confuse a variable with a function. I was surprised that such a thing could work. I'm happy to hear that it doesn't. What about something like this: #ifdef WIN32 #define s_errno WSAGetLastError() #else #define s_errno errno #endif /* for socket functions, check s_errno */ if (s_errno == EINPROGRESS || s_errno == 0) ... /* for non-socket functions, check errno as usual */ if (errno == ENOENT) ... Then replace only errno with s_errno when it is used with socket code. I'm not sure if strerror would work with all the errors returned by WSAGetLastError(). The Win32 SDK says to use FormatMessage(a ton of stuff here). Regards, Jeff