mirror of
https://github.com/urbit/shrub.git
synced 2024-12-01 14:42:02 +03:00
Merge branch 'release-candidate' into build-compat
* release-candidate: (27 commits) Style nits [CI] Update arvo Add a jet for +del:by fit UTF-8 tape bug calls u3_raft_work on leader promotion (for eager restart effects) removes unused u3v_nick (effect traversal) and u3v_http_request refactors event replay, removing unnecessary effect traversal refactors event poke, removing unnecessary effect traversal trailing whitespace adds and corrects some raft comments separates effects and persistence updates terminal to always 32 bytes on read updates ames to always allocate 2K bytes on read set alarm for behn timers updates u3_raft_work() to be async, adds sync u3_raft_play() synchronously processes each event singly handles effect/event pairs singly while iterating queue factor out raft_pump() factored out _raft_crop() and _raft_poke() uncouple roe mutation ...
This commit is contained in:
commit
abe21628d5
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,9 +1,6 @@
|
||||
[submodule "subprojects/softfloat3"]
|
||||
path = subprojects/softfloat3
|
||||
url = https://github.com/urbit/berkeley-softfloat-3.git
|
||||
[submodule "subprojects/commonmark-legacy"]
|
||||
path = subprojects/commonmark-legacy
|
||||
url = https://github.com/urbit/commonmark-legacy.git
|
||||
[submodule "subprojects/ed25519"]
|
||||
path = subprojects/ed25519
|
||||
url = https://github.com/urbit/ed25519.git
|
||||
|
@ -1 +1 @@
|
||||
6a1f32bb1984fa9329c072de09ba67b212c8dbed
|
||||
00c79de3df4ecae9f499053990471d420f0e79a0
|
||||
|
@ -17,8 +17,17 @@
|
||||
**/
|
||||
/* Assert. Good to capture.
|
||||
*/
|
||||
// # define c3_assert(x) assert(x)
|
||||
# define c3_assert(x) ( (x) ? 0 : c3_cooked(), assert(x) )
|
||||
# define c3_assert(x) \
|
||||
do { \
|
||||
if (!(x)) { \
|
||||
fprintf(stderr, \
|
||||
"\rAssertion '%s' failed " \
|
||||
"in %s:%d\n", \
|
||||
#x, __FILE__, __LINE__); \
|
||||
c3_cooked(); \
|
||||
assert(x); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* Stub.
|
||||
*/
|
||||
|
@ -79,6 +79,7 @@
|
||||
/** Tier 4.
|
||||
**/
|
||||
u3_noun u3wdb_bif(u3_noun);
|
||||
u3_noun u3wdb_del(u3_noun);
|
||||
u3_noun u3wdb_dif(u3_noun);
|
||||
u3_noun u3wdb_gas(u3_noun);
|
||||
u3_noun u3wdb_get(u3_noun);
|
||||
@ -289,7 +290,3 @@
|
||||
u3_noun u3wfu_snub(u3_noun);
|
||||
u3_noun u3wfu_toss(u3_noun);
|
||||
u3_noun u3wfu_wrap(u3_noun);
|
||||
|
||||
/** Tier 7.
|
||||
**/
|
||||
u3_noun u3wg_down(u3_noun);
|
||||
|
@ -327,7 +327,3 @@
|
||||
u3_noun u3wzu_snub(u3_noun);
|
||||
u3_noun u3wzu_toss(u3_noun);
|
||||
u3_noun u3wzu_wrap(u3_noun);
|
||||
|
||||
/** Tier 7.
|
||||
**/
|
||||
u3_noun u3yg_down(u3_noun);
|
||||
|
@ -84,11 +84,6 @@
|
||||
u3_noun
|
||||
u3v_pike(u3_noun ovo, u3_noun cor);
|
||||
|
||||
/* u3v_nick(): transform enveloped packets, [vir cor].
|
||||
*/
|
||||
u3_noun
|
||||
u3v_nick(u3_noun vir, u3_noun cor);
|
||||
|
||||
/* u3v_do(): use a kernel function.
|
||||
*/
|
||||
u3_noun
|
||||
@ -119,11 +114,6 @@
|
||||
u3_noun
|
||||
u3v_poke(u3_noun ovo);
|
||||
|
||||
/* u3v_http_request(): hear http request on channel (unprotected).
|
||||
*/
|
||||
void
|
||||
u3v_http_request(c3_o sec, u3_noun pox, u3_noun req);
|
||||
|
||||
/* u3v_tank(): dump single tank.
|
||||
*/
|
||||
void
|
||||
|
@ -1104,7 +1104,12 @@
|
||||
void
|
||||
u3_raft_init(void);
|
||||
|
||||
/* u3_raft_work(): poke, kick, and push pending events.
|
||||
/* u3_raft_play(): synchronously poke, kick, and push pending events.
|
||||
*/
|
||||
void
|
||||
u3_raft_play(void);
|
||||
|
||||
/* u3_raft_work(): asynchronously poke, kick, and push pending events.
|
||||
*/
|
||||
void
|
||||
u3_raft_work(void);
|
||||
|
111
jets/d/by_del.c
Normal file
111
jets/d/by_del.c
Normal file
@ -0,0 +1,111 @@
|
||||
/* j/4/by_del.c
|
||||
**
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
/* functions
|
||||
*/
|
||||
static u3_noun
|
||||
_rebalance(u3_noun a)
|
||||
{
|
||||
u3_noun l_a, n_a, r_a;
|
||||
|
||||
if ( c3n == u3r_trel(a, &n_a, &l_a, &r_a) ) {
|
||||
return u3m_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
if ( u3_nul == l_a) {
|
||||
return u3k(r_a);
|
||||
}
|
||||
else if ( u3_nul == r_a) {
|
||||
return u3k(l_a);
|
||||
}
|
||||
else {
|
||||
u3_noun n_l_a, l_l_a, r_l_a;
|
||||
u3_noun n_r_a, l_r_a, r_r_a;
|
||||
|
||||
if ( (c3n == u3r_trel(l_a, &n_l_a, &l_l_a, &r_l_a) ) ||
|
||||
(c3n == u3r_trel(r_a, &n_r_a, &l_r_a, &r_r_a) ) ||
|
||||
(c3n == u3du(n_l_a)) ||
|
||||
(c3n == u3du(n_r_a)) ) {
|
||||
return u3m_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
if ( c3y == u3qc_vor(u3h(n_l_a), u3h(n_r_a)) ) {
|
||||
u3_noun new_right = u3nt(u3k(n_a),
|
||||
u3k(r_l_a),
|
||||
u3k(r_a));
|
||||
|
||||
u3_noun ret = u3nt(u3k(n_l_a),
|
||||
u3k(l_l_a),
|
||||
_rebalance(new_right));
|
||||
u3z(new_right);
|
||||
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
u3_noun new_left = u3nt(u3k(n_a),
|
||||
u3k(l_a),
|
||||
u3k(l_r_a));
|
||||
|
||||
u3_noun ret = u3nt(u3k(n_r_a),
|
||||
_rebalance(new_left),
|
||||
u3k(r_r_a));
|
||||
u3z(new_left);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u3_noun
|
||||
u3qdb_del(u3_noun a,
|
||||
u3_noun b)
|
||||
{
|
||||
if ( u3_nul == a ) {
|
||||
return u3_nul;
|
||||
}
|
||||
else {
|
||||
u3_noun l_a, n_a, r_a, pn_a, qn_a;
|
||||
|
||||
if ( (c3n == u3r_trel(a, &n_a, &l_a, &r_a)) ||
|
||||
(c3n == u3r_cell(n_a, &pn_a, &qn_a)) )
|
||||
{
|
||||
return u3m_bail(c3__exit);
|
||||
}
|
||||
else if ( c3n == u3r_sing(pn_a, b) ) {
|
||||
if ( c3y == u3qc_gor(b, pn_a) ) {
|
||||
return u3nt(u3k(n_a),
|
||||
u3qdb_del(l_a, b),
|
||||
u3k(r_a));
|
||||
}
|
||||
else {
|
||||
return u3nt(u3k(n_a),
|
||||
u3k(l_a),
|
||||
u3qdb_del(r_a, b));
|
||||
}
|
||||
}
|
||||
else {
|
||||
return _rebalance(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u3_noun
|
||||
u3wdb_del(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( c3n == u3r_mean(cor, u3x_sam, &b,
|
||||
u3x_con_sam, &a, 0) ) {
|
||||
return u3m_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
u3_noun n = u3qdb_del(a, b);
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
|
220
jets/g/down.c
220
jets/g/down.c
@ -1,220 +0,0 @@
|
||||
/* j/g/down.c
|
||||
**
|
||||
*/
|
||||
#include "all.h"
|
||||
#include <cmark.h>
|
||||
#include <node.h>
|
||||
#include <buffer.h>
|
||||
|
||||
static u3_noun node_to_noun(cmark_node * nod);
|
||||
|
||||
static u3_noun list_elems_to_noun(cmark_node * nod)
|
||||
{
|
||||
u3_noun elems = u3_nul;
|
||||
|
||||
cmark_node * child;
|
||||
for ( child = nod->last_child; child; child = child->prev ) {
|
||||
elems = u3nc(node_to_noun(child),elems);
|
||||
}
|
||||
|
||||
return elems;
|
||||
}
|
||||
|
||||
static u3_noun document_to_noun(cmark_node * nod)
|
||||
{
|
||||
return list_elems_to_noun(nod);
|
||||
}
|
||||
|
||||
static u3_noun block_quote_to_noun(cmark_node * nod)
|
||||
{
|
||||
return u3nc(u3nc(c3__bloq,u3_nul),list_elems_to_noun(nod));
|
||||
}
|
||||
|
||||
static u3_noun list_to_noun(cmark_node * nod)
|
||||
{
|
||||
return
|
||||
u3nc(
|
||||
u3nt(
|
||||
c3__list,
|
||||
__(nod->as.list.tight),
|
||||
(nod->as.list.list_type == CMARK_BULLET_LIST)
|
||||
? nod->as.list.bullet_char /* XX convert? */
|
||||
: u3nc(nod->as.list.start,
|
||||
(nod->as.list.delimiter == CMARK_PERIOD_DELIM)
|
||||
? '.'
|
||||
: ')')),
|
||||
list_elems_to_noun(nod));
|
||||
}
|
||||
|
||||
static u3_noun list_item_to_noun(cmark_node * nod)
|
||||
{
|
||||
return u3nc(u3nc(c3__item,u3_nul),list_elems_to_noun(nod));
|
||||
}
|
||||
|
||||
static u3_noun code_block_to_noun(cmark_node * nod)
|
||||
{
|
||||
u3_atom str = u3i_string((c3_c *) nod->string_content.ptr); /* XX u3i_bytes */
|
||||
u3_noun res =
|
||||
u3nt(
|
||||
c3__code,
|
||||
nod->as.code.fenced
|
||||
? u3nq(
|
||||
u3_nul,
|
||||
nod->as.code.fence_char,
|
||||
nod->as.code.fence_length,
|
||||
u3i_tape((c3_c *) nod->as.code.info.ptr)
|
||||
)
|
||||
: u3_nul,
|
||||
u3qe_lore(str));
|
||||
u3z(str);
|
||||
return res;
|
||||
}
|
||||
|
||||
static u3_noun html_to_noun(cmark_node * nod)
|
||||
{
|
||||
u3_atom str = u3i_string((c3_c *) nod->string_content.ptr); /* XX u3i_bytes */
|
||||
u3_noun res = u3nc(c3__html, u3qe_lore(str));
|
||||
u3z(str);
|
||||
return res;
|
||||
}
|
||||
|
||||
static u3_noun paragraph_to_noun(cmark_node * nod)
|
||||
{
|
||||
return u3nc(c3__para, list_elems_to_noun(nod));
|
||||
}
|
||||
|
||||
static u3_noun header_to_noun(cmark_node * nod)
|
||||
{
|
||||
/* see also nod->as.header.setext */
|
||||
return u3nt(c3__head, nod->as.header.level, list_elems_to_noun(nod));
|
||||
}
|
||||
|
||||
static u3_noun hrule_to_noun(cmark_node * nod)
|
||||
{
|
||||
return u3nc(c3__hrul, u3_nul);
|
||||
}
|
||||
|
||||
static u3_noun reference_def_to_noun(cmark_node * nod)
|
||||
{
|
||||
return u3nc(c3__defn, u3_nul);
|
||||
}
|
||||
|
||||
static u3_noun text_to_noun(cmark_node * nod)
|
||||
{
|
||||
return u3nc(u3_blip, u3i_tape((c3_c *) cmark_chunk_to_cstr(&nod->as.literal)));
|
||||
}
|
||||
|
||||
static u3_noun softbreak_to_noun(cmark_node * nod) // XXX
|
||||
{
|
||||
return u3nt(0, 10, 0);
|
||||
}
|
||||
|
||||
static u3_noun linebreak_to_noun(cmark_node * nod)
|
||||
{
|
||||
return u3nc(c3__line, u3_nul);
|
||||
}
|
||||
|
||||
static u3_noun inline_code_to_noun(cmark_node * nod)
|
||||
{
|
||||
return u3nc(c3__code, u3i_tape((c3_c *) cmark_chunk_to_cstr(&nod->as.literal)));
|
||||
}
|
||||
|
||||
static u3_noun inline_html_to_noun(cmark_node * nod) // XXX
|
||||
{
|
||||
return u3nc(c3__htmt, u3i_string((c3_c *) cmark_chunk_to_cstr(&nod->as.literal)));
|
||||
}
|
||||
|
||||
static u3_noun emph_to_noun(cmark_node * nod)
|
||||
{
|
||||
return u3nc(u3nc(c3__emph, c3n), list_elems_to_noun(nod));
|
||||
}
|
||||
|
||||
static u3_noun strong_to_noun(cmark_node * nod)
|
||||
{
|
||||
return u3nc(u3nc(c3__emph, c3y), list_elems_to_noun(nod));
|
||||
}
|
||||
|
||||
static u3_noun link_to_noun(cmark_node * nod)
|
||||
{
|
||||
return u3nc(u3nt(c3__link,
|
||||
nod->as.link.url
|
||||
? u3i_tape((c3_c *) nod->as.link.url)
|
||||
: u3_nul,
|
||||
nod->as.link.title
|
||||
? u3nc(u3_nul, u3i_tape((c3_c *) nod->as.link.title))
|
||||
: u3_nul),
|
||||
list_elems_to_noun(nod));
|
||||
}
|
||||
|
||||
static u3_noun image_to_noun(cmark_node * nod)
|
||||
{
|
||||
return u3nc(u3nt(c3__blot,
|
||||
u3i_tape((c3_c *) nod->as.link.url),
|
||||
nod->as.link.title
|
||||
? u3nc(u3_nul, u3i_tape((c3_c *) nod->as.link.title))
|
||||
: u3_nul),
|
||||
list_elems_to_noun(nod));
|
||||
}
|
||||
|
||||
static u3_noun node_to_noun(cmark_node * nod)
|
||||
{
|
||||
if (!nod) {
|
||||
fprintf(stderr, "markdown null node");
|
||||
return u3m_bail(c3__fail);
|
||||
}
|
||||
switch ( nod->type ) {
|
||||
/* Block */
|
||||
case CMARK_NODE_DOCUMENT: return document_to_noun(nod);
|
||||
case CMARK_NODE_BLOCK_QUOTE: return block_quote_to_noun(nod);
|
||||
case CMARK_NODE_LIST: return list_to_noun(nod);
|
||||
case CMARK_NODE_LIST_ITEM: return list_item_to_noun(nod);
|
||||
case CMARK_NODE_CODE_BLOCK: return code_block_to_noun(nod);
|
||||
case CMARK_NODE_HTML: return html_to_noun(nod);
|
||||
case CMARK_NODE_PARAGRAPH: return paragraph_to_noun(nod);
|
||||
case CMARK_NODE_HEADER: return header_to_noun(nod);
|
||||
case CMARK_NODE_HRULE: return hrule_to_noun(nod);
|
||||
case CMARK_NODE_REFERENCE_DEF: return reference_def_to_noun(nod);
|
||||
/* Inline */
|
||||
case CMARK_NODE_TEXT: return text_to_noun(nod);
|
||||
case CMARK_NODE_SOFTBREAK: return softbreak_to_noun(nod);
|
||||
case CMARK_NODE_LINEBREAK: return linebreak_to_noun(nod);
|
||||
case CMARK_NODE_INLINE_CODE: return inline_code_to_noun(nod);
|
||||
case CMARK_NODE_INLINE_HTML: return inline_html_to_noun(nod);
|
||||
case CMARK_NODE_EMPH: return emph_to_noun(nod);
|
||||
case CMARK_NODE_STRONG: return strong_to_noun(nod);
|
||||
case CMARK_NODE_LINK: return link_to_noun(nod);
|
||||
case CMARK_NODE_IMAGE: return image_to_noun(nod);
|
||||
default: fprintf(stderr, "bad markdown parsing");
|
||||
return u3m_bail(c3__fail);
|
||||
}
|
||||
}
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3qg_down(u3_atom a)
|
||||
{
|
||||
c3_c *tex = u3r_string(a);
|
||||
|
||||
/* XX better strlen */
|
||||
cmark_node * doc = cmark_parse_document(tex, strlen(tex));
|
||||
|
||||
u3_noun res = document_to_noun(doc);
|
||||
|
||||
cmark_node_free(doc);
|
||||
// free out, tex?
|
||||
return res;
|
||||
}
|
||||
u3_noun
|
||||
u3wg_down(u3_noun cor)
|
||||
{
|
||||
u3_noun a;
|
||||
|
||||
if ( (u3_none == (a = u3r_at(u3x_sam, cor))) ||
|
||||
(c3n == u3ud(a)) )
|
||||
{
|
||||
return u3m_bail(c3__exit);
|
||||
} else {
|
||||
return u3qg_down(a);
|
||||
}
|
||||
}
|
16
jets/tree.c
16
jets/tree.c
@ -81,15 +81,6 @@ static u3j_core _141_hex_aes_d[] =
|
||||
};
|
||||
static c3_c* _141_hex_aes_ha[] = {0};
|
||||
|
||||
static u3j_harm _141_hex_down_mark_a[] = {{".2", u3wg_down, c3y}, {}};
|
||||
static c3_c* _141_hex_down_mark_ha[] = {0};
|
||||
|
||||
static u3j_core _141_hex_down_d[] =
|
||||
{ { "mark", 7, _141_hex_down_mark_a, 0, _141_hex_down_mark_ha },
|
||||
{}
|
||||
};
|
||||
static c3_c* _141_hex_down_ha[] = {0};
|
||||
|
||||
static u3j_harm _141_hex_lore_a[] = {{".2", u3we_lore}, {}};
|
||||
static c3_c* _141_hex_lore_ha[] = {0};
|
||||
static u3j_harm _141_hex_loss_a[] = {{".2", u3we_loss}, {}};
|
||||
@ -181,9 +172,7 @@ static c3_c* _141_hex_ripe_ha[] = {0};
|
||||
|
||||
|
||||
static u3j_core _141_hex_d[] =
|
||||
{ { "down", 8063, 0, _141_hex_down_d, _141_hex_down_ha },
|
||||
|
||||
{ "lore", 63, _141_hex_lore_a, 0, _141_hex_lore_ha },
|
||||
{ { "lore", 63, _141_hex_lore_a, 0, _141_hex_lore_ha },
|
||||
{ "loss", 63, _141_hex_loss_a, 0, _141_hex_loss_ha },
|
||||
{ "lune", 127, _141_hex_lune_a, 0, _141_hex_lune_ha },
|
||||
|
||||
@ -903,6 +892,8 @@ static c3_c* _141_two__in_ha[] = {0};
|
||||
|
||||
static u3j_harm _141_two__by_bif_a[] = {{".2", u3wdb_bif, c3y}, {}};
|
||||
static c3_c* _141_two__by_bif_ha[] = {0};
|
||||
static u3j_harm _141_two__by_del_a[] = {{".2", u3wdb_del, c3y}, {}};
|
||||
static c3_c* _141_two__by_del_ha[] = {0};
|
||||
static u3j_harm _141_two__by_dif_a[] = {{".2", u3wdb_dif, c3y}, {}};
|
||||
static c3_c* _141_two__by_dif_ha[] = {0};
|
||||
static u3j_harm _141_two__by_gas_a[] = {{".2", u3wdb_gas, c3y}, {}};
|
||||
@ -929,6 +920,7 @@ static c3_c* _141_two__in_ha[] = {0};
|
||||
|
||||
static u3j_core _141_two__by_d[] =
|
||||
{ { "bif", 7, _141_two__by_bif_a, 0, _141_two__by_bif_ha },
|
||||
{ "del", 7, _141_two__by_del_a, 0, _141_two__by_del_ha },
|
||||
{ "dif", 7, _141_two__by_dif_a, 0, _141_two__by_dif_ha },
|
||||
{ "gas", 7, _141_two__by_gas_a, 0, _141_two__by_gas_ha },
|
||||
{ "get", 7, _141_two__by_get_a, 0, _141_two__by_get_ha },
|
||||
|
10
meson.build
10
meson.build
@ -90,6 +90,7 @@ jets_d_src = [
|
||||
'jets/d/in_wyt.c',
|
||||
'jets/d/in_bif.c',
|
||||
'jets/d/in_dif.c',
|
||||
'jets/d/by_del.c',
|
||||
'jets/d/by_gas.c',
|
||||
'jets/d/by_get.c',
|
||||
'jets/d/by_has.c',
|
||||
@ -179,10 +180,6 @@ jets_f_ut_src = [
|
||||
'jets/f/ut_wrap.c'
|
||||
]
|
||||
|
||||
jets_g_src = [
|
||||
'jets/g/down.c'
|
||||
]
|
||||
|
||||
jets_src = [
|
||||
'jets/tree.c'
|
||||
]
|
||||
@ -192,7 +189,8 @@ jets_all_src = [
|
||||
jets_c_src, jets_d_src,
|
||||
jets_e_src, jets_e_ed_src,
|
||||
jets_f_src, jets_f_ut_src,
|
||||
jets_g_src, jets_src]
|
||||
jets_src
|
||||
]
|
||||
|
||||
noun_src = [
|
||||
'noun/allocate.c',
|
||||
@ -322,7 +320,6 @@ elif osdet != 'openbsd'
|
||||
endif
|
||||
|
||||
# For these libs we provide fallback bundle
|
||||
cmark_dep = dependency('libcmark', version: '0.12.0', fallback: ['commonmark-legacy', 'cmark_dep'])
|
||||
urbitscrypt_dep = dependency('libscrypt', version: '>=0.1.21', fallback: ['libscrypt', 'libscrypt_dep'])
|
||||
|
||||
ed25519_dep = dependency('ed25519', version: '>=0.1.0', fallback: ['ed25519', 'ed25519_dep'])
|
||||
@ -339,7 +336,6 @@ deps = [openssl_dep,
|
||||
curl_dep,
|
||||
libuv_dep,
|
||||
libh2o_dep,
|
||||
cmark_dep,
|
||||
secp256k1_dep,
|
||||
gmp_dep,
|
||||
sigsegv_dep,
|
||||
|
@ -531,10 +531,10 @@ u3t_print_steps(c3_c* cap_c, c3_d sep_d)
|
||||
void
|
||||
u3t_damp(void)
|
||||
{
|
||||
fprintf(stderr, "\r\n");
|
||||
|
||||
if ( 0 != u3R->pro.day ) {
|
||||
u3_noun wol = u3do("pi-tell", u3R->pro.day);
|
||||
|
||||
fprintf(stderr, "\r\n");
|
||||
u3_term_wall(wol);
|
||||
|
||||
/* bunt a +doss
|
||||
|
@ -139,64 +139,6 @@ u3v_pike(u3_noun ovo, u3_noun cor)
|
||||
return _cv_mung(0, fun, sam);
|
||||
}
|
||||
|
||||
/* u3v_nick(): transform enveloped packets, [vir cor].
|
||||
*/
|
||||
u3_noun
|
||||
u3v_nick(u3_noun vir, u3_noun cor)
|
||||
{
|
||||
if ( u3_nul == vir ) {
|
||||
return u3nt(u3_blip, vir, cor);
|
||||
}
|
||||
else {
|
||||
u3_noun i_vir = u3h(vir);
|
||||
u3_noun pi_vir, qi_vir;
|
||||
u3_noun vix;
|
||||
|
||||
if ( (c3y == u3r_cell(i_vir, &pi_vir, &qi_vir)) &&
|
||||
(c3y == u3du(qi_vir)) &&
|
||||
(c3__hear == u3h(qi_vir)) )
|
||||
{
|
||||
u3_noun gon;
|
||||
|
||||
gon = u3v_pike(u3k(i_vir), cor);
|
||||
if ( u3_blip != u3h(gon) ) {
|
||||
u3z(vir);
|
||||
return gon;
|
||||
}
|
||||
else {
|
||||
u3_noun viz;
|
||||
|
||||
vix = u3k(u3h(u3t(gon)));
|
||||
cor = u3k(u3t(u3t(gon)));
|
||||
u3z(gon);
|
||||
|
||||
viz = u3kb_weld(vix, u3k(u3t(vir)));
|
||||
u3z(vir);
|
||||
|
||||
return u3v_nick(viz, cor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
u3_noun nez = u3v_nick(u3k(u3t(vir)), cor);
|
||||
|
||||
if ( u3_blip != u3h(nez) ) {
|
||||
u3z(vir);
|
||||
return nez;
|
||||
} else {
|
||||
u3_noun viz;
|
||||
|
||||
viz = u3nc(u3k(i_vir), u3k(u3h(u3t(nez))));
|
||||
cor = u3k(u3t(u3t(nez)));
|
||||
|
||||
u3z(vir);
|
||||
u3z(nez);
|
||||
|
||||
return u3nt(u3_blip, viz, cor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* _cv_nock_poke(): call poke through hardcoded interface.
|
||||
*/
|
||||
static u3_noun
|
||||
@ -374,15 +316,6 @@ u3v_poke(u3_noun ovo)
|
||||
return _cv_nock_poke(ovo);
|
||||
}
|
||||
|
||||
/* u3v_http_request(): hear http request on channel (unprotected).
|
||||
*/
|
||||
void
|
||||
u3v_http_request(c3_o sec, u3_noun pox, u3_noun req)
|
||||
{
|
||||
// uL(fprintf(uH, "http: request\n"));
|
||||
u3v_plan(pox, u3nq(c3__this, sec, 0, req));
|
||||
}
|
||||
|
||||
/* u3v_tank(): dump single tank.
|
||||
*/
|
||||
void
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 6e7d7e3a92361f11942f0c743d154ab426d1530e
|
||||
Subproject commit 4da94a611ee62bad87ab2b131ffda3bcc0723d9c
|
@ -1 +0,0 @@
|
||||
Subproject commit 8555ef14c4a503f57a0d192bb120159239f4322c
|
@ -1 +1 @@
|
||||
Subproject commit ba4777acac5694925ab78f38577b059cd4a3e8e6
|
||||
Subproject commit 76385f2ebbbc9580a9c236952d68d11d73a6135c
|
@ -1 +1 @@
|
||||
Subproject commit 41958a8aedb3aa2a85332bc8ac0ac389aa725a09
|
||||
Subproject commit 3b1f53c86b71f6fdc099b3b378de6f379b4b8412
|
@ -1 +1 @@
|
||||
Subproject commit 4ebe362f390025e5448e9fcf777c1f38630bc011
|
||||
Subproject commit 029693ff1cbe4f69d3a2da87d0f4f034f92cc0c2
|
@ -1 +1 @@
|
||||
Subproject commit a59901c38a67660039ee93a6170a338634d76ec0
|
||||
Subproject commit 173beb88ee62bddd13874ca04ab338cdec704928
|
@ -1 +1 @@
|
||||
Subproject commit 9e3aece8147d28246c57b84731dad26130c7d1c1
|
||||
Subproject commit 0c3a346a60f0b3bb42445b2c63198a6e0f94c89b
|
@ -1 +1 @@
|
||||
Subproject commit 001378cbe3681af1137553ed7220c79273850d6a
|
||||
Subproject commit 71a75d57ca4e7ca0f7fc2fd84abd93595b0624ca
|
@ -1 +1 @@
|
||||
Subproject commit 9d4342099a54cefc3a4117ce0d0c71cff4e48783
|
||||
Subproject commit ec4c7e31b32e07aad80e52f65ff46ac6d6aad986
|
@ -30,8 +30,11 @@ _ames_alloc(uv_handle_t* had_u,
|
||||
uv_buf_t* buf
|
||||
)
|
||||
{
|
||||
void* ptr_v = c3_malloc(len_i);
|
||||
*buf = uv_buf_init(ptr_v, len_i);
|
||||
// we allocate 2K, which gives us plenty of space
|
||||
// for a single ames packet (max size 1060 bytes)
|
||||
//
|
||||
void* ptr_v = c3_malloc(2048);
|
||||
*buf = uv_buf_init(ptr_v, 2048);
|
||||
}
|
||||
|
||||
/* _ames_free(): contrasting free.
|
||||
|
@ -78,6 +78,7 @@ u3_behn_ef_doze(u3_noun wen)
|
||||
u3_noun now = u3_time_in_tv(&tim_tv);
|
||||
c3_d gap_d = u3_time_gap_ms(now, u3k(u3t(wen)));
|
||||
|
||||
teh_u->alm = c3y;
|
||||
uv_timer_start(&teh_u->tim_u, _behn_time_cb, gap_d, 0);
|
||||
}
|
||||
|
||||
|
@ -442,6 +442,7 @@ u3_lo_shut(c3_o inn)
|
||||
if ( c3n == u3_Host.liv ) {
|
||||
// direct save and die
|
||||
//
|
||||
u3_raft_play();
|
||||
// u3_lo_grab("lo_exit", u3_none);
|
||||
// u3_loom_save(u3A->ent_d);
|
||||
// u3_loom_exit();
|
||||
|
410
vere/raft.c
410
vere/raft.c
@ -179,6 +179,7 @@ _raft_promote(u3_raft* raf_u)
|
||||
u3_sist_boot();
|
||||
if ( c3n == u3_Host.ops_u.bat ) {
|
||||
u3_lo_lead();
|
||||
u3_raft_work();
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -1445,17 +1446,22 @@ u3_raft_init()
|
||||
|
||||
/* _raft_sure(): apply and save an input ovum and its result.
|
||||
*/
|
||||
static void
|
||||
static u3_noun
|
||||
_raft_sure(u3_noun ovo, u3_noun vir, u3_noun cor)
|
||||
{
|
||||
// Whatever worked, save it. (XX - should be concurrent with execute.)
|
||||
// We'd like more events that don't change the state but need work here.
|
||||
{
|
||||
u3_noun ret;
|
||||
|
||||
u3r_mug(cor);
|
||||
u3r_mug(u3A->roc);
|
||||
|
||||
// XX review this, and confirm it's actually an optimization
|
||||
// Seems like it could be very expensive in some cases
|
||||
//
|
||||
if ( c3n == u3r_sing(cor, u3A->roc) ) {
|
||||
u3A->roe = u3nc(u3nc(vir, ovo), u3A->roe);
|
||||
ret = u3nc(vir, ovo);
|
||||
|
||||
u3z(u3A->roc);
|
||||
u3A->roc = cor;
|
||||
@ -1463,20 +1469,23 @@ _raft_sure(u3_noun ovo, u3_noun vir, u3_noun cor)
|
||||
else {
|
||||
u3z(ovo);
|
||||
|
||||
// push a new event into queue
|
||||
u3A->roe = u3nc(u3nc(vir, u3_nul), u3A->roe);
|
||||
// we return ~ in place of the event ovum to skip persistence
|
||||
//
|
||||
ret = u3nc(vir, u3_nul);
|
||||
|
||||
u3z(cor);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* _raft_lame(): handle an application failure.
|
||||
*/
|
||||
static void
|
||||
static u3_noun
|
||||
_raft_lame(u3_noun ovo, u3_noun why, u3_noun tan)
|
||||
{
|
||||
u3_noun bov, gon;
|
||||
u3_noun ret;
|
||||
|
||||
#if 0
|
||||
{
|
||||
@ -1509,10 +1518,12 @@ _raft_lame(u3_noun ovo, u3_noun why, u3_noun tan)
|
||||
gon = u3m_soft(0, u3v_poke, u3k(bov));
|
||||
|
||||
if ( u3_blip == u3h(gon) ) {
|
||||
_raft_sure(bov, u3k(u3h(u3t(gon))), u3k(u3t(u3t(gon))));
|
||||
ret = _raft_sure(bov, u3k(u3h(u3t(gon))), u3k(u3t(u3t(gon))));
|
||||
|
||||
u3z(tan);
|
||||
u3z(gon);
|
||||
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
u3z(gon);
|
||||
@ -1522,9 +1533,11 @@ _raft_lame(u3_noun ovo, u3_noun why, u3_noun tan)
|
||||
u3_noun nog = u3m_soft(0, u3v_poke, u3k(vab));
|
||||
|
||||
if ( u3_blip == u3h(nog) ) {
|
||||
_raft_sure(vab, u3k(u3h(u3t(nog))), u3k(u3t(u3t(nog))));
|
||||
ret = _raft_sure(vab, u3k(u3h(u3t(nog))), u3k(u3t(u3t(nog))));
|
||||
u3z(tan);
|
||||
u3z(nog);
|
||||
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
u3z(nog);
|
||||
@ -1534,6 +1547,8 @@ _raft_lame(u3_noun ovo, u3_noun why, u3_noun tan)
|
||||
u3_lo_punt(2, u3kb_flop(u3k(tan)));
|
||||
uL(fprintf(uH, "crude: punted\n"));
|
||||
// c3_assert(!"crud");
|
||||
|
||||
return u3_nul;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1541,7 +1556,7 @@ _raft_lame(u3_noun ovo, u3_noun why, u3_noun tan)
|
||||
|
||||
/* _raft_punk(): insert and apply an input ovum (unprotected).
|
||||
*/
|
||||
static void
|
||||
static u3_noun
|
||||
_raft_punk(u3_noun ovo)
|
||||
{
|
||||
#ifdef GHETTO
|
||||
@ -1587,70 +1602,30 @@ _raft_punk(u3_noun ovo)
|
||||
free(txt_c);
|
||||
#endif
|
||||
|
||||
if ( u3_blip != u3h(gon) ) {
|
||||
u3_noun why = u3k(u3h(gon));
|
||||
u3_noun tan = u3k(u3t(gon));
|
||||
{
|
||||
u3_noun hed, tal;
|
||||
u3x_cell(gon, &hed, &tal);
|
||||
|
||||
u3k(hed); u3k(tal);
|
||||
u3z(gon);
|
||||
_raft_lame(ovo, why, tan);
|
||||
}
|
||||
else {
|
||||
u3_noun vir = u3k(u3h(u3t(gon)));
|
||||
u3_noun cor = u3k(u3t(u3t(gon)));
|
||||
u3_noun nug;
|
||||
|
||||
u3z(gon);
|
||||
nug = u3v_nick(vir, cor);
|
||||
|
||||
if ( u3_blip != u3h(nug) ) {
|
||||
u3_noun why = u3k(u3h(nug));
|
||||
u3_noun tan = u3k(u3t(nug));
|
||||
|
||||
u3z(nug);
|
||||
_raft_lame(ovo, why, tan);
|
||||
if ( u3_blip != hed ) {
|
||||
return _raft_lame(ovo, hed, tal);
|
||||
}
|
||||
else {
|
||||
vir = u3k(u3h(u3t(nug)));
|
||||
cor = u3k(u3t(u3t(nug)));
|
||||
u3_noun vir, cor;
|
||||
u3x_cell(tal, &vir, &cor);
|
||||
|
||||
u3z(nug);
|
||||
_raft_sure(ovo, vir, cor);
|
||||
u3k(vir); u3k(cor);
|
||||
u3z(tal);
|
||||
|
||||
return _raft_sure(ovo, vir, cor);
|
||||
}
|
||||
}
|
||||
// uL(fprintf(uH, "punk oot %s\n", txt_c));
|
||||
// free(txt_c);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_raft_comm(c3_d bid_d)
|
||||
{
|
||||
u3p(u3v_cart) egg_p;
|
||||
|
||||
u3_lo_open();
|
||||
|
||||
egg_p = u3A->ova.egg_p;
|
||||
while ( egg_p ) {
|
||||
u3v_cart* egg_u = u3to(u3v_cart, egg_p);
|
||||
|
||||
if ( egg_u->ent_d <= bid_d ) {
|
||||
egg_u->cit = c3y;
|
||||
} else break;
|
||||
|
||||
egg_p = egg_u->nex_p;
|
||||
}
|
||||
u3_lo_shut(c3y);
|
||||
}
|
||||
|
||||
static void
|
||||
_raft_comm_cb(uv_timer_t* tim_u)
|
||||
{
|
||||
u3_raft* raf_u = tim_u->data;
|
||||
|
||||
_raft_comm(raf_u->ent_d);
|
||||
}
|
||||
|
||||
|
||||
/* _raft_push(): save an event
|
||||
*/
|
||||
static c3_d
|
||||
_raft_push(u3_raft* raf_u, c3_w* bob_w, c3_w len_w)
|
||||
{
|
||||
@ -1664,8 +1639,17 @@ _raft_push(u3_raft* raf_u, c3_w* bob_w, c3_w len_w)
|
||||
u3t_event_trace("Recording", 'e');
|
||||
raf_u->lat_w = raf_u->tem_w; // XX
|
||||
|
||||
if ( !uv_is_active((uv_handle_t*)&raf_u->tim_u) ) {
|
||||
uv_timer_start(&raf_u->tim_u, _raft_comm_cb, 0, 0);
|
||||
u3p(u3v_cart) egg_p;
|
||||
|
||||
egg_p = u3A->ova.egg_p;
|
||||
while ( egg_p ) {
|
||||
u3v_cart* egg_u = u3to(u3v_cart, egg_p);
|
||||
|
||||
if ( egg_u->ent_d <= raf_u->ent_d ) {
|
||||
egg_u->cit = c3y;
|
||||
} else break;
|
||||
|
||||
egg_p = egg_u->nex_p;
|
||||
}
|
||||
|
||||
return raf_u->ent_d;
|
||||
@ -1678,10 +1662,10 @@ _raft_push(u3_raft* raf_u, c3_w* bob_w, c3_w len_w)
|
||||
}
|
||||
|
||||
|
||||
/* _raft_kick_all(): kick a list of events, transferring.
|
||||
/* _raft_kick(): kick a list of effects, transferring.
|
||||
*/
|
||||
static void
|
||||
_raft_kick_all(u3_noun vir)
|
||||
_raft_kick(u3_noun vir)
|
||||
{
|
||||
while ( u3_nul != vir ) {
|
||||
u3_noun ovo = u3k(u3h(vir));
|
||||
@ -1932,131 +1916,185 @@ _raft_grab(u3_noun ova)
|
||||
|
||||
int FOO;
|
||||
|
||||
/* u3_raft_work(): work.
|
||||
/* _raft_crop(): Delete finished events.
|
||||
*/
|
||||
static void
|
||||
_raft_crop(void)
|
||||
{
|
||||
while ( u3A->ova.egg_p ) {
|
||||
u3p(u3v_cart) egg_p = u3A->ova.egg_p;
|
||||
u3v_cart* egg_u = u3to(u3v_cart, u3A->ova.egg_p);
|
||||
|
||||
if ( c3y == egg_u->did ) {
|
||||
if ( egg_p == u3A->ova.geg_p ) {
|
||||
c3_assert(egg_u->nex_p == 0);
|
||||
u3A->ova.geg_p = u3A->ova.egg_p = 0;
|
||||
}
|
||||
else {
|
||||
c3_assert(egg_u->nex_p != 0);
|
||||
u3A->ova.egg_p = egg_u->nex_p;
|
||||
}
|
||||
egg_u->cit = c3y;
|
||||
u3a_free(egg_u);
|
||||
}
|
||||
else break;
|
||||
}
|
||||
}
|
||||
|
||||
/* _raft_pop_roe(): pop the next [~ event] off the queue.
|
||||
**
|
||||
** effects are no longer stored on u3A->roe; the head of
|
||||
** each pair is always null.
|
||||
*/
|
||||
static u3_weak
|
||||
_raft_pop_roe(void)
|
||||
{
|
||||
if ( u3_nul == u3A->roe ) {
|
||||
return u3_none;
|
||||
}
|
||||
|
||||
u3_noun ovo;
|
||||
|
||||
{
|
||||
u3_noun ova = u3kb_flop(u3A->roe);
|
||||
u3A->roe = u3qb_flop(u3t(ova));
|
||||
ovo = u3k(u3h(ova));
|
||||
u3z(ova);
|
||||
}
|
||||
|
||||
return ovo;
|
||||
}
|
||||
|
||||
/* _raft_poke(): poke Arvo with the next queued event.
|
||||
*/
|
||||
static u3_weak
|
||||
_raft_poke(void)
|
||||
{
|
||||
u3_weak rus;
|
||||
|
||||
// defer event processing until storage is initialized
|
||||
//
|
||||
if ( 0 == u3Z->lug_u.len_d ) {
|
||||
return u3_none;
|
||||
}
|
||||
|
||||
if ( u3_none != (rus = _raft_pop_roe()) ) {
|
||||
u3_noun ovo, vir;
|
||||
|
||||
u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3k(rus)), u3_nul));
|
||||
|
||||
u3x_cell(rus, &vir, &ovo);
|
||||
c3_assert( u3_nul == vir );
|
||||
u3k(ovo);
|
||||
u3z(rus);
|
||||
|
||||
rus = _raft_punk(ovo);
|
||||
|
||||
u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3_nul), u3_nul));
|
||||
}
|
||||
|
||||
return rus;
|
||||
}
|
||||
|
||||
/* _raft_pump(): Cartify, jam, and save an ovum.
|
||||
*/
|
||||
static void
|
||||
_raft_pump(u3_noun ovo)
|
||||
{
|
||||
u3v_cart* egg_u = u3a_malloc(sizeof(*egg_u));
|
||||
u3p(u3v_cart) egg_p = u3of(u3v_cart, egg_u);
|
||||
u3_noun ron;
|
||||
c3_d bid_d;
|
||||
c3_w len_w;
|
||||
c3_w* bob_w;
|
||||
|
||||
egg_u->nex_p = 0;
|
||||
egg_u->cit = c3n;
|
||||
egg_u->did = c3n;
|
||||
egg_u->vir = 0;
|
||||
|
||||
ron = u3ke_jam(u3nc(u3k(u3A->now), ovo));
|
||||
c3_assert(u3A->key);
|
||||
// don't encrypt for the moment, bootstrapping
|
||||
// ron = u3dc("en:crua", u3k(u3A->key), ron);
|
||||
|
||||
len_w = u3r_met(5, ron);
|
||||
bob_w = c3_malloc(len_w * 4L);
|
||||
u3r_words(0, len_w, bob_w, ron);
|
||||
u3z(ron);
|
||||
|
||||
bid_d = _raft_push(u3Z, bob_w, len_w);
|
||||
egg_u->ent_d = bid_d;
|
||||
|
||||
if ( 0 == u3A->ova.geg_p ) {
|
||||
c3_assert(0 == u3A->ova.egg_p);
|
||||
u3A->ova.geg_p = u3A->ova.egg_p = egg_p;
|
||||
}
|
||||
else {
|
||||
c3_assert(0 == u3to(u3v_cart, u3A->ova.geg_p)->nex_p);
|
||||
u3to(u3v_cart, u3A->ova.geg_p)->nex_p = egg_p;
|
||||
u3A->ova.geg_p = egg_p;
|
||||
}
|
||||
|
||||
egg_u->did = c3y;
|
||||
}
|
||||
|
||||
/* u3_raft_chip(): chip one event off for processing.
|
||||
*/
|
||||
void
|
||||
u3_raft_chip(void)
|
||||
{
|
||||
u3_weak rus = _raft_poke();
|
||||
|
||||
_raft_crop();
|
||||
|
||||
if ( u3_none != rus ) {
|
||||
u3_noun ovo, vir;
|
||||
u3x_cell(rus, &vir, &ovo);
|
||||
|
||||
if ( u3_nul != ovo ) {
|
||||
_raft_pump(u3k(ovo));
|
||||
}
|
||||
|
||||
_raft_kick(u3k(vir));
|
||||
_raft_grab(vir);
|
||||
|
||||
u3z(rus);
|
||||
}
|
||||
}
|
||||
|
||||
/* u3_raft_play(): synchronously process events.
|
||||
*/
|
||||
void
|
||||
u3_raft_play(void)
|
||||
{
|
||||
c3_assert( u3Z->typ_e == u3_raty_lead );
|
||||
|
||||
u3_raft_chip();
|
||||
|
||||
if ( u3_nul != u3A->roe ) {
|
||||
u3_raft_play();
|
||||
}
|
||||
}
|
||||
|
||||
/* _raft_work_cb(): callback to recurse into u3_raft_work().
|
||||
*/
|
||||
static void
|
||||
_raft_work_cb(uv_timer_t* tim_u)
|
||||
{
|
||||
u3_raft_work();
|
||||
}
|
||||
|
||||
/* u3_raft_work(): asynchronously process events.
|
||||
*/
|
||||
void
|
||||
u3_raft_work(void)
|
||||
{
|
||||
if ( u3Z->typ_e != u3_raty_lead ) {
|
||||
c3_assert(u3A->ova.egg_p == 0);
|
||||
if ( u3_nul != u3A->roe ) {
|
||||
uL(fprintf(uH, "raft: dropping roe!!\n"));
|
||||
u3z(u3A->roe);
|
||||
u3A->roe = u3_nul;
|
||||
}
|
||||
}
|
||||
else {
|
||||
u3_noun ova;
|
||||
u3_noun vir;
|
||||
u3_noun nex;
|
||||
c3_assert( u3Z->typ_e == u3_raty_lead );
|
||||
|
||||
// Delete finished events.
|
||||
//
|
||||
while ( u3A->ova.egg_p ) {
|
||||
u3p(u3v_cart) egg_p = u3A->ova.egg_p;
|
||||
u3v_cart* egg_u = u3to(u3v_cart, u3A->ova.egg_p);
|
||||
u3_raft_chip();
|
||||
|
||||
if ( c3y == egg_u->did ) {
|
||||
vir = egg_u->vir;
|
||||
|
||||
if ( egg_p == u3A->ova.geg_p ) {
|
||||
c3_assert(egg_u->nex_p == 0);
|
||||
u3A->ova.geg_p = u3A->ova.egg_p = 0;
|
||||
}
|
||||
else {
|
||||
c3_assert(egg_u->nex_p != 0);
|
||||
u3A->ova.egg_p = egg_u->nex_p;
|
||||
}
|
||||
egg_u->cit = c3y;
|
||||
u3a_free(egg_u);
|
||||
}
|
||||
else break;
|
||||
}
|
||||
|
||||
// Poke pending events, leaving the poked events and errors on u3A->roe.
|
||||
//
|
||||
{
|
||||
if ( 0 == u3Z->lug_u.len_d ) {
|
||||
return;
|
||||
}
|
||||
ova = u3kb_flop(u3A->roe);
|
||||
u3A->roe = u3_nul;
|
||||
|
||||
u3_noun hed = (u3_nul == ova) ? u3_nul : u3h(ova);
|
||||
|
||||
if ( u3_nul != hed ) {
|
||||
u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3k(hed)), u3_nul));
|
||||
}
|
||||
|
||||
while ( u3_nul != ova ) {
|
||||
_raft_punk(u3k(u3t(u3h(ova))));
|
||||
c3_assert(u3_nul == u3h(u3h(ova)));
|
||||
|
||||
nex = u3k(u3t(ova));
|
||||
u3z(ova); ova = nex;
|
||||
}
|
||||
|
||||
if ( u3_nul != hed ) {
|
||||
u3_term_ef_blit(0, u3nc(u3nc(c3__bee, u3_nul), u3_nul));
|
||||
}
|
||||
}
|
||||
|
||||
// Cartify, jam, and encrypt this batch of events. Take a number, Raft will
|
||||
// be with you shortly.
|
||||
{
|
||||
c3_d bid_d;
|
||||
c3_w len_w;
|
||||
c3_w* bob_w;
|
||||
u3_noun ron;
|
||||
u3_noun ovo;
|
||||
|
||||
ova = u3kb_flop(u3A->roe);
|
||||
u3A->roe = u3_nul;
|
||||
|
||||
while ( u3_nul != ova ) {
|
||||
ovo = u3k(u3t(u3h(ova)));
|
||||
vir = u3k(u3h(u3h(ova)));
|
||||
nex = u3k(u3t(ova));
|
||||
u3z(ova); ova = nex;
|
||||
|
||||
if ( u3_nul != ovo ) {
|
||||
u3v_cart* egg_u = u3a_malloc(sizeof(*egg_u));
|
||||
u3p(u3v_cart) egg_p = u3of(u3v_cart, egg_u);
|
||||
|
||||
egg_u->nex_p = 0;
|
||||
egg_u->cit = c3n;
|
||||
egg_u->did = c3n;
|
||||
egg_u->vir = vir;
|
||||
|
||||
ron = u3ke_jam(u3nc(u3k(u3A->now), ovo));
|
||||
c3_assert(u3A->key);
|
||||
// don't encrypt for the moment, bootstrapping
|
||||
// ron = u3dc("en:crua", u3k(u3A->key), ron);
|
||||
|
||||
len_w = u3r_met(5, ron);
|
||||
bob_w = c3_malloc(len_w * 4L);
|
||||
u3r_words(0, len_w, bob_w, ron);
|
||||
u3z(ron);
|
||||
|
||||
bid_d = _raft_push(u3Z, bob_w, len_w);
|
||||
egg_u->ent_d = bid_d;
|
||||
|
||||
if ( 0 == u3A->ova.geg_p ) {
|
||||
c3_assert(0 == u3A->ova.egg_p);
|
||||
u3A->ova.geg_p = u3A->ova.egg_p = egg_p;
|
||||
}
|
||||
else {
|
||||
c3_assert(0 == u3to(u3v_cart, u3A->ova.geg_p)->nex_p);
|
||||
u3to(u3v_cart, u3A->ova.geg_p)->nex_p = egg_p;
|
||||
u3A->ova.geg_p = egg_p;
|
||||
}
|
||||
_raft_kick_all(vir);
|
||||
egg_u->did = c3y;
|
||||
egg_u->vir = 0;
|
||||
|
||||
_raft_grab(ova);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( u3_nul != u3A->roe ) {
|
||||
uv_timer_start(&u3Z->tim_u, _raft_work_cb, 0, 0);
|
||||
}
|
||||
}
|
||||
|
66
vere/sist.c
66
vere/sist.c
@ -237,42 +237,42 @@ _sist_sing(u3_noun ovo)
|
||||
{
|
||||
u3_noun gon = u3m_soft(0, u3v_poke, u3k(ovo));
|
||||
|
||||
if ( u3_blip != u3h(gon) ) {
|
||||
_sist_suck(ovo, gon);
|
||||
}
|
||||
else {
|
||||
u3_noun vir = u3k(u3h(u3t(gon)));
|
||||
u3_noun cor = u3k(u3t(u3t(gon)));
|
||||
u3_noun nug;
|
||||
{
|
||||
u3_noun hed, tal;
|
||||
u3x_cell(gon, &hed, &tal);
|
||||
|
||||
u3z(gon);
|
||||
nug = u3v_nick(vir, cor);
|
||||
|
||||
if ( u3_blip != u3h(nug) ) {
|
||||
_sist_suck(ovo, nug);
|
||||
if ( u3_blip != hed ) {
|
||||
_sist_suck(ovo, gon);
|
||||
}
|
||||
else {
|
||||
vir = u3h(u3t(nug));
|
||||
cor = u3k(u3t(u3t(nug)));
|
||||
u3_noun vir, cor;
|
||||
u3x_cell(tal, &vir, &cor);
|
||||
|
||||
while ( u3_nul != vir ) {
|
||||
u3_noun fex = u3h(vir);
|
||||
u3_noun fav = u3t(fex);
|
||||
|
||||
if ( c3__init == u3h(fav) ) {
|
||||
u3A->own = u3k(u3t(fav));
|
||||
// note: c3__boot == u3h(u3t(ovo))
|
||||
u3A->fak = ( c3__fake == u3h(u3t(u3t(ovo))) ) ? c3y : c3n;
|
||||
}
|
||||
|
||||
vir = u3t(vir);
|
||||
}
|
||||
u3z(nug);
|
||||
u3z(u3A->roc);
|
||||
u3A->roc = cor;
|
||||
u3A->roc = u3k(cor);
|
||||
|
||||
{
|
||||
u3_noun tag, dat;
|
||||
u3x_trel(ovo, 0, &tag, &dat);
|
||||
|
||||
if ( c3__boot == tag ) {
|
||||
while ( u3_nul != vir ) {
|
||||
u3_noun fav = u3t(u3h(vir));
|
||||
|
||||
if ( c3__init == u3h(fav) ) {
|
||||
u3A->own = u3k(u3t(fav));
|
||||
u3A->fak = ( c3__fake == u3h(tag) ) ? c3y : c3n;
|
||||
}
|
||||
|
||||
vir = u3t(vir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
u3z(ovo);
|
||||
}
|
||||
|
||||
u3z(gon);
|
||||
u3z(ovo);
|
||||
}
|
||||
|
||||
/* _sist_cask(): ask for a passcode.
|
||||
@ -595,7 +595,8 @@ _sist_zest()
|
||||
}
|
||||
|
||||
// Work through the boot events.
|
||||
u3_raft_work();
|
||||
//
|
||||
u3_raft_play();
|
||||
}
|
||||
|
||||
/* _sist_rest_nuu(): upgrade log from previous format.
|
||||
@ -1223,8 +1224,9 @@ u3_sist_boot(void)
|
||||
u3C.wag_w |= u3o_hashless;
|
||||
}
|
||||
|
||||
// process pending events
|
||||
u3_raft_work();
|
||||
// process pending events
|
||||
//
|
||||
u3_raft_play();
|
||||
}
|
||||
else {
|
||||
u3_noun pig, who;
|
||||
|
11
vere/term.c
11
vere/term.c
@ -41,14 +41,19 @@ _term_msc_out_host()
|
||||
return 1000000ULL * tim_tv.tv_sec + tim_tv.tv_usec;
|
||||
}
|
||||
|
||||
/* _term_alloc(): libuv buffer allocator.
|
||||
*/
|
||||
static void
|
||||
_term_alloc(uv_handle_t* had_u,
|
||||
size_t len_i,
|
||||
uv_buf_t* buf
|
||||
)
|
||||
{
|
||||
void* ptr_v = c3_malloc(len_i);
|
||||
*buf = uv_buf_init(ptr_v, len_i);
|
||||
// this read can range from a single byte to a paste buffer
|
||||
// 32 bytes has been chosen heuristically
|
||||
//
|
||||
void* ptr_v = c3_malloc(32);
|
||||
*buf = uv_buf_init(ptr_v, 32);
|
||||
}
|
||||
|
||||
|
||||
@ -652,7 +657,7 @@ _term_io_suck_char(u3_utty* uty_u, c3_y cay_y)
|
||||
|
||||
// uL(fprintf(uH, "muck-utf8 len %d\n", tat_u->fut.len_w));
|
||||
// uL(fprintf(uH, "muck-utf8 %x\n", huv));
|
||||
wug = u3do("turf", huv);
|
||||
wug = u3do("taft", huv);
|
||||
// uL(fprintf(uH, "muck-utf32 %x\n", tat_u->fut.len_w));
|
||||
|
||||
tat_u->fut.len_w = tat_u->fut.wid_w = 0;
|
||||
|
@ -371,6 +371,8 @@ _unix_scan_mount_point(u3_umon* mon_u)
|
||||
_unix_watch_file(fil_u, &mon_u->dir_u, pax_c);
|
||||
}
|
||||
}
|
||||
|
||||
free(pax_c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -590,7 +592,8 @@ _unix_watch_file(u3_ufil* fil_u, u3_udir* par_u, c3_c* pax_c)
|
||||
|
||||
fil_u->dir = c3n;
|
||||
fil_u->dry = c3n;
|
||||
fil_u->pax_c = pax_c;
|
||||
fil_u->pax_c = c3_malloc(1 + strlen(pax_c));
|
||||
strcpy(fil_u->pax_c, pax_c);
|
||||
fil_u->par_u = par_u;
|
||||
fil_u->nex_u = NULL;
|
||||
fil_u->mug_w = 0;
|
||||
@ -627,7 +630,8 @@ _unix_watch_dir(u3_udir* dir_u, u3_udir* par_u, c3_c* pax_c)
|
||||
|
||||
dir_u->dir = c3y;
|
||||
dir_u->dry = c3n;
|
||||
dir_u->pax_c = pax_c;
|
||||
dir_u->pax_c = c3_malloc(1 + strlen(pax_c));
|
||||
strcpy(dir_u->pax_c, pax_c);
|
||||
dir_u->par_u = par_u;
|
||||
dir_u->nex_u = NULL;
|
||||
dir_u->kid_u = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user