kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 89b603c2476a1d6319606bffabf4e70eb6f44cfa
parent 211f82847eee1aeb112dc4bb3e7c5646ae967fc3
Author: Joris Vink <joris@coders.se>
Date:   Wed,  2 Apr 2014 00:06:24 +0200

Support postgresl under the bsds

Diffstat:
Makefile | 2+-
src/bsd.c | 37+++++++++++++++++++++++++++++++++++--
2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile @@ -20,7 +20,7 @@ endif ifneq ("$(PGSQL)", "") S_SRC+=contrib/postgres/kore_pgsql.c - LDFLAGS+=-lpq + LDFLAGS+=-L$(shell pg_config --libdir) -lpq CFLAGS+=-I$(shell pg_config --includedir) -DKORE_USE_PGSQL endif diff --git a/src/bsd.c b/src/bsd.c @@ -23,6 +23,10 @@ #include "kore.h" +#if defined(KORE_USE_PGSQL) +#include "contrib/postgres/kore_pgsql.h" +#endif + static int kfd = -1; static struct kevent *events; static u_int32_t nchanges; @@ -107,12 +111,20 @@ kore_platform_event_wait(void) if (type == KORE_TYPE_LISTENER) fatal("error on server socket"); +#if defined(KORE_USE_PGSQL) + if (type == KORE_TYPE_PGSQL_CONN) { + kore_pgsql_handle(events[i].udata, 1); + continue; + } +#endif + c = (struct connection *)events[i].udata; kore_connection_disconnect(c); continue; } - if (type == KORE_TYPE_LISTENER) { + switch (type) { + case KORE_TYPE_LISTENER: l = (struct listener *)events[i].udata; while ((worker->accepted < worker->accept_treshold) && @@ -128,7 +140,8 @@ kore_platform_event_wait(void) kore_platform_event_schedule(c->fd, EVFILT_WRITE, EV_ADD | EV_ONESHOT, c); } - } else { + break; + case KORE_TYPE_CONNECTION: c = (struct connection *)events[i].udata; if (events[i].filter == EVFILT_READ && !(c->flags & CONN_READ_BLOCK)) @@ -146,6 +159,14 @@ kore_platform_event_wait(void) c); } } + break; +#if defined(KORE_USE_PGSQL) + case KORE_TYPE_PGSQL_CONN: + kore_pgsql_handle(events[i].udata, 0); + break; +#endif + default: + fatal("wrong type in event %d", type); } } } @@ -181,6 +202,18 @@ kore_platform_disable_accept(void) } void +kore_platform_schedule_read(int fd, void *data) +{ + kore_platform_event_schedule(fd, EVFILT_READ, EV_ADD, data); +} + +void +kore_platform_disable_read(int fd) +{ + kore_platform_event_schedule(fd, EVFILT_READ, EV_DELETE, NULL); +} + +void kore_platform_proctitle(char *title) { #ifndef __MACH__