1
0
mirror of https://git.kore.io/kore.git synced 2024-11-15 22:46:21 +01:00
Commit Graph

630 Commits

Author SHA1 Message Date
Joris Vink
0542d70a71 Use a single header_buf in http_response_normal()
Avoids constantly allocating and freeing buffers all the time.
This can be done safely due to the fact workers are single threaded.
2014-08-22 14:38:48 +02:00
Joris Vink
71fb54aab7 Replace - as well when building asset names 2014-08-21 23:06:54 +02:00
Joris Vink
7e74cd6e62 Introduce a wait queue for our pgsql code.
Instead of letting http_requests spin, if we cannot allocate
a connection for the request we will queue them up put them to sleep.

When a connection becomes available, we'll wake up a request that
was waiting for a connection and let it continue.

This completely avoids consuming massive amounts of cpu time
when dealing with thousands of requests waiting for a pgsql
worker to become ready.
2014-08-21 16:36:12 +02:00
Joris Vink
c063dd52f6 epoll improvements.
* check for EPOLLRDHUP
* in kore_platform_schedule_read() don't use EPOLLET
2014-08-21 16:33:11 +02:00
Joris Vink
a197bd9bac turn status into an u_int16_t 2014-08-21 13:52:27 +02:00
Joris Vink
d3149a2a71 We need at most 2 tokens here 2014-08-18 21:13:16 +02:00
Joris Vink
69f98ef158 Add root/src/includes as an include path when building 2014-08-18 18:56:22 +02:00
Joris Vink
68e0697f2e s/appl/rootdir in cli_compile_file 2014-08-18 15:31:10 +02:00
Joris Vink
83a16763c8 Always NUL-terminate an asset its data.
This way developers can cast assets to char * without first
having to convert it to a proper C string.

The NUL character is NOT included in the length of the asset.
2014-08-18 13:57:06 +02:00
Joris Vink
105804e325 Make http_status_text() return a const char 2014-08-18 10:37:13 +02:00
Joris Vink
873c68b515 Make http_status_text() available everywhere 2014-08-18 10:34:47 +02:00
Joris Vink
6e6b042388 Add KORE_PGSQL_STATE_WAIT to our example 2014-08-15 12:39:31 +02:00
Joris Vink
8565b47800 Attach tasks/pgsqls to http_requests once more.
This way if an http request is removed while tasks or
pgsqls are still active they are free'd out and cancelled
properly.
2014-08-14 22:05:34 +02:00
Joris Vink
f021c8db44 pgsql improvements
* set pgsql->result to NULL when we freed it
* drain the connection pipe just in case in pgsql_conn_release()
2014-08-14 16:43:40 +02:00
Joris Vink
0b3c918ba6 Properly check for connection trouble in the pgsql example 2014-08-14 15:13:47 +02:00
Joris Vink
9ea1e3cb57 Properly release pgsql connection if needed 2014-08-14 14:46:21 +02:00
Joris Vink
f93747828c Major pgsql rework.
Gone is the ugly KORE_PGSQL macro that hid an overly complex
state machine for the pgsql api.
Gone is the pgsql array that was attached to http_requests.
Gone are the callback hacks inside the pgsql api.

Instead, I strongly encourage people to use the new state machine
api Kore offers to properly deal with asynchronous queries.

The pgsql example in examples/pgsql has been updated to reflect
these changes.
2014-08-14 14:34:23 +02:00
Joris Vink
856d7b0cb2 Rename HTTP_STATE_OK to HTTP_STATE_CONTINUE 2014-08-14 11:20:04 +02:00
Joris Vink
210fb05a35 Add a hopefully easy to use and optional fsm for page handlers
In order to use this, define states for your page handler:

struct http_state mystates[] = {
	{ "PAGE_STATE_INIT",	page_init },
	{ "PAGE_STATE_RESULT",	page_result },
};

In your page handler you can then simply call http_state_run() with
your states and http_request. This will cause Kore to start calling
your state callbacks beginning at index 0.

State callbacks have the same prototype as page handlers:

int	func(struct http_request *);

However, unlike page handlers they MUST return one of the following:

- HTTP_STATE_OK:	All good, just continue the fsm.
- HTTP_STATE_ERROR:	Abort fsm and return KORE_RESULT_OK to Kore
			(This will cancel the http request).
- HTTP_STATE_RETRY:	Return KORE_RESULT_RETRY to Kore.
			(Kore will retry your page handler next event loop).
- HTTP_STATE_COMPLETE:	The fsm completed, break out cleanly.

Note that using this is completely optional and you can still
use the traditional way of writing page handlers.

