FS-10167: Rewrote the ks_pool allocator, no longer uses paging or internal block allocation, but still retains reference counting and auto cleanup callbacks, should be much more efficient now on windows than the original mmap approach, and all tests now run successfully!

This commit is contained in:
Shane Bryldt committed 2017-04-11 14:43:00 -06:00
1 parent aaa26c6d09
commit ea0dc132a3
17 files changed
+524 -1677

No files matched your search

+2 -2
View File
@@ -312,7 +312,7 @@ KS_DECLARE(void) blade_connection_disconnect(blade_connection_t *bc)
{
ks_assert(bc);
if (bc->state != BLADE_CONNECTION_STATE_DETACH && bc->state != BLADE_CONNECTION_STATE_DISCONNECT) {
if (bc->state != BLADE_CONNECTION_STATE_DETACH && bc->state != BLADE_CONNECTION_STATE_DISCONNECT && bc->state != BLADE_CONNECTION_STATE_CLEANUP) {
ks_log(KS_LOG_DEBUG, "Connection (%s) disconnecting\n", bc->id);
blade_connection_state_set(bc, BLADE_CONNECTION_STATE_DETACH);
}
@@ -453,7 +453,7 @@ ks_status_t blade_connection_state_on_attach(blade_connection_t *bc)
callback = blade_connection_state_callback_lookup(bc, BLADE_CONNECTION_STATE_ATTACH);
if (callback) hook = callback(bc, BLADE_CONNECTION_STATE_CONDITION_POST);
if (hook == BLADE_CONNECTION_STATE_HOOK_DISCONNECT) blade_connection_disconnect(bc);
if (hook == BLADE_CONNECTION_STATE_HOOK_DISCONNECT) blade_connection_disconnect(bc);
else if (hook == BLADE_CONNECTION_STATE_HOOK_SUCCESS) {
// @todo this is adding a second lock, since we keep it locked in the callback to allow finishing, we don't want get locking here...
// or just try unlocking twice to confirm...
+1 -1
View File
@@ -77,7 +77,7 @@ KS_DECLARE(ks_status_t) blade_datastore_create(blade_datastore_t **bdsP, ks_pool
ks_assert(bdsP);
ks_assert(pool);
ks_assert(tpool);
//ks_assert(tpool);
bds = ks_pool_alloc(pool, sizeof(*bds));
bds->pool = pool;
+7 -4
View File
@@ -869,7 +869,7 @@ blade_connection_state_hook_t blade_transport_wss_on_state_disconnect(blade_conn
list_delete(&bt_wss->module->connected, bc);
if (bt_wss_init) blade_transport_wss_init_destroy(&bt_wss_init);
if (bt_wss) blade_transport_wss_destroy(&bt_wss);
if (bt_wss) blade_transport_wss_destroy(&bt_wss); // @TODO: Scream at this very loudly until I feel better for it wasting 2 days to track down, and then fix the issue it's causing
return BLADE_CONNECTION_STATE_HOOK_SUCCESS;
}
@@ -1092,6 +1092,8 @@ blade_connection_state_hook_t blade_transport_wss_on_state_attach_inbound(blade_
// behaviour to simply go as far as assigning a session to the connection and let the system handle the rest
if (json_req) cJSON_Delete(json_req);
if (json_res) cJSON_Delete(json_res);
return ret;
}
@@ -1223,6 +1225,7 @@ blade_connection_state_hook_t blade_transport_wss_on_state_attach_outbound(blade
done:
if (json_req) cJSON_Delete(json_req);
if (json_res) cJSON_Delete(json_res);
return ret;
}
@@ -1261,15 +1264,15 @@ blade_connection_state_hook_t blade_transport_wss_on_state_ready_outbound(blade_
if (condition == BLADE_CONNECTION_STATE_CONDITION_PRE) {
blade_session_t *bs = NULL;
cJSON *req = NULL;
//cJSON *req = NULL;
ks_log(KS_LOG_DEBUG, "State Callback: %d\n", (int32_t)condition);
bs = blade_handle_sessions_get(blade_connection_handle_get(bc), blade_connection_session_get(bc));
ks_assert(bs);
blade_rpc_request_create(blade_connection_pool_get(bc), &req, NULL, NULL, "blade.test.echo");
blade_session_send(bs, req, blade_test_echo_response_handler);
//blade_rpc_request_create(blade_connection_pool_get(bc), &req, NULL, NULL, "blade.test.echo");
//blade_session_send(bs, req, blade_test_echo_response_handler);
blade_session_read_unlock(bs);
}
+1
View File
@@ -159,6 +159,7 @@ KS_DECLARE(ks_status_t) blade_session_shutdown(blade_session_t *bs)
if (bs->state_thread) {
bs->shutdown = KS_TRUE;
ks_thread_join(bs->state_thread);
printf("FREEING SESSION THREAD %p\n", (void *)bs->state_thread);
ks_pool_free(bs->pool, &bs->state_thread);
bs->shutdown = KS_FALSE;
}