pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[PATCH] Pin any DLL as soon as seen when looking for _putenv()
2+ messages / 2 participants
[nested] [flat]

* [PATCH] Pin any DLL as soon as seen when looking for _putenv()
@ 2016-09-06 08:02  Christian Ullrich <chris@chrullrich.net>
  0 siblings, 0 replies; 2+ messages in thread

From: Christian Ullrich @ 2016-09-06 08:02 UTC (permalink / raw)

---
 src/port/win32env.c | 54 ++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 35 insertions(+), 19 deletions(-)

inline patch 1: src/port/win32env.c (+35/-19 lines) download inline-1.patchdiff --git a/src/port/win32env.c b/src/port/win32env.c index 3f56ba8..7417b60 100644 --- a/src/port/win32env.c +++ b/src/port/win32env.c @@ -43,36 +43,37 @@ pgwin32_putenv(const char *envval) char *modulename; HMODULE hmodule; PUTENVPROC putenvFunc; + BOOL pinned; } rtmodules[] = { /* Visual Studio 6.0 / mingw */ - {"msvcrt", NULL, NULL}, - {"msvcrtd", NULL, NULL}, + {"msvcrt", NULL, NULL, FALSE}, + {"msvcrtd", NULL, NULL, FALSE}, /* Visual Studio 2002 */ - {"msvcr70", NULL, NULL}, - {"msvcr70d", NULL, NULL}, + {"msvcr70", NULL, NULL, FALSE}, + {"msvcr70d", NULL, NULL, FALSE}, /* Visual Studio 2003 */ - {"msvcr71", NULL, NULL}, - {"msvcr71d", NULL, NULL}, + {"msvcr71", NULL, NULL, FALSE}, + {"msvcr71d", NULL, NULL, FALSE}, /* Visual Studio 2005 */ - {"msvcr80", NULL, NULL}, - {"msvcr80d", NULL, NULL}, + {"msvcr80", NULL, NULL, FALSE}, + {"msvcr80d", NULL, NULL, FALSE}, /* Visual Studio 2008 */ - {"msvcr90", NULL, NULL}, - {"msvcr90d", NULL, NULL}, + {"msvcr90", NULL, NULL, FALSE}, + {"msvcr90d", NULL, NULL, FALSE}, /* Visual Studio 2010 */ - {"msvcr100", NULL, NULL}, - {"msvcr100d", NULL, NULL}, + {"msvcr100", NULL, NULL, FALSE}, + {"msvcr100d", NULL, NULL, FALSE}, /* Visual Studio 2012 */ - {"msvcr110", NULL, NULL}, - {"msvcr110d", NULL, NULL}, + {"msvcr110", NULL, NULL, FALSE}, + {"msvcr110d", NULL, NULL, FALSE}, /* Visual Studio 2013 */ - {"msvcr120", NULL, NULL}, - {"msvcr120d", NULL, NULL}, + {"msvcr120", NULL, NULL, FALSE}, + {"msvcr120d", NULL, NULL, FALSE}, /* Visual Studio 2015 and later */ - {"ucrtbase", NULL, NULL}, - {"ucrtbased", NULL, NULL}, - {NULL, NULL, NULL} + {"ucrtbase", NULL, NULL, FALSE}, + {"ucrtbased", NULL, NULL, FALSE}, + {NULL, NULL, NULL, FALSE} }; int i; @@ -90,6 +91,21 @@ pgwin32_putenv(const char *envval) } else { + /* + * Pin this DLL handle as soon as possible to avoid it + * to be unloaded until the process terminates. + */ + if (!rtmodules[i].pinned) + { + HMODULE tmp; + BOOL res = GetModuleHandleEx( + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS + | GET_MODULE_HANDLE_EX_FLAG_PIN, + (LPCTSTR)rtmodules[i].hmodule, + &tmp); + rtmodules[i].pinned = res; + } + rtmodules[i].putenvFunc = (PUTENVPROC) GetProcAddress(rtmodules[i].hmodule, "_putenv"); if (rtmodules[i].putenvFunc == NULL) { -- 2.10.0.windows.1
--------------63886F5E27B20EF033573BDA Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers --------------63886F5E27B20EF033573BDA-- ^ permalink raw reply [nested|flat] 2+ messages in thread

* pgsql: Run pgindent on the changes of the previous patch.
@ 2025-07-25 20:42  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2025-07-25 20:42 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Run pgindent on the changes of the previous patch.

This step can be checked mechanically.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Discussion: https://postgr.es/m/2976982.1748049023@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/73873805fb3627cb23937c750fa83ffd8f16fc6c

Modified Files
--------------
contrib/dblink/dblink.c                 | 180 ++++----
contrib/postgres_fdw/connection.c       | 188 ++++-----
contrib/postgres_fdw/postgres_fdw.c     | 703 ++++++++++++++++----------------
src/include/libpq/libpq-be-fe-helpers.h |  38 +-
4 files changed, 553 insertions(+), 556 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2025-07-25 20:42 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-09-06 08:02 [PATCH] Pin any DLL as soon as seen when looking for _putenv() Christian Ullrich <chris@chrullrich.net>
2025-07-25 20:42 pgsql: Run pgindent on the changes of the previous patch. Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox