Commit Graph

564 Commits

Author SHA1 Message Date
Joris Vink 693a07250f bump copyright years 2014-10-14 16:18:23 +02:00
Joris Vink d142db2f45 Bump 2014-10-14 16:16:06 +02:00
Joris Vink 16f2d00d37 No more SSLv3 allowed. 2014-10-14 15:03:04 +02:00
Joris Vink 5855a88862 Increase frequency of idle_check. 2014-10-13 16:34:42 +02:00
Joris Vink b668125ff7 Allow kore to build with openssl from osx brew. 2014-10-13 11:53:56 +02:00
Joris Vink 2b2e765fe6 Allow 0 parameters for kore_pgsql_query_params() 2014-10-12 01:17:35 +02:00
Joris Vink a603b77e24 Add PUT/DELETE/HEAD methods (finally).
This commit renames certain POST centric variable and configuration
naming to the correct HTTP body stuff.

API changes include http_postbody_text() and http_postbody_bytes() to
have become http_body_text() and http_body_bytes().

The developer is still responsible for validating the method their
page handler is called with. Hopefully this becomes a configuration
option soon enough.
2014-10-08 11:03:14 +02:00
Joris Vink 3741e8ca3f Merge pull request #20 from jturner/openbsd-fix
Add required header for proper OpenBSD checking
2014-10-01 21:59:22 +02:00
James Turner 215a4d2da2 Add required header for proper OpenBSD checking 2014-10-01 13:08:38 -04:00
Joris Vink 626206f0d8 Set idle_timer.length in ktunnel to a high number.
This makes my tunnels not timeout every 20 seconds, much nicer.
2014-09-29 14:47:01 +02:00
Joris Vink e1be630b84 Add kore_pgsql_getlength() which will return length of a column. 2014-09-28 23:03:49 +02:00
Joris Vink 3b09683f5c Add kore_pgsql_query_params().
This function uses PQsendQueryParams() instead of the normal PQsendQuery()
allowing you to pass binary data in a cleaner fashion.

A basic call would look something like:

char *mydata = "Hello";
size_t mydata_len = strlen(mydata);

kore_pgsql_query_params(&pgsql, req,
    "INSERT INTO foo VALUES($1::text)", KORE_PGSQL_FORMAT_TEXT, 1
    mydata, mydata_len, KORE_PGSQL_FORMAT_TEXT);

kore_pgsql_query_params() is variadic, allowing you to pass any
count of parameters where each parameter has the following:
	data pointer, data length, type of parameter.
2014-09-28 21:39:16 +02:00
Joris Vink 0909e6bac1 Write our assets.h with a fixed include guard. 2014-09-26 15:50:56 +02:00
Joris Vink 1c83af511d Make kore_mem_free() behave like free() and don't do anything if NULL is passed in. 2014-09-25 22:20:47 +02:00
Joris Vink e3417dea16 Remove the pgsql simple layer again.
I rather keep the old idioms instead of adding more complex things
on top of the async ones. Especially since the simple layer would
interfear with existing http state machines from your handler.
2014-09-19 15:53:22 +02:00
Joris Vink f73557c545 Use proper error message 2014-09-19 15:01:56 +02:00
Joris Vink efec7bf8cf No need to set l here 2014-09-19 15:01:45 +02:00
Joris Vink c0c3e9fb05 Use s instead of req->stream. 2014-09-19 15:01:25 +02:00
Joris Vink eef40bf2dd add a .gitignore here 2014-09-19 14:51:14 +02:00
Joris Vink c4c60e1960 Oops, make sure the new simple api can handle > 1 request without borking. 2014-09-19 14:49:12 +02:00
Joris Vink f6f37437da In pgsql_simple_state_result() be sure to progress the sql state.
Drop back into waiting after our result so we can properly read out
the completed state.
2014-09-19 12:51:37 +02:00
Joris Vink ee52746a7a indenting 2014-09-19 12:38:52 +02:00
Joris Vink 8e9c3da764 Add a new "simple query" layer to our pgsql api.
This simple query allows you to ditch rolling your own
state machine for handling async pgsql states and instead
asks you to provide 3 functions:
	- init
	- results
	- done

You can see the different in complexity in the pgsql example,
which now contains a pgsql_simple.c holding the same asynchronous
query as in pgsql.c but using the simple pgsql api.

You can of course still roll your own in case you want more control.
2014-09-19 12:32:49 +02:00
Joris Vink 0e11edefb5 s/HTTP_STATUS_RETRY/HTTP_STATE_RETRY 2014-09-19 11:16:56 +02:00
Joris Vink 73055662de Remove start from pgsql_job 2014-09-18 10:49:15 +02:00
Joris Vink 8982a7b3c9 Disable timeouts for ktunnel 2014-09-18 10:30:59 +02:00
Joris Vink 34d146fc01 Fix ktunnel compilation under BSDs 2014-09-18 09:52:48 +02:00
Joris Vink 59a1a05afe No need to set now at the start, thanks clang. 2014-09-18 08:42:41 +02:00
Joris Vink c5f00d3443 Add KTunnel example, an anything-over-HTTPS tunnel using Kore. 2014-09-17 08:53:13 +02:00
Joris Vink 49e97ae6f8 Call kore_connection_disconnect() when draining connections.
This way the disconnect callbacks are called properly when
workers are exiting.
2014-09-17 08:46:55 +02:00
Joris Vink 7771adbec2 Allow applications to create new connections in our event loop. 2014-09-17 08:25:45 +02:00
Joris Vink b2f870a36f bump to 1.2-current and link to tarball 2014-08-26 00:34:29 +02:00
Joris Vink f3e863a482 Properly end headers when doing status codes only. 2014-08-25 10:58:34 +02:00
Joris Vink fa69f2a49c Attempt vsnprintf() up to BUFSIZ in kore_buf_appendv().
If the result was too large fall back to vasprintf instead.
2014-08-22 14:40:19 +02:00
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