1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +03:00

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.
This commit is contained in:
Magnus Hagander
2007-03-08 19:27:28 +00:00
parent 2825337232
commit c0aa50630b
4 changed files with 14 additions and 48 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.344 2007/02/20 15:20:51 momjian Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.345 2007/03/08 19:27:28 mha Exp $
*
*-------------------------------------------------------------------------
*/
@ -1840,9 +1840,7 @@ makeEmptyPGconn(void)
#ifdef WIN32
/*
* Make sure socket support is up and running. Even though this is done in
* libpqdll.c, that is only for MSVC and BCC builds and doesn't work for
* static builds at all, so we have to do it in the main code too.
* Make sure socket support is up and running.
*/
WSADATA wsaData;
@ -1853,7 +1851,12 @@ makeEmptyPGconn(void)
conn = (PGconn *) malloc(sizeof(PGconn));
if (conn == NULL)
{
#ifdef WIN32
WSACleanup();
#endif
return conn;
}
/* Zero all pointers and booleans */
MemSet(conn, 0, sizeof(PGconn));
@ -1918,10 +1921,6 @@ freePGconn(PGconn *conn)
PGnotify *notify;
pgParameterStatus *pstatus;
#ifdef WIN32
WSACleanup();
#endif
if (!conn)
return;
@ -1986,6 +1985,10 @@ freePGconn(PGconn *conn)
termPQExpBuffer(&conn->errorMessage);
termPQExpBuffer(&conn->workBuffer);
free(conn);
#ifdef WIN32
WSACleanup();
#endif
}
/*