Commit Graph

61 Commits

Author SHA1 Message Date
Joris Vink
090e2cc6a2 Debug builds imply NOOPT 2016-02-13 14:21:09 +01:00
Joris Vink
1f5e482b8a Build option changes.
- Build with -O2 unless NOOPT is set to 1.
- Hide -g behind DEBUG instead of always building with it.
- Explicitely set the standard used to c99, use pedantic.
2016-02-01 15:33:40 +01:00
Joris Vink
b4611ee38d Kill off zlib_dict.c 2015-12-04 14:11:37 +01:00
Joris Vink
769c78a6e8 Introduce NOHTTP=1 build option.
This basically turns off the HTTP layer for Kore. It does not
compile in anything for HTTP.

This allows Kore to be used as a network application platform as well.
Added an example for this called nohttp.

Other changes that sneaked in while hacking on this:
* Use calloc(), kill pendantic malloc option.
* Killed off SPDY/3.1 support completely, will be superseded by http2

Note that comes with massive changes to a lot of the core API
functions provided by Kore, these might break your application.
2015-11-27 16:22:50 +01:00
Nandor Kracser
3633270de3 Don't link object files if not needed 2015-07-25 19:10:48 +02:00
Joris Vink
49ca95f390 Add our messaging framework.
With this framework apps can now send messages between worker processes.

