Обсуждение: Fw: For the start

Поиск
Список
Период
Сортировка

Fw: For the start

От
"Darko Prenosil"
Дата:
----- Original Message -----
From: "Darko Prenosil" <Darko.Prenosil@finteh.hr>
To: <pgsql-hackers-win32@postgresql.org>
Sent: Friday, September 05, 2003 11:34 PM
Subject: Re: [pgsql-hackers-win32] For the start


>
> ----- Original Message -----
> From: "Andreas Pflug" <pgadmin@pse-consulting.de>
> To: "Darko Prenosil" <Darko.Prenosil@finteh.hr>
> Cc: <pgsql-hackers-win32@postgresql.org>
> Sent: Friday, September 05, 2003 10:37 PM
> Subject: Re: [pgsql-hackers-win32] For the start
>
>
> > Darko Prenosil wrote:
> >
> > >------
> > >        thread.c:70: conflicting types for `pqGetpwuid'
> > >        ../../src/include/port.h:116: previous declaration of
> `pqGetpwuid'
> > >
> > >There was no such error before about two months when I tried it.
> > >If I recall correctly, Andreas was doing some patches on this matter
> > >recently ?
> > >
> > Hi Darko,
> >
> > pqGetpwuid should not compile under win32 because of the WIN32 macro
> > (it's only used by libpq for SSL client certificates, and win32 libpq
> > won't support this at the moment), I'd be quite surprised if this macro
> > isn't defined for mingw because standard win32 headers would be affected
> > (I'd expect it at least in the makefile as -DWIN32 or so). Bruce
> > suggested there might arise problems with WIN32, if you got new findings
> > please let us know.
> >
> Are You talking about current 7.4 head or WIN32_DEV branch ?
> I see WIN32 macro in current CVS head, but not in WIN32_DEV branch. As I
> said before, it looks like we need first to apply Your patches to
WIN32_DEV
> branch before going further.
>
> Regards !
>
Now when I'm reading this mail again, I think You misunderstood what I'm
trying to do.
I am not compiling libpq, but postgresql server.
I would like to first get a clean compile (which I already succeed with some
older version of CVS head)
, and after that play a bit with signal implementation that Bruce suggested
for postgresql win32 port.
I'm afraid that I can't directly apply Your patches to WIN32_DEV branch
because it is actually based on cvs head
from "date: 2003/08/08 17:17:17" (according to Marc's mail).
I'm not that familiar with diff/patch, so this question might sound
stupid: is there any easy way to make those patches against WIN32_DEV branch
?
Anyway those WIN32 ifdefs must go into WIN32_DEV branch.

Regards !



Re: Fw: For the start

От
"Marc G. Fournier"
Дата:

On Fri, 5 Sep 2003, Darko Prenosil wrote:

> I'm not that familiar with diff/patch, so this question might sound
> stupid: is there any easy way to make those patches against WIN32_DEV branch
> ?
> Anyway those WIN32 ifdefs must go into WIN32_DEV branch.

Can someone send me the patches that are being refer'd to, and I'll look
at getting them into WIN32_DEV ...


Re: Fw: For the start

От
"Darko Prenosil"
Дата:
----- Original Message -----
From: "Marc G. Fournier" <scrappy@postgresql.org>
To: "Darko Prenosil" <Darko.Prenosil@finteh.hr>
Cc: <pgsql-hackers-win32@postgresql.org>
Sent: Saturday, September 06, 2003 3:31 AM
Subject: Re: Fw: [pgsql-hackers-win32] For the start


>
>
> On Fri, 5 Sep 2003, Darko Prenosil wrote:
>
> > I'm not that familiar with diff/patch, so this question might sound
> > stupid: is there any easy way to make those patches against WIN32_DEV
branch
> > ?
> > Anyway those WIN32 ifdefs must go into WIN32_DEV branch.
>
> Can someone send me the patches that are being refer'd to, and I'll look
> at getting them into WIN32_DEV ...
>
>
Andreas, Can You do that, or should I find those patches in the archives ? I
am not shore if those patches are touching anithing else except libpq
threading/ssl. If You do not have time to spend on it, I'll try to extract
those critical changes for WIN32_DEV branch.

Regards !


Re: Fw: For the start

От
Andreas Pflug
Дата:
Darko Prenosil wrote:

>Andreas, Can You do that, or should I find those patches in the archives ? I
>am not shore if those patches are touching anithing else except libpq
>threading/ssl. If You do not have time to spend on it, I'll try to extract
>those critical changes for WIN32_DEV branch.
>
Hi Darko,

I don't have WIN32_DEV on my system, and probably won't have in the next 
weeks. My patches are only for libpq, and won't interfere with the 
backend. Attached the patch that finally got applied.

Regards,
Andreas

cvs diff -u interfaces\libpq\fe-connect.c interfaces\libpq\fe-exec.c interfaces\libpq\fe-secure.c
interfaces\libpq\libpq-int.hinclude\pg_config.h.win32 interfaces\libpq\win32.c interfaces\libpq\win32.mak (in directory
C:\postgresql\src\)
Index: interfaces/libpq/fe-connect.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.259
diff -u -r1.259 fe-connect.c
--- interfaces/libpq/fe-connect.c    4 Aug 2003 02:40:16 -0000    1.259
+++ interfaces/libpq/fe-connect.c    31 Aug 2003 23:22:25 -0000
@@ -48,7 +48,7 @@
 
 /* For FNCTL_NONBLOCK */
 #if defined(WIN32) || defined(__BEOS__)
-long        ioctlsocket_ret;
+long        ioctlsocket_ret=1;
 #endif

 #define PGPASSFILE ".pgpass"
 
Index: interfaces/libpq/fe-exec.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-exec.c,v
retrieving revision 1.146
diff -u -r1.146 fe-exec.c
--- interfaces/libpq/fe-exec.c    27 Aug 2003 00:33:34 -0000    1.146
+++ interfaces/libpq/fe-exec.c    31 Aug 2003 23:22:28 -0000
@@ -2304,7 +2304,7 @@
     if (buffer == NULL)
         return NULL;
 
-    for (i = j = buflen = 0; i < strtextlen;)
+    for (i = j = buflen = 0; i < (int)strtextlen;)
     {
         switch (strtext[i])
         {
Index: interfaces/libpq/fe-secure.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/fe-secure.c,v
retrieving revision 1.29
diff -u -r1.29 fe-secure.c
--- interfaces/libpq/fe-secure.c    4 Aug 2003 17:25:14 -0000    1.29
+++ interfaces/libpq/fe-secure.c    31 Aug 2003 23:22:29 -0000
@@ -312,7 +312,7 @@
                         printfPQExpBuffer(&conn->errorMessage,
                                           libpq_gettext("SSL SYSCALL error: EOF detected\n"));
 
-                        SOCK_ERRNO = ECONNRESET;
+                        SOCK_ERRNO_SET(ECONNRESET);
                         n = -1;
                     }
                     break;
@@ -322,7 +322,7 @@
                       libpq_gettext("SSL error: %s\n"), SSLerrmessage());
                 /* fall through */
             case SSL_ERROR_ZERO_RETURN:
-                SOCK_ERRNO = ECONNRESET;
+                SOCK_ERRNO_SET(ECONNRESET);
                 n = -1;
                 break;
             default:
@@ -383,7 +383,7 @@
                     {
                         printfPQExpBuffer(&conn->errorMessage,
                                           libpq_gettext("SSL SYSCALL error: EOF detected\n"));
-                        SOCK_ERRNO = ECONNRESET;
+                        SOCK_ERRNO_SET(ECONNRESET);
                         n = -1;
                     }
                     break;
@@ -393,7 +393,7 @@
                       libpq_gettext("SSL error: %s\n"), SSLerrmessage());
                 /* fall through */
             case SSL_ERROR_ZERO_RETURN:
-                SOCK_ERRNO = ECONNRESET;
+                SOCK_ERRNO_SET(ECONNRESET);
                 n = -1;
                 break;
             default:
@@ -544,6 +544,9 @@
 static DH  *
 load_dh_file(int keylength)
 {
+#ifdef WIN32
+    return NULL;
+#else
     char        pwdbuf[BUFSIZ];
     struct passwd pwdstr;
     struct passwd *pwd = NULL;
@@ -558,6 +561,7 @@
     /* attempt to open file.  It's not an error if it doesn't exist. */
     snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/dh%d.pem",
              pwd->pw_dir, keylength);
+
     if ((fp = fopen(fnbuf, "r")) == NULL)
         return NULL;
 
@@ -583,6 +587,7 @@
     }
 
     return dh;
+#endif
 }
 
 /*
@@ -686,6 +691,9 @@
 static int
 client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
 {
+#ifdef WIN32
+   return 0;
+#else
     char        pwdbuf[BUFSIZ];
     struct passwd pwdstr;
     struct passwd *pwd = NULL;
@@ -785,6 +793,7 @@
     }
 
     return 1;
+#endif
 }
 
 /*
@@ -793,11 +802,13 @@
 static int
 initialize_SSL(PGconn *conn)
 {
+#ifndef WIN32
     struct stat buf;
     char        pwdbuf[BUFSIZ];
     struct passwd pwdstr;
     struct passwd *pwd = NULL;
     char        fnbuf[2048];
+#endif
 
     if (!SSL_context)
     {
@@ -813,6 +824,7 @@
         }
     }
 
+#ifndef WIN32
     if (pqGetpwuid(getuid(), &pwdstr, pwdbuf, sizeof(pwdbuf), &pwd) == 0)
     {
         snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/root.crt",
@@ -849,6 +861,7 @@
 
     /* set up mechanism to provide client certificate, if available */
     SSL_CTX_set_client_cert_cb(SSL_context, client_cert_cb);
