# HG changeset patch # User Olaf Wintermann # Date 1642875220 -3600 # Node ID 4cfaa02055cd3e4ca80c06142701c53f995fc6c6 # Parent 3dfbd0b919506324381a9cb744d9ebaab05a950b add first code for postgresql plugin: resourcepool type implementation diff -r 3dfbd0b91950 -r 4cfaa02055cd Makefile --- a/Makefile Sat Jan 22 11:06:11 2022 +0100 +++ b/Makefile Sat Jan 22 19:13:40 2022 +0100 @@ -53,3 +53,5 @@ install: all cd make; $(MAKE) -f install.mk install +install-bin: all + cd make; $(MAKE) -f install.mk install-bin diff -r 3dfbd0b91950 -r 4cfaa02055cd configure --- a/configure Sat Jan 22 11:06:11 2022 +0100 +++ b/configure Sat Jan 22 19:13:40 2022 +0100 @@ -251,6 +251,11 @@ CFLAGS="$CFLAGS `$PKG_CONFIG --cflags libpq`" LDFLAGS="$LDFLAGS `$PKG_CONFIG --libs libpq`" CFLAGS="$CFLAGS -DENABLE_POSTGRESQL" + cat >> $TEMP_DIR/make.mk << __EOF__ +# Dependency: libpq +PLUGINS += postgresql + +__EOF__ echo yes return 0 done @@ -464,6 +469,26 @@ fi # Features + + +echo >> $TEMP_DIR/config.mk +if [ ! -z "${CFLAGS}" ]; then + echo "CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk +fi +if [ ! -z "${CXXFLAGS}" ]; then + echo "CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk +fi +if [ ! -z "${LDFLAGS}" ]; then + echo "LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk +fi + +# Target: postgresql +CFLAGS= +LDFLAGS= +CXXFLAGS= + + +# Features if [ ! -z "$FEATURE_POSTGRESQL" ]; then # check dependency dependency_libpq @@ -479,13 +504,13 @@ echo >> $TEMP_DIR/config.mk if [ ! -z "${CFLAGS}" ]; then - echo "CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk + echo "POSTGRESQL_CFLAGS += $CFLAGS" >> $TEMP_DIR/config.mk fi if [ ! -z "${CXXFLAGS}" ]; then - echo "CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk + echo "POSTGRESQL_CXXFLAGS += $CXXFLAGS" >> $TEMP_DIR/config.mk fi if [ ! -z "${LDFLAGS}" ]; then - echo "LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk + echo "POSTGRESQL_LDFLAGS += $LDFLAGS" >> $TEMP_DIR/config.mk fi if [ $ERROR -ne 0 ]; then diff -r 3dfbd0b91950 -r 4cfaa02055cd make/install.mk --- a/make/install.mk Sat Jan 22 11:06:11 2022 +0100 +++ b/make/install.mk Sat Jan 22 19:13:40 2022 +0100 @@ -30,25 +30,13 @@ include ../config.mk -install: - @echo "install Webserver to $(WS_INSTALL_DIR)" - mkdir -p $(INSTALL_DIR)/bin - mkdir -p $(INSTALL_DIR)/lib - mkdir -p $(INSTALL_DIR)/config - mkdir -p $(INSTALL_DIR)/docs - mkdir -p $(INSTALL_DIR)/logs - mkdir -p $(INSTALL_DIR)/include +install: install-dir install-bin @echo "copy config" cp ../templates/config/init.conf $(INSTALL_DIR)/config/init.conf cp ../templates/config/obj.conf $(INSTALL_DIR)/config/obj.conf cp ../templates/config/mime.types $(INSTALL_DIR)/config/mime.types cp ../templates/config/acl.conf $(INSTALL_DIR)/config/acl.conf sed s:%%WS_HOST%%:$(HOST):g ../templates/config/server.template > $(INSTALL_DIR)/config/server.conf - @echo "copy binaries" - cp ../build/bin/webservd$(APP_EXT) $(INSTALL_DIR)/bin/ - cp ../build/bin/wstool$(APP_EXT) $(INSTALL_DIR)/bin/ - cp ../build/lib/libucx$(LIB_EXT) $(INSTALL_DIR)/lib/ - cp ../build/lib/libwscfg$(LIB_EXT) $(INSTALL_DIR)/lib/ @echo "copy includes" cp ../src/server/public/nsapi.h $(INSTALL_DIR)/include/nsapi.h cp ../src/server/public/auth.h $(INSTALL_DIR)/include/auth.h @@ -64,3 +52,18 @@ chmod +x $(INSTALL_DIR)/bin/reconfig @echo "copy docs" cp -R ../templates/docs $(INSTALL_DIR)/ + +install-dir: + @echo "install Webserver to $(WS_INSTALL_DIR)" + mkdir -p $(INSTALL_DIR)/bin + mkdir -p $(INSTALL_DIR)/lib + mkdir -p $(INSTALL_DIR)/config + mkdir -p $(INSTALL_DIR)/docs + mkdir -p $(INSTALL_DIR)/logs + mkdir -p $(INSTALL_DIR)/include + +install-bin: install-dir + @echo "copy binaries" + cp ../build/bin/webservd$(APP_EXT) $(INSTALL_DIR)/bin/ + cp ../build/bin/wstool$(APP_EXT) $(INSTALL_DIR)/bin/ + cp ../build/lib/* $(INSTALL_DIR)/lib/ diff -r 3dfbd0b91950 -r 4cfaa02055cd make/project.xml --- a/make/project.xml Sat Jan 22 11:06:11 2022 +0100 +++ b/make/project.xml Sat Jan 22 19:13:40 2022 +0100 @@ -81,13 +81,19 @@ libpq -DENABLE_POSTGRESQL + +PLUGINS += postgresql + + libxml2,openssl + + + libpq - libxml2,openssl diff -r 3dfbd0b91950 -r 4cfaa02055cd src/server/daemon/config.c --- a/src/server/daemon/config.c Sat Jan 22 11:06:11 2022 +0100 +++ b/src/server/daemon/config.c Sat Jan 22 19:13:40 2022 +0100 @@ -429,7 +429,7 @@ scstr_t type = serverconfig_directive_value(obj, SC("Type")); int ret = 0; - if(resourcepool_new(cfg, name, type, obj)) { + if(resourcepool_new(cfg, type, name, obj)) { ret = 1; } diff -r 3dfbd0b91950 -r 4cfaa02055cd src/server/daemon/resourcepool.c --- a/src/server/daemon/resourcepool.c Sat Jan 22 11:06:11 2022 +0100 +++ b/src/server/daemon/resourcepool.c Sat Jan 22 19:13:40 2022 +0100 @@ -42,6 +42,14 @@ return resource_pool_types ? 0 : 1; } +int resourcepool_register_type(const char *type_name, ResourceType *type_info) { + if(ucx_map_cstr_put(resource_pool_types, type_name, type_info)) { + log_ereport(LOG_CATASTROPHE, "resourcepool_register_type: OOM"); + return 1; + } + return 0; +} + int resourcepool_new(ServerConfiguration *cfg, scstr_t type, scstr_t name, ConfigNode *node) { @@ -67,7 +75,7 @@ } respool->pool = cfg->pool; - void *respool_data = restype->init(cfg->pool, param); + void *respool_data = restype->init(cfg->pool, name.ptr, param); if(!respool_data) { log_ereport(LOG_FAILURE, "Cannot create resource pool data: pool: %s type: %s", name.ptr, type.ptr); return 1; diff -r 3dfbd0b91950 -r 4cfaa02055cd src/server/plugins/postgresql/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/server/plugins/postgresql/Makefile Sat Jan 22 19:13:40 2022 +0100 @@ -0,0 +1,52 @@ +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 2022 Olaf Wintermann. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +BUILD_ROOT = ../../../.. + +include $(BUILD_ROOT)/config.mk + +# list of source files +SRC = init.c +SRC += resource.c + +OBJ = $(SRC:%.c=$(BUILD_ROOT)/build/server/plugins/postgresql/%$(OBJ_EXT)) + +BUILD_DIR = $(BUILD_ROOT)/build/server/plugins/postgresql + +PLUGIN_TARGET = $(BUILD_ROOT)/build/lib/libwspostgresql$(LIB_EXT) + +all: $(PLUGIN_TARGET) + +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +$(PLUGIN_TARGET): $(BUILD_DIR) $(OBJ) + $(CC) $(POSTGRESQL_LDFLAGS) $(SHLIB_LDFLAGS) -o $@ $(OBJ) + +$(BUILD_DIR)/%.o: %.c + $(CC) $(CFLAGS) $(POSTGRESQL_CFLAGS) $(SHLIB_CFLAGS) -c -o $@ $< \ No newline at end of file diff -r 3dfbd0b91950 -r 4cfaa02055cd src/server/plugins/postgresql/init.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/server/plugins/postgresql/init.c Sat Jan 22 19:13:40 2022 +0100 @@ -0,0 +1,40 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2022 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "init.h" + +#include "resource.h" + +int pg_init(pblock *pb, Session *sn, Request *Rq) { + if(resourcepool_register_type("postgresql", pg_get_resource_type())) { + log_ereport(LOG_FAILURE, "pg-init: Cannot register resourcepool type"); + return REQ_ABORTED; + } + + return REQ_PROCEED; +} diff -r 3dfbd0b91950 -r 4cfaa02055cd src/server/plugins/postgresql/init.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/server/plugins/postgresql/init.h Sat Jan 22 19:13:40 2022 +0100 @@ -0,0 +1,48 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2022 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WS_PG_INIT_H +#define WS_PG_INIT_H + +#include "../../public/nsapi.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int pg_init(pblock *pb, Session *sn, Request *Rq); + + +#ifdef __cplusplus +} +#endif + +#endif /* WS_PG_INIT_H */ + diff -r 3dfbd0b91950 -r 4cfaa02055cd src/server/plugins/postgresql/init.o Binary file src/server/plugins/postgresql/init.o has changed diff -r 3dfbd0b91950 -r 4cfaa02055cd src/server/plugins/postgresql/resource.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/server/plugins/postgresql/resource.c Sat Jan 22 19:13:40 2022 +0100 @@ -0,0 +1,130 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2022 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "resource.h" + +static ResourceType pg_resource_type = { + (resource_pool_init_func)pg_resourcepool_init, + (resource_pool_destroy_func)pg_resourcepool_destroy, + (resource_pool_createresource_func)pg_resourcepool_createresource, + (resource_pool_freeresource_func)pg_resourcepool_freeresource, + (resource_pool_prepare_func)pg_resourcepool_prepare, + (resource_pool_finish_func)pg_resourcepool_finish, + (resource_pool_getresourcedata_func)pg_resourcepool_getresourcedata +}; + +ResourceType* pg_get_resource_type(void) { + return &pg_resource_type; +} + +void * pg_resourcepool_init(pool_handle_t *pool, const char *rpname, pblock *pb) { + char *connection = pblock_findval("Connection", pb); + if(!connection) { + log_ereport(LOG_MISCONFIG, "Resource pool %s: Missing Connection parameter", rpname); + return NULL; + } + + // test connection + PGconn *test_connection = PQconnectdb(connection); + if(pg_check_connection(rpname, test_connection)) { + return NULL; // error, pg_check_connection does the logging + } + PQfinish(test_connection); + + PgResourcePool *pg = pool_malloc(pool, sizeof(PgResourcePool)); + if(!pg) { + return NULL; + } + pg->pool = pool; + pg->name = rpname; + pg->connection = connection; + + return pg; + +} + +int pg_check_connection(const char *rpname, PGconn *connection) { + if(!connection) { + log_ereport(LOG_FAILURE, "Resource pool %s: Cannot create PQ connection", rpname); + return 1; + } + if(PQstatus(connection) != CONNECTION_OK) { + char *err = PQerrorMessage(connection); + int errlen = 0; + if(err) { + errlen = strlen(err); + if(errlen > 0 && err[errlen-1] == '\n') { + errlen--; + } + } + log_ereport(LOG_FAILURE, "Resource pool %s: Failed to connect to database: %.*s", rpname, errlen, err); + PQfinish(connection); + return 1; + } + return 0; +} + + +void pg_resourcepool_destroy(PgResourcePool *pg) { + // unused +} + +void * pg_resourcepool_createresource(PgResourcePool *pg) { + PGconn *connection = PQconnectdb(pg->connection); + if(pg_check_connection(pg->name, connection)) { + return NULL; + } + + PgResource *res = pool_malloc(pg->pool, sizeof(PgResource)); + if(!res) { + PQfinish(connection); + log_ereport(LOG_CATASTROPHE, "pg_resourcepool_createresource: OOM"); + return NULL; + } + res->connection = connection; + + return res; +} + +void pg_resourcepool_freeresource(PgResourcePool *pg, PgResource *res) { + if(res->connection) { + PQfinish(res->connection); + } +} + +int pg_resourcepool_prepare(PgResourcePool *pg, PgResource *res) { + return 0; +} + +int pg_resourcepool_finish(PgResourcePool *pg, PgResource *res) { + return 0; +} + +void * pg_resourcepool_getresourcedata(PgResource *res) { + return res->connection; +} diff -r 3dfbd0b91950 -r 4cfaa02055cd src/server/plugins/postgresql/resource.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/server/plugins/postgresql/resource.h Sat Jan 22 19:13:40 2022 +0100 @@ -0,0 +1,91 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2022 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef RESOURCE_H +#define RESOURCE_H + +#include "../../public/nsapi.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct PgResourcePool { + /* + * ResourcePool parameters + */ + pblock *param; + + /* + * Cfg memorypool + */ + pool_handle_t *pool; + + /* + * ResourcePool name + */ + const char *name; + + /* + * connection string used for PQconnectdb + */ + char *connection; + + +} PgResourcePool; + +typedef struct PgResource { + PGconn *connection; +} PgResource; + +ResourceType* pg_get_resource_type(void); + +void * pg_resourcepool_init(pool_handle_t *pool, const char *rpname, pblock *pb); +void pg_resourcepool_destroy(PgResourcePool *pg); +void * pg_resourcepool_createresource(PgResourcePool *pg); +void pg_resourcepool_freeresource(PgResourcePool *pg, PgResource *res); +int pg_resourcepool_prepare(PgResourcePool *pg, PgResource *res); +int pg_resourcepool_finish(PgResourcePool *pg, PgResource *res); +void * pg_resourcepool_getresourcedata(PgResource *res); + +/* + * checks if conn is a working connection and logs an error message if not + * conn can be null (resulting in an error message) + * if conn is not null but the status is not CONNECTION_OK, + * conn will be destroyed + */ +int pg_check_connection(const char *rpname, PGconn *connection); + +#ifdef __cplusplus +} +#endif + +#endif /* RESOURCE_H */ + diff -r 3dfbd0b91950 -r 4cfaa02055cd src/server/public/nsapi.h --- a/src/server/public/nsapi.h Sat Jan 22 11:06:11 2022 +0100 +++ b/src/server/public/nsapi.h Sat Jan 22 19:13:40 2022 +0100 @@ -358,9 +358,6 @@ #ifndef HPUX #include #endif -#ifndef BSD -#include /* new */ -#endif #include #include #include @@ -770,14 +767,22 @@ typedef struct ResourceType ResourceType; typedef struct ResourceData ResourceData; +typedef void * (*resource_pool_init_func)(pool_handle_t *, const char *, pblock *); +typedef void (*resource_pool_destroy_func)(void *); +typedef void * (*resource_pool_createresource_func)(void *); +typedef void (*resource_pool_freeresource_func)(void *, void *); +typedef int (*resource_pool_prepare_func)(void *, void *); +typedef int (*resource_pool_finish_func)(void *, void *); +typedef void * (*resource_pool_getresourcedata_func)(void *); + struct ResourceType { - void * (*init)(pool_handle_t *, pblock *); + void * (*init)(pool_handle_t *, const char *, pblock *); void (*destroy)(void *); - void * (*createresource)(void *); void (*freeresource)(void *, void *); int (*prepare)(void *, void *); int (*finish)(void *, void *); + void * (*getresourcedata)(void *); }; struct ResourceData { @@ -785,6 +790,8 @@ void *data; }; +int resourcepool_register_type(const char *type_name, ResourceType *type_info); + ////// /* * VSInitFunc, VSDestroyFunc, VSDirectiveInitFunc and VSDirectiveDestroyFunc