A new API function exists:
	int kore_msg_register(u_int8_t id, void (*cb)(const void *, u_int32_t);

This API call allows your app to register a new message callback for a given ID.

You can then send messages on this ID to other workers using:
	void kore_msg_send(u_int8_t id, void *data, u_int32_t length);

This framework will interally be used for a few things such as allowing
websocket data to broadcasted between all workers, adding unified caching
and hopefully eventually moving the access log to this as well.

Some internals have changed with this commit:
	* worker_clients has been called connections.
	* the parent now initializes the net, and event subsystems.
	* kore_worker_websocket_broadcast() is dead.
2015-06-22 21:13:32 +02:00
Geenz
817b916e1f Call it NOTLS instead.
Per @jorisvink's feedback.
2015-05-25 09:42:34 -04:00
Geenz
c44de3f629 Rename BENCHMARK to reflect its actual function.
NO_SSL makes a bit more sense, especially for people who proxy their requests via nginx, apache, or similar.
2015-05-25 09:28:13 -04:00
Joris Vink
2ee09b6a43 Kill lingering PHONY target. 2015-05-21 14:59:56 +02:00
Thordur Bjornsson
abacc14a2c top level dockerfile not generally useful.
So, garbage collect.
2015-05-21 14:42:25 +02:00
Thordur Bjornsson
9c2e902b81 Contain the kore.
Add a top level Dockerfile, not really useful for anything besides
hacking on kore. See `make contain`;

Add docker top level directory, it contains an `app` container,
with a `kore run` ENTRYPOINT, an example of using that image is

   FROM kore/app

   COPY . myapp
   CMD ["myapp"]

There is also a `build` image, which is the base for both aforementioned
containers.
2015-05-20 16:31:28 +02:00
Joris Vink
d6ab1d7445 Add rudimentary timers to Kore.
Timers are in ms resolution and are added using
kore_timer_add(cb, interval, flags).

Both oneshot timers and continious timers are supported.
2015-04-06 18:54:35 +02:00
Andreas Pfohl
24e1d3928d Added ability to set path prefix during make. 2014-12-12 10:15:30 +01:00
Joris Vink
8fe16c193a Link with -lcrypto even for BENCHMARK 2014-11-24 11:31:50 +01:00
Joris Vink
f867882f43 Add websocket support to Kore.
Introduces a few new api functions:

- kore_websocket_handshake(struct http_request *):
	Performs the handshake on an HTTP request (coming from page handler)

- kore_websocket_send(struct connection *, u_int8_t, void *, size_t):
	Sends data to a websocket connection.

- kore_websocket_broadcast(struct connection *, u_int8_t, void *, size_t, int):
	Broadcast the given websocket op and data to all connected
	websocket clients on the worker. Note that as of right now
	the WEBSOCKET_BROADCAST_GLOBAL scope option does not work
	yet and messages broadcasted will be restricted to workers
	only.

- kore_worker_websocket_broadcast(struct connection *, void *, void *):
	Backend function used by kore_websocket_broadcast().
	Could prove useful for developers to have access to.

A simple example is given under examples/websocket.

Known issues:
	Kore does not support PING or CONT frames just yet.
2014-11-24 11:08:34 +01:00
Thordur Bjornsson
c271ea6b3e Honor CC from the environment. 2014-10-22 17:02:25 +02:00
Joris Vink
b668125ff7 Allow kore to build with openssl from osx brew. 2014-10-13 11:53:56 +02:00
Joris Vink
2b40672ba1 When compiling with PGSQL, note the include dir for "kore build" 2014-08-03 17:33:40 +02:00
Joris Vink
c078c8a306 Correct order for linking 2014-08-02 13:01:58 +02:00
Joris Vink
ea5b89d20b Move orbit functionality into kore directly.
Makes more sense and reads easier:

kore create myapp
kore build myapp
kore run myapp

Note that kore retains its cli options (if no command was given),
meaning you can still start kore in the traditional way as well.

The command options are simply to make development easier.
2014-08-01 13:59:47 +02:00
Joris Vink
0c21c08b6d Hook orbit into the build 2014-08-01 10:46:50 +02:00
Joris Vink
c2e4d55235 Add a BENCHMARK compile option which compiles without OpenSSL.
Personally use this for testing Kore its performance without
letting the OpenSSL stack get in the way too much.

Note that it leaves data structures as is, and just removes
any calls to OpenSSL (and removes the linking vs OpenSSL).
2014-08-01 10:22:32 +02:00
Joris Vink
b6a778a4a5 Install kore headers under /usr/local/include/kore 2014-07-03 22:39:16 +02:00
Joris Vink
4f126f51d3 Add install/uninstall targets. 2014-07-03 21:38:16 +02:00
Joris Vink
be4b1c7e7b Move actual code out of contrib into src/. 2014-07-02 12:19:38 +02:00
Joris Vink
cf700b34f7 Add initial stab at asynchronous background tasks.
More to follow.
2014-06-28 16:17:18 +02:00
Joris Vink
d98d56fb20 Add KORE_PENDANTIC_MALLOC option.
This option tells Kore to zero out memory when allocated, freed or
when get/put from the pools.
2014-04-22 12:46:23 +02:00
Joris Vink
89b603c247 Support postgresl under the bsds 2014-04-02 00:06:24 +02:00
Joris Vink
22882261f7 Properly use pg_config --includedirs + move modules to contrib 2014-03-31 11:29:51 +02:00
Joris Vink
2f044cc7eb Initial stab at entering postgresql contrib code.
Has support for full async pgsql queries. Most of the logic
is hidden behind a KORE_PGSQL() macro allowing you to insert
these pgsql calls in your page handlers without blocking the
kore worker while the query is going off.

There is place for improvement here, and perhaps KORE_PGSQL won't
stay as I feel this might overcomplicate things instead of making
them simpler as I thought it would.
2014-03-30 23:54:35 +02:00
Joris Vink
9a8092bf41 Add authentication blocks for Kore.
Using authentication blocks one can define "authentication" mechanisms
in Kore for page handlers.

This can be used to require a session cookie (validated by your own validator)
for certain page handlers, and hopefully in the future provide a framework
for adding more authentication things (like HTTP Auth).

Right now only cookie checking is available.
2014-01-22 22:55:10 +01:00
Joris Vink
b647afcc4f fix brocken DEBUG define 2013-11-21 12:00:07 +01:00
Thordur Bjornsson
302c3b6c9d If DEBUG is set in the environment, define KORE_DEBUG 2013-11-19 13:10:01 +01:00
Thordur Bjornsson
f9cac98ab5 Detect OS rather then supplying a build target 2013-11-19 13:10:01 +01:00
Joris Vink
34c2f31a93 Add validators to kore, specified in the configuration using 'validator' keyword.
Example:
	validator	v_id	function	v_id_function
	validator	v_url	regex		^/url/path/[a-z]*$

You can then call these using kore_validator_run(char *, char *), example:

	if (!kore_validator_run("v_url", req->path))
		[req->path is bad];
2013-11-09 16:21:52 +01:00
Joris Vink
89f12a61e5 Add osx to makefile options.
From Vaibhav Bhembre via github
2013-07-28 20:02:01 +02:00
Joris Vink
91b839f355 Add OSX support, buildable via "make osx".
Make sure you have OpenSSL 1.0.0d+ (available from Macports) installed.

Based on diff from Vaibhav Bhembre via github
2013-07-17 20:19:44 +02:00
Joris Vink
29fa49ba83 Add fixed size memory pools and use them throughout Kore. 2013-07-15 11:06:36 +02:00
Joris Vink
c1723f2db5 Clean up header includes, based on a diff from Ewan Higgs via github.
And while we're messing in it, make sure bsd.c compiles again.
2013-07-06 20:55:22 +02:00
Joris Vink
b4a0330a96 - Better spread load between all worker processes.
- Introduce own memory management system on top of malloc to keep track
  of all our allocations and free's. Later we should introduce a pooling
  mechanism for fixed size allocations (http_request comes to mind).
- Introduce ssl_cipher in configuration.

Memory usage is kind of high right now, but it seems its OpenSSL
doing it rather then Kore.
2013-06-27 08:43:07 +02:00
Joris Vink
f707749cf4 no longer hold static openssl libs in the repo. 2013-06-26 19:05:54 +02:00
Joris Vink
0dda6f996f Add a form of synchronization between what worker will be accepting
new connections and which ones will not be notified for it.

Fixes the thundering herd problem, and nicely spreads out load between
all the workers equally. A configuration option (workers_max_connections)
is available to tweak how many connections a worker will have before
giving up the accept lock.

Two ways are added to this commit for access locking:
- Locking via semaphores.
- Locking via GCC's builtin atomic methods.

The default is running with semaphores disabled (OpenBSD cannot do
sem_init() with pshared set to 1, which is required).

If you want to use semaphores add KORE_USE_SEMAPHORES to CFLAGS,
and -lpthread to LDFLAGS in the Makefile.

Other fixes:
- BSD: add a timeout to kevent().
- Merge kore_worker_wait together, linux knows waitpid() as well.
- Send the correct SIGQUIT signal to workers instead of SIGINT.
- Fix kore_time_ms().
- Log fatal worker messages in syslog.
- Refactor code even more.
- Do not free our own kore_worker structure.
2013-06-26 16:37:22 +02:00
Joris Vink
3e5c17b8a3 refactor code quite a bit. 2013-06-26 11:18:32 +02:00
Joris Vink
6026a6d4ee add SNI support, and change domain configuration a bit. 2013-06-24 11:32:45 +02:00
Joris Vink
a1b400c400 Add access logging to Kore. 2013-06-24 09:36:40 +02:00
Joris Vink
25f1ab9865 Add BSD kqueue(2) support. Compile with make bsd (or make linux for linux) 2013-06-17 23:39:17 +02:00
Joris Vink
98de763632 s/light/kore 2013-06-17 23:54:59 +02:00
Joris Vink
0de28488a6 move from multithreads to single threaded worker processes. 2013-06-04 11:55:38 +02:00
Joris Vink
9243f409cc move to a worker based threading approach where we delegate http requests to workers in a round robin basis (later this should be swapped to find the laziest worker and assign the request to that instead). 2013-05-30 19:36:42 +02:00
Joris Vink
8478d8df54 add chroot and runas directives so we can chroot and drop privilegs properly 2013-05-04 22:18:27 +02:00