+#endif
 
     return 0;
 }
Index: interfaces/libpq/libpq-int.h
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/libpq-int.h,v
retrieving revision 1.81
diff -u -r1.81 libpq-int.h
--- interfaces/libpq/libpq-int.h    13 Aug 2003 18:56:21 -0000    1.81
+++ interfaces/libpq/libpq-int.h    31 Aug 2003 23:22:30 -0000
@@ -465,9 +465,11 @@
 #ifdef WIN32
 #define SOCK_ERRNO (WSAGetLastError())
 #define SOCK_STRERROR winsock_strerror
+#define SOCK_ERRNO_SET(e) WSASetLastError(e)
 #else
 #define SOCK_ERRNO errno
 #define SOCK_STRERROR pqStrerror
+#define SOCK_ERRNO_SET(e) errno=e
 #endif
 
 #endif   /* LIBPQ_INT_H */
Index: interfaces/libpq/win32.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/win32.c,v
retrieving revision 1.6
diff -u -r1.6 win32.c
--- interfaces/libpq/win32.c    4 Aug 2003 02:40:20 -0000    1.6
+++ interfaces/libpq/win32.c    31 Aug 2003 23:22:31 -0000
@@ -312,7 +312,7 @@
     {
         strerrbuf[buflen - 1] = '\0';
         offs = strlen(strerrbuf);
-        if (offs > buflen - 64)
+        if (offs > (int)buflen - 64)
             offs = buflen - 64;
         sprintf(strerrbuf + offs, " (0x%08X/%lu)", err, err);
     }
Index: interfaces/libpq/win32.mak
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/libpq/win32.mak,v
retrieving revision 1.18
diff -u -r1.18 win32.mak
--- interfaces/libpq/win32.mak    12 Jun 2003 08:15:29 -0000    1.18
+++ interfaces/libpq/win32.mak    31 Aug 2003 23:22:31 -0000
@@ -1,14 +1,16 @@
 # Makefile for Microsoft Visual C++ 5.0 (or compat)
 
-# Will build a Win32 static library (non-debug) libpq.lib
-#        and a Win32 dynamic library (non-debug) libpq.dll with import library libpqdll.lib
+# Will build a Win32 static library libpq.lib
+#        and a Win32 dynamic library libpq.dll with import library libpqdll.lib
+# USE_SSL=1 will compile with OpenSSL
+# DEBUG=1 compiles with debugging symbols
 
 
 !MESSAGE Building the Win32 static library...
 !MESSAGE
 
 !IFDEF DEBUG
-OPT=/Od
+OPT=/Od /Zi
 LOPT=/debug
 DEBUGDEF=/D _DEBUG
 !ELSE
@@ -26,12 +28,16 @@
 CPP=cl.exe
 RSC=rc.exe
 
+!IFDEF DEBUG
+OUTDIR=.\Debug
+INTDIR=.\Debug
+CPP_OBJS=.\Debug/
+!ELSE
 OUTDIR=.\Release
 INTDIR=.\Release
+CPP_OBJS=.\Release/
+!ENDIF
 
-# Begin Custom Macros
-OutDir=.\Release
-# End Custom Macros
 
 ALL : "$(OUTDIR)\libpq.lib" "$(OUTDIR)\libpq.dll" 
 
@@ -72,16 +78,20 @@
  "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\libpq.pch" /YX\
  /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c  /D "HAVE_VSNPRINTF" /D "HAVE_STRDUP"
 
-CPP_OBJS=.\Release/
+!IFDEF USE_SSL
+CPP_PROJ=$(CPP_PROJ) /D USE_SSL
+SSL_LIBS=ssleay32.lib libeay32.lib gdi32.lib
+!ENDIF
+
 CPP_SBRS=.
 
 LIB32=link.exe -lib
 LIB32_FLAGS=$(LOPT) /nologo /out:"$(OUTDIR)\libpq.lib" 
 LIB32_OBJS= \
-    "$(OUTDIR)\win32.obj" \
+    "$(INTDIR)\win32.obj" \
     "$(INTDIR)\getaddrinfo.obj" \
     "$(INTDIR)\inet_aton.obj" \
-      "$(INTDIR)\crypt.obj" \
+        "$(INTDIR)\crypt.obj" \
     "$(INTDIR)\path.obj" \
     "$(INTDIR)\dllist.obj" \
     "$(INTDIR)\md5.obj" \
@@ -94,15 +104,17 @@
     "$(INTDIR)\fe-lobj.obj" \
     "$(INTDIR)\fe-misc.obj" \
     "$(INTDIR)\fe-print.obj" \
