Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c0aa506

Browse files
committed
Remove unsafe calling of WSAStartup and WSACleanup from DllMain. Move the
inline cleanup call around so it will be called in the right order, and be called on errors. Per report from Tokuharu Yuzawa.
1 parent 2825337 commit c0aa506

File tree

4 files changed

+14
-48
lines changed

4 files changed

+14
-48
lines changed

src/interfaces/libpq/bcc32.mak

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ CLEAN :
9393
-@erase "$(INTDIR)\fe-secure.obj"
9494
-@erase "$(INTDIR)\pqexpbuffer.obj"
9595
-@erase "$(INTDIR)\pqsignal.obj"
96-
-@erase "$(OUTDIR)\libpqdll.obj"
9796
-@erase "$(OUTDIR)\win32.obj"
9897
-@erase "$(INTDIR)\wchar.obj"
9998
-@erase "$(INTDIR)\encnames.obj"
@@ -155,14 +154,13 @@ RSC_PROJ=-l 0x409 -i$(BCB)\include -fo"$(INTDIR)\libpq.res"
155154

156155
LINK32=ilink32.exe
157156
LINK32_FLAGS = -Gn -L$(BCB)\lib;$(INTDIR); -x -Tpd -v
158-
LINK32_OBJS= "$(INTDIR)\libpqdll.obj"
159157

160158
# @<< is a Response file, http://www.opussoftware.com/tutorial/TutMakefile.htm
161159

162-
"$(OUTDIR)\blibpq.dll": "$(OUTDIR)\blibpq.lib" $(LINK32_OBJS) "$(INTDIR)\libpq.res" blibpqdll.def
160+
"$(OUTDIR)\blibpq.dll": "$(OUTDIR)\blibpq.lib" "$(INTDIR)\libpq.res" blibpqdll.def
163161
$(LINK32) @<<
164162
$(LINK32_FLAGS) +
165-
c0d32.obj $(LINK32_OBJS), +
163+
c0d32.obj , +
166164
$@,, +
167165
"$(OUTDIR)\blibpq.lib" import32.lib cw32mt.lib, +
168166
blibpqdll.def,"$(INTDIR)\libpq.res"

src/interfaces/libpq/fe-connect.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.344 2007/02/20 15:20:51 momjian Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.345 2007/03/08 19:27:28 mha Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1840,9 +1840,7 @@ makeEmptyPGconn(void)
18401840
#ifdef WIN32
18411841

18421842
/*
1843-
* Make sure socket support is up and running. Even though this is done in
1844-
* libpqdll.c, that is only for MSVC and BCC builds and doesn't work for
1845-
* static builds at all, so we have to do it in the main code too.
1843+
* Make sure socket support is up and running.
18461844
*/
18471845
WSADATA wsaData;
18481846

@@ -1853,7 +1851,12 @@ makeEmptyPGconn(void)
18531851

18541852
conn = (PGconn *) malloc(sizeof(PGconn));
18551853
if (conn == NULL)
1854+
{
1855+
#ifdef WIN32
1856+
WSACleanup();
1857+
#endif
18561858
return conn;
1859+
}
18571860

18581861
/* Zero all pointers and booleans */
18591862
MemSet(conn, 0, sizeof(PGconn));
@@ -1918,10 +1921,6 @@ freePGconn(PGconn *conn)
19181921
PGnotify *notify;
19191922
pgParameterStatus *pstatus;
19201923

1921-
#ifdef WIN32
1922-
WSACleanup();
1923-
#endif
1924-
19251924
if (!conn)
19261925
return;
19271926

@@ -1986,6 +1985,10 @@ freePGconn(PGconn *conn)
19861985
termPQExpBuffer(&conn->errorMessage);
19871986
termPQExpBuffer(&conn->workBuffer);
19881987
free(conn);
1988+
1989+
#ifdef WIN32
1990+
WSACleanup();
1991+
#endif
19891992
}
19901993

19911994
/*

src/interfaces/libpq/libpqdll.c

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/interfaces/libpq/win32.mak

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ CLEAN :
6363
-@erase "$(INTDIR)\fe-secure.obj"
6464
-@erase "$(INTDIR)\pqexpbuffer.obj"
6565
-@erase "$(INTDIR)\pqsignal.obj"
66-
-@erase "$(OUTDIR)\libpqdll.obj"
6766
-@erase "$(OUTDIR)\win32.obj"
6867
-@erase "$(INTDIR)\wchar.obj"
6968
-@erase "$(INTDIR)\encnames.obj"
@@ -143,7 +142,6 @@ LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shfolder.lib wsock32.lib $(SSL
143142
/pdb:"$(OUTDIR)\libpqdll.pdb" /machine:I386 /out:"$(OUTDIR)\$(OUTFILENAME).dll"\
144143
/implib:"$(OUTDIR)\$(OUTFILENAME)dll.lib" /def:$(OUTFILENAME)dll.def
145144
LINK32_OBJS= \
146-
"$(INTDIR)\libpqdll.obj" \
147145
"$(OUTDIR)\$(OUTFILENAME).lib" \
148146
"$(OUTDIR)\libpq.res"
149147

@@ -159,7 +157,7 @@ LINK32_OBJS= \
159157
$(RSC) $(RSC_PROJ) libpq.rc
160158

161159

162-
"$(OUTDIR)\$(OUTFILENAME).dll" : "$(OUTDIR)" "$(OUTDIR)\libpqdll.obj" "$(INTDIR)\libpqdll.obj" "$(INTDIR)\libpq.res"
160+
"$(OUTDIR)\$(OUTFILENAME).dll" : "$(OUTDIR)" "$(INTDIR)\libpq.res"
163161
$(LINK32) @<<
164162
$(LINK32_FLAGS) $(LINK32_OBJS)
165163
<<

0 commit comments

Comments
 (0)