The fsm is designed to get rid of the clutter that exists today
in Kore when dealing with non blocking tasks or pgsql calls.
2014-08-13 23:34:30 +02:00
Joris Vink
2e7d6a12a9 closedir() when we're ready traversing it 2014-08-13 14:32:57 +02:00
Joris Vink
29afdd0b21 Make sure opt always contains what we want 2014-08-13 14:32:49 +02:00
Joris Vink
e0cdc31c73 Take away the reference to the video if we're not streaming 2014-08-12 09:43:19 +02:00
Joris Vink
0b907312ef let kore build generate certs with a more unique issuer
also fix spacing and asset print information.
2014-08-11 16:11:37 +02:00
Joris Vink
d74f039a0c When building assets replace bad characters with an underscore 2014-08-11 13:08:26 +02:00
Joris Vink
7349fab13f Sprinkle kore_snprintf() where appropriate. 2014-08-11 11:02:30 +02:00
Joris Vink
70d9df8896 s/id/user 2014-08-11 11:01:59 +02:00
Joris Vink
97c17f724b Add kore_snprintf() as a wrapper around snprintf(). 2014-08-11 10:45:10 +02:00
Joris Vink
4a4fa4889e Another round of spdy/3.1 improvements.
* Implement flow control window updates if we're receiving data (POSTs)
2014-08-10 21:39:47 +02:00
Joris Vink
1616320490 Add an html5 video streaming example 2014-08-10 19:33:43 +02:00
Joris Vink
c665b7d926 Add a callback to http_response_stream().
This way we can get our code called whenever a stream is
completed. This cb handler does stand alone from an http_request
and is passed a netbuf data structure.
2014-08-10 18:46:44 +02:00
Joris Vink
10284d59b6 Another round of spdy/3.1 improvements.
* Always make sure we end the stream properly
* Check for SPDY_FLOW_WINDOW_MAX on window frame updates
* Kill SPDY_STREAM_BLOCKING, once flow control kicks in its per session
2014-08-10 18:18:27 +02:00
Joris Vink
1ef0f3423b Bump to spdy/3.1 2014-08-08 14:48:51 +02:00
Joris Vink
5cca2f1f78 properly implement spdy/3.1 flow control 2014-08-08 14:18:15 +02:00
Joris Vink
d2c65b4f62 Change http_response_stream() to only take a base + len 2014-08-07 14:31:45 +02:00
Joris Vink
cda09b6065 Add http_response_stream() which can stream data from a buffer to the client. 2014-08-07 14:23:26 +02:00
Joris Vink
e3ae1b4e2d Implement some great SPDY improvements.
* Bump spdy announcement to the correct draft version
* When receiving a RST, clean out the netbuf chain of that stream
2014-08-07 10:22:54 +02:00
Joris Vink
966ed3d20d Rename the two functions used to read/set headers.
Rename http_request_header_get() to http_request_header().
Rename http_response_header_add() to http_response_header().
2014-08-05 14:26:31 +02:00
Joris Vink
0413de6a8f fatal if the return value from a page handler isn't what we want. 2014-08-05 14:17:23 +02:00
Joris Vink
b27322933b The default pid file is kore.pid so no need to set that explicitely 2014-08-05 13:11:53 +02:00
Joris Vink
891f3454ce Move the default pid file to kore.pid instead of /var/run/kore.pid 2014-08-05 13:10:34 +02:00
Joris Vink
577462379d Deprecate ssl_no_compression config option, its always on. 2014-08-05 13:07:32 +02:00
Joris Vink
79a736fc16 Add a link to yajl repo 2014-08-04 21:06:35 +02:00
Joris Vink
0c5b0d2288 Add an example that parses JSON via yajl 2014-08-04 21:06:02 +02:00
Joris Vink
b0700162c4 Make http_post_data_bytes() and http_post_data_text() available 2014-08-04 21:03:26 +02:00
Joris Vink
9b3ff7db53 Lowercase the HTTP headers sent in normal HTTP responses.
SPDY already had this, as required by the spec.
2014-08-04 20:12:31 +02:00
Joris Vink
9dbcf5399f Add headers example 2014-08-04 20:06:59 +02:00
Joris Vink
4010bdd58d Remove kore_cb and its related settings.
After revisiting why this exists in Kore I decided it
does not belong in this platform and instead of letting
it sit there staring at me I rather just kill it.
2014-08-04 19:54:32 +02:00
Joris Vink
b3f65ae13f Add a readme to parameters + update some text 2014-08-04 19:02:23 +02:00
Joris Vink
4a7653f195 Add a parameters example.
This example shows how the parameter system in Kore works
and how to use it properly.
2014-08-04 19:00:25 +02:00
Joris Vink
0b36877736 Change kore_buf_appendv() to use vasprintf(). 2014-08-04 18:59:59 +02:00