+    "$(INTDIR)\thread.obj" \
     "$(INTDIR)\fe-secure.obj" \
     "$(INTDIR)\pqexpbuffer.obj" \
     "$(INTDIR)\wchar.obj" \
     "$(INTDIR)\encnames.obj"
 
+
 RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
 
 LINK32=link.exe
-LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib wsock32.lib\
+LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib wsock32.lib $(SSL_LIBS)  \
  /nologo /subsystem:windows /dll $(LOPT) /incremental:no\
  /pdb:"$(OUTDIR)\libpqdll.pdb" /machine:I386 /out:"$(OUTDIR)\libpq.dll"\
  /implib:"$(OUTDIR)\libpqdll.lib"  /def:libpqdll.def
@@ -126,38 +138,43 @@
   $(LINK32_FLAGS) $(LINK32_OBJS)
 <<
 
-"$(OUTDIR)\getaddrinfo.obj" : ..\..\port\getaddrinfo.c
+"$(INTDIR)\getaddrinfo.obj" : ..\..\port\getaddrinfo.c
     $(CPP) @<<
     $(CPP_PROJ) ..\..\port\getaddrinfo.c
 <<
 
-"$(OUTDIR)\inet_aton.obj" : ..\..\port\inet_aton.c
+"$(INTDIR)\thread.obj" : ..\..\port\thread.c
+    $(CPP) @<<
+    $(CPP_PROJ) ..\..\port\thread.c
+<<
+
+"$(INTDIR)\inet_aton.obj" : ..\..\port\inet_aton.c
     $(CPP) @<<
     $(CPP_PROJ) ..\..\port\inet_aton.c
 <<
 
-"$(OUTDIR)\crypt.obj" : ..\..\port\crypt.c
+"$(INTDIR)\crypt.obj" : ..\..\port\crypt.c
     $(CPP) @<<
     $(CPP_PROJ) ..\..\port\crypt.c
 <<
 
-"$(OUTDIR)\path.obj" : ..\..\port\path.c
+"$(INTDIR)\path.obj" : ..\..\port\path.c
     $(CPP) @<<
     $(CPP_PROJ) ..\..\port\path.c
 <<
 
-"$(OUTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c
+"$(INTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c
     $(CPP) @<<
     $(CPP_PROJ) ..\..\backend\lib\dllist.c
 <<
 
 
-"$(OUTDIR)\md5.obj" : ..\..\backend\libpq\md5.c
+"$(INTDIR)\md5.obj" : ..\..\backend\libpq\md5.c
     $(CPP) @<<
     $(CPP_PROJ) ..\..\backend\libpq\md5.c
 <<
 
-"$(OUTDIR)\ip.obj" : ..\..\backend\libpq\ip.c
+"$(INTDIR)\ip.obj" : ..\..\backend\libpq\ip.c
     $(CPP) @<<
     $(CPP_PROJ) ..\..\backend\libpq\ip.c
 <<
Index: include/pg_config.h.win32
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/include/pg_config.h.win32,v
retrieving revision 1.11
diff -u -r1.11 pg_config.h.win32
--- include/pg_config.h.win32    12 Jun 2003 08:15:29 -0000    1.11
+++ include/pg_config.h.win32    31 Aug 2003 23:22:31 -0000
@@ -60,4 +60,6 @@
 #include <windows.h>
 #endif
 
+#include <port/win32.h>
+
 #endif /* pg_config_h_win32__ */

***** CVS exited normally with code 1 *****



Re: Fw: For the start

От
"Darko Prenosil"
Дата:
----- Original Message -----
From: "Andreas Pflug" <pgadmin@pse-consulting.de>
To: "Darko Prenosil" <Darko.Prenosil@finteh.hr>
Cc: "Marc G. Fournier" <scrappy@postgresql.org>;
<pgsql-hackers-win32@postgresql.org>
Sent: Saturday, September 06, 2003 11:23 AM
Subject: Re: Fw: [pgsql-hackers-win32] For the start


> Darko Prenosil wrote:
>
> >Andreas, Can You do that, or should I find those patches in the archives
? I
> >am not shore if those patches are touching anithing else except libpq
> >threading/ssl. If You do not have time to spend on it, I'll try to
extract
> >those critical changes for WIN32_DEV branch.
> >
> Hi Darko,
>
> I don't have WIN32_DEV on my system, and probably won't have in the next
> weeks. My patches are only for libpq, and won't interfere with the
> backend. Attached the patch that finally got applied.
>
> Regards,
> Andreas
>
Ooops ! This is not the patch that changed port.h or thread.c, but it is
also fixing "pqGetpwuid" problem in other file (fe-secure).
Looks like I need this patch too.
I just looked at the current CVS and I see that that port.h change applied
before only 16 hours.
I see that it is applied only on CVS head, not WIN32_DEV.

Regards !