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 2c6b5e6b0f81f0db0133db08b9bfa7f1b006c3ab
parent 4f126f51d3b1f9d2fbd76a9fe5634b26b2b2a483
Author: Joris Vink <joris@coders.se>
Date:   Thu,  3 Jul 2014 22:14:46 +0200

Normalize kore_*.h headers

Diffstat:
includes/kore_pgsql.h | 77-----------------------------------------------------------------------------
includes/kore_tasks.h | 64----------------------------------------------------------------
includes/pgsql.h | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
includes/tasks.h | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/bsd.c | 4++--
src/http.c | 4++--
src/linux.c | 4++--
src/pgsql.c | 2+-
src/tasks.c | 2+-
src/worker.c | 4++--
10 files changed, 151 insertions(+), 151 deletions(-)

diff --git a/includes/kore_pgsql.h b/includes/kore_pgsql.h @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2014 Joris Vink <joris@coders.se> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _H_KORE_PGSQL -#define _H_KORE_PGSQL - -#include <libpq-fe.h> - -struct kore_pgsql { - u_int8_t state; - char *error; - PGresult *result; - void *conn; -}; - -extern char *pgsql_conn_string; - -void kore_pgsql_init(void); -void kore_pgsql_handle(void *, int); -void kore_pgsql_cleanup(struct http_request *); -void kore_pgsql_continue(struct http_request *, int); -int kore_pgsql_query(struct http_request *, char *, int); - -int kore_pgsql_ntuples(struct kore_pgsql *); -void kore_pgsql_logerror(struct kore_pgsql *); -char *kore_pgsql_getvalue(struct kore_pgsql *, int, int); - -#define KORE_PGSQL_STATE_INIT 1 -#define KORE_PGSQL_STATE_WAIT 2 -#define KORE_PGSQL_STATE_RESULT 3 -#define KORE_PGSQL_STATE_ERROR 4 -#define KORE_PGSQL_STATE_DONE 5 -#define KORE_PGSQL_STATE_COMPLETE 6 - -#define KORE_PGSQL(r, q, i, s) \ - do { \ - if (r->pgsql[i] == NULL) \ - if (!kore_pgsql_query(r, q, i)) { \ - if (r->pgsql[i] == NULL) \ - return (KORE_RESULT_RETRY); \ - s; \ - r->pgsql[i]->state = \ - KORE_PGSQL_STATE_COMPLETE; \ - } \ - if (r->pgsql[i] == NULL) \ - return (KORE_RESULT_RETRY); \ - switch (r->pgsql[i]->state) { \ - case KORE_PGSQL_STATE_ERROR: \ - case KORE_PGSQL_STATE_RESULT: \ - s; \ - case KORE_PGSQL_STATE_COMPLETE: \ - break; \ - default: \ - kore_pgsql_continue(r, i); \ - return (KORE_RESULT_RETRY); \ - } \ - if (r->pgsql[i]->state == KORE_PGSQL_STATE_ERROR || \ - r->pgsql[i]->state == KORE_PGSQL_STATE_RESULT) { \ - kore_pgsql_continue(r, i); \ - return (KORE_RESULT_RETRY); \ - } \ - } while (0); - -#endif diff --git a/includes/kore_tasks.h b/includes/kore_tasks.h @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2014 Joris Vink <joris@coders.se> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef __H_KORE_TASKS -#define __H_KORE_TASKS - -#define KORE_TASK_STATE_CREATED 1 -#define KORE_TASK_STATE_RUNNING 2 -#define KORE_TASK_STATE_FINISHED 3 - -struct http_request; - -struct kore_task { - u_int8_t type; - volatile u_int8_t state; - volatile int result; - - struct http_request *req; - int fds[2]; - int (*entry)(struct kore_task *); - - struct kore_task_thread *thread; - TAILQ_ENTRY(kore_task) list; -}; - -struct kore_task_thread { - u_int8_t idx; - pthread_t tid; - pthread_mutex_t lock; - pthread_cond_t cond; - TAILQ_HEAD(, kore_task) tasks; - - TAILQ_ENTRY(kore_task_thread) list; -}; - -void kore_task_init(void); -void kore_task_run(struct kore_task *); -void kore_task_finish(struct kore_task *); -void kore_task_destroy(struct kore_task *); -int kore_task_finished(struct kore_task *); -void kore_task_handle(struct kore_task *, int); - -void kore_task_bind_request(struct kore_task *, - struct http_request *); -void kore_task_create(struct kore_task **, - int (*entry)(struct kore_task *)); - -u_int32_t kore_task_channel_read(struct kore_task *, void *, u_int32_t); -void kore_task_channel_write(struct kore_task *, void *, u_int32_t); - -#endif diff --git a/includes/pgsql.h b/includes/pgsql.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014 Joris Vink <joris@coders.se> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _H_KORE_PGSQL +#define _H_KORE_PGSQL + +#include <libpq-fe.h> + +struct kore_pgsql { + u_int8_t state; + char *error; + PGresult *result; + void *conn; +}; + +extern char *pgsql_conn_string; + +void kore_pgsql_init(void); +void kore_pgsql_handle(void *, int); +void kore_pgsql_cleanup(struct http_request *); +void kore_pgsql_continue(struct http_request *, int); +int kore_pgsql_query(struct http_request *, char *, int); + +int kore_pgsql_ntuples(struct kore_pgsql *); +void kore_pgsql_logerror(struct kore_pgsql *); +char *kore_pgsql_getvalue(struct kore_pgsql *, int, int); + +#define KORE_PGSQL_STATE_INIT 1 +#define KORE_PGSQL_STATE_WAIT 2 +#define KORE_PGSQL_STATE_RESULT 3 +#define KORE_PGSQL_STATE_ERROR 4 +#define KORE_PGSQL_STATE_DONE 5 +#define KORE_PGSQL_STATE_COMPLETE 6 + +#define KORE_PGSQL(r, q, i, s) \ + do { \ + if (r->pgsql[i] == NULL) \ + if (!kore_pgsql_query(r, q, i)) { \ + if (r->pgsql[i] == NULL) \ + return (KORE_RESULT_RETRY); \ + s; \ + r->pgsql[i]->state = \ + KORE_PGSQL_STATE_COMPLETE; \ + } \ + if (r->pgsql[i] == NULL) \ + return (KORE_RESULT_RETRY); \ + switch (r->pgsql[i]->state) { \ + case KORE_PGSQL_STATE_ERROR: \ + case KORE_PGSQL_STATE_RESULT: \ + s; \ + case KORE_PGSQL_STATE_COMPLETE: \ + break; \ + default: \ + kore_pgsql_continue(r, i); \ + return (KORE_RESULT_RETRY); \ + } \ + if (r->pgsql[i]->state == KORE_PGSQL_STATE_ERROR || \ + r->pgsql[i]->state == KORE_PGSQL_STATE_RESULT) { \ + kore_pgsql_continue(r, i); \ + return (KORE_RESULT_RETRY); \ + } \ + } while (0); + +#endif diff --git a/includes/tasks.h b/includes/tasks.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014 Joris Vink <joris@coders.se> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef __H_KORE_TASKS +#define __H_KORE_TASKS + +#define KORE_TASK_STATE_CREATED 1 +#define KORE_TASK_STATE_RUNNING 2 +#define KORE_TASK_STATE_FINISHED 3 + +struct http_request; + +struct kore_task { + u_int8_t type; + volatile u_int8_t state; + volatile int result; + + struct http_request *req; + int fds[2]; + int (*entry)(struct kore_task *); + + struct kore_task_thread *thread; + TAILQ_ENTRY(kore_task) list; +}; + +struct kore_task_thread { + u_int8_t idx; + pthread_t tid; + pthread_mutex_t lock; + pthread_cond_t cond; + TAILQ_HEAD(, kore_task) tasks; + + TAILQ_ENTRY(kore_task_thread) list; +}; + +void kore_task_init(void); +void kore_task_run(struct kore_task *); +void kore_task_finish(struct kore_task *); +void kore_task_destroy(struct kore_task *); +int kore_task_finished(struct kore_task *); +void kore_task_handle(struct kore_task *, int); + +void kore_task_bind_request(struct kore_task *, + struct http_request *); +void kore_task_create(struct kore_task **, + int (*entry)(struct kore_task *)); + +u_int32_t kore_task_channel_read(struct kore_task *, void *, u_int32_t); +void kore_task_channel_write(struct kore_task *, void *, u_int32_t); + +#endif diff --git a/src/bsd.c b/src/bsd.c @@ -24,11 +24,11 @@ #include "kore.h" #if defined(KORE_USE_PGSQL) -#include "kore_pgsql.h" +#include "pgsql.h" #endif #if defined(KORE_USE_TASKS) -#include "kore_tasks.h" +#include "tasks.h" #endif static int kfd = -1; diff --git a/src/http.c b/src/http.c @@ -24,11 +24,11 @@ #include "http.h" #if defined(KORE_USE_PGSQL) -#include "kore_pgsql.h" +#include "pgsql.h" #endif #if defined(KORE_USE_TASKS) -#include "kore_tasks.h" +#include "tasks.h" #endif static char *http_status_text(int); diff --git a/src/linux.c b/src/linux.c @@ -22,11 +22,11 @@ #include "kore.h" #if defined(KORE_USE_PGSQL) -#include "kore_pgsql.h" +#include "pgsql.h" #endif #if defined(KORE_USE_TASKS) -#include "kore_tasks.h" +#include "tasks.h" #endif static int efd = -1; diff --git a/src/pgsql.c b/src/pgsql.c @@ -21,7 +21,7 @@ #include "kore.h" #include "http.h" -#include "kore_pgsql.h" +#include "pgsql.h" struct pgsql_job { u_int8_t idx; diff --git a/src/tasks.c b/src/tasks.c @@ -24,7 +24,7 @@ #include "kore.h" #include "http.h" -#include "kore_tasks.h" +#include "tasks.h" static u_int8_t threads; static pthread_mutex_t task_thread_lock; diff --git a/src/worker.c b/src/worker.c @@ -26,11 +26,11 @@ #include "http.h" #if defined(KORE_USE_PGSQL) -#include "kore_pgsql.h" +#include "pgsql.h" #endif #if defined(KORE_USE_TASKS) -#include "kore_tasks.h" +#include "tasks.h" #endif #if defined(WORKER_DEBUG)