kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit a3ed3bf7ebdf5da31d4627717c28fab5e94bc368
parent 59f7e85f459cb4bd2e2d5f0394a546d1ac598b00
Author: Joris Vink <joris@coders.se>
Date:   Fri, 24 Mar 2017 13:00:05 +0100

Convert pgsql-sync example after pgsql changes.

Only check if we bound something if we're asynchronous.

Diffstat:
examples/pgsql-sync/src/pgsql-sync.c | 4+++-
src/pgsql.c | 8+++++---
2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/examples/pgsql-sync/src/pgsql-sync.c b/examples/pgsql-sync/src/pgsql-sync.c @@ -49,6 +49,8 @@ page(struct http_request *req) req->status = HTTP_STATUS_INTERNAL_ERROR; + kore_pgsql_init(&sql); + /* * Initialise our kore_pgsql data structure with the database name * we want to connect to (note that we registered this earlier with @@ -56,7 +58,7 @@ page(struct http_request *req) * query (KORE_PGSQL_SYNC) and we do not need to pass our http_request * so we pass NULL instead. */ - if (!kore_pgsql_query_init(&sql, NULL, "db", KORE_PGSQL_SYNC)) { + if (!kore_pgsql_setup(&sql, "db", KORE_PGSQL_SYNC)) { kore_pgsql_logerror(&sql); goto out; } diff --git a/src/pgsql.c b/src/pgsql.c @@ -110,9 +110,11 @@ kore_pgsql_setup(struct kore_pgsql *pgsql, const char *dbname, int flags) return (KORE_RESULT_ERROR); } - if (pgsql->req == NULL && pgsql->cb == NULL) { - pgsql_set_error(pgsql, "nothing was bound"); - return (KORE_RESULT_ERROR); + if (flags & KORE_PGSQL_ASYNC) { + if (pgsql->req == NULL && pgsql->cb == NULL) { + pgsql_set_error(pgsql, "nothing was bound"); + return (KORE_RESULT_ERROR); + } } db = NULL;