Merge branch 'master' of github.com:urbit/urbit

This commit is contained in:
C. Guy Yarvin 2014-03-19 15:42:12 -07:00
commit 55c9f41b14
29 changed files with 602 additions and 326 deletions

6
.gitignore vendored
View File

@ -1,8 +1,4 @@
*.o
.gdb_history
/generated/
/bin/
*.swp
.*tags
/bin/vere
/urb/*/
!/urb/zod/

View File

@ -43,14 +43,14 @@ ifeq ($(OS),osx)
OSLIBS=-framework CoreServices -framework CoreFoundation
endif
ifeq ($(OS),linux)
OSLIBS=-lcrypto -lpthread -lrt -lcurses
OSLIBS=-lpthread -lrt -lcurses
DEFINES=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
endif
ifeq ($(OS),bsd)
OSLIBS=-lcrypto -lpthread -lncurses -lkvm
OSLIBS=-lpthread -lncurses -lkvm
endif
LIBS=-lgmp -lncurses -lsigsegv $(OSLIBS)
LIBS=-lssl -lcrypto -lgmp -lncurses -lsigsegv $(OSLIBS)
INCLUDE=include
GENERATED=generated

View File

@ -242,7 +242,7 @@ _ds_chip(u2_wire wir_r,
}
}
/* u2_ds_wipe():
/* u2_ds_wipe():
**
** Clear dashboard.
*/

View File

@ -37,7 +37,7 @@
# include "f/nock.h"
# include "f/funj.h"
# include "f/unix.h"
# include "f/hevn.h"
# include "f/hevn.h"
# include "f/arvo.h"
/** coal: common methods for dealing with nouns.

View File

@ -4,7 +4,7 @@
*/
/** Functions.
**/
/* c3_comd_init():
/* c3_comd_init():
**
** Initialize the readline console. Return the history filename.
*/
@ -18,5 +18,5 @@
** Returns 0 iff the console has exited.
*/
c3_c* // produce
c3_comd_line(const c3_c *fel_c,
c3_comd_line(const c3_c *fel_c,
const c3_c *prm_c); // retain

View File

@ -23,7 +23,7 @@
# include <unistd.h>
# include <stdint.h>
# include <assert.h>
# include <byteswap.h>
# include <byteswap.h>
# include <setjmp.h>
# include <stdio.h>
# include <signal.h>
@ -40,8 +40,8 @@
# include <assert.h>
# include <setjmp.h>
# include <signal.h>
# include <machine/endian.h>
# include <machine/byte_order.h>
# include <machine/endian.h>
# include <machine/byte_order.h>
# include <stdio.h>
# include <sys/time.h>
# include <sys/resource.h>

View File

@ -28,9 +28,9 @@
# define c3_and(x, y) ((x) && (y))
# define c3_or(x, y) ((x) || (y))
/* Deprecated integers.
/* Deprecated integers.
*/
typedef char c3_c; // does not match int8_t or uint8_t
typedef int c3_i; // int - really bad
typedef int c3_i; // int - really bad
typedef uintptr_t c3_p; // pointer-length uint - really really bad
typedef intptr_t c3_ps; // pointer-length int - really really bad

View File

@ -28,8 +28,8 @@
# define u2_kite_tax(kit_r) *u2_at(kit_r, u2_loom_kite, tax)
# define u2_kite_don(kit_r) *u2_at(kit_r, u2_loom_kite, don)
# define u2_kite_par_r(kit_r) *u2_at(kit_r, u2_loom_kite, par_r)
# define u2_kite_buf_r(kit_r) u2_aftr(kit_r, u2_loom_kite, buf_f)
# define u2_kite_par_r(kit_r) *u2_at(kit_r, u2_loom_kite, par_r)
# define u2_kite_buf_r(kit_r) u2_aftr(kit_r, u2_loom_kite, buf_f)
/** Functions.
@ -38,7 +38,7 @@
**/
/* u2_bl_bail(): bail out.
**
** Bail codes:
** Bail codes:
**
** c3__exit for normal exit with correct trace
** c3__fail for abnormal failure without assumptions
@ -111,7 +111,7 @@
** Factor `a` as a cell `[b c]`.
*/
void
u2_bi_cell(u2_wire wir_r,
u2_bi_cell(u2_wire wir_r,
u2_noun a,
u2_noun* b,
u2_noun* c);
@ -121,7 +121,7 @@
** Factor `a` as a quadruple `[b c d e]`.
*/
void
u2_bi_qual(u2_wire wir_r,
u2_bi_qual(u2_wire wir_r,
u2_noun a,
u2_noun* b,
u2_noun* c,
@ -179,10 +179,10 @@
/** Atom access.
**/
/* u2_bi_met():
/* u2_bi_met():
**
** Return the size of (b) in bits, rounded up to
** (1 << a_y).
** (1 << a_y).
**
** For example, (a_y == 3) returns the size in bytes.
*/
@ -199,7 +199,7 @@
u2_bi_bit(u2_wire wir_r,
c3_w a_w,
u2_noun b);
/* u2_bi_byte():
**
** Return byte (a_w) of (b).
@ -208,7 +208,7 @@
u2_bi_byte(u2_wire wir_r,
c3_w a_w,
u2_noun b);
/* u2_bi_bytes():
**
** Copy bytes (a_w) through (a_w + b_w - 1) from (d) to (c).
@ -291,11 +291,11 @@
**
** Create an atomic string from a list of bytes.
*/
u2_noun
u2_noun
u2_bn_tape(u2_wire wir_r,
u2_list lit);
/* u2_bn_cell():
/* u2_bn_cell():
**
** Produce the cell [a b].
*/
@ -337,13 +337,13 @@
*/
u2_noun
u2_bn_list(u2_wire wir_r, ...);
/* u2_bn_nock():
**
** Nock or bail.
*/
u2_noun // transfer
u2_bn_nock(u2_wire wir_r,
u2_bn_nock(u2_wire wir_r,
u2_noun bus, // retain
u2_noun fol); // retain
@ -355,7 +355,7 @@
u2_bn_mp(u2_wire wir_r,
mpz_t a_mp);
/* u2_bn_qual():
/* u2_bn_qual():
**
** Produce the quadruple [a b c d].
*/
@ -367,7 +367,7 @@
u2_noun d);
# define u2_bq(wir_r, a, b, c, d) u2_bn_qual(wir_r, a, b, c, d)
/* u2_bn_quil():
/* u2_bn_quil():
**
** Produce the quintuple [a b c d].
*/
@ -380,7 +380,7 @@
u2_noun e);
# define u2_bu(wir_r, a, b, c, d, e) u2_bn_quil(wir_r, a, b, c, d, e)
/* u2_bn_trel():
/* u2_bn_trel():
**
** Produce the triple [a b c].
*/
@ -409,7 +409,7 @@
u2_bn_molt(u2_wire wir_r,
u2_noun som, // retain
...); // retain
/* u2_bn_molf():
**
** As u2_bn_molt(), with argument pointer.
@ -426,9 +426,9 @@
u2_noun
u2_bn_mang(u2_wire wir_r,
u2_noun cor,
...); // nouns
...); // nouns
/* u2_bn_mong():
/* u2_bn_mong():
**
** Call by gate and sample (new convention).
** Caller retains `gat`, transfers `sam`.
@ -441,7 +441,7 @@
/* u2_bn_hook():
**
** Execute hook from core.
*/
*/
u2_noun // transfer
u2_bn_hook(u2_wire wir_r,
u2_noun cor, // retain

View File

@ -7,7 +7,7 @@
/* u2_loom_benx: tracing, profiling, debugging
*/
typedef struct _u2_loom_benx {
/* Source position debug stack:
/* Source position debug stack:
**
** *(list ~[* [@ @] [@ @]])
*/
@ -15,7 +15,7 @@
/* Manual context debug stack:
**
** *(list %{nap})
** *(list %{nap})
*/
u2_weak zof; // on shed
@ -92,7 +92,7 @@
u2_bean
u2_bx_post(u2_ray wir_r,
u2_noun* zat,
u2_noun* zof,
u2_noun* zof,
c3_d* sap_d,
c3_d* cop_d,
c3_d* det_d,
@ -130,13 +130,13 @@
/* u2_bx_copy(): note `cop` copied words.
*/
void
void
u2_bx_copy(u2_ray wir_r,
c3_w cop_w);
/* u2_bx_dent(): note 'det' identicals.
*/
void
void
u2_bx_dent(u2_ray wir_r,
c3_w det_w);
@ -144,8 +144,8 @@
*/
void
u2_bx_shed(u2_ray wir_r,
c3_ws wad_ws);
c3_ws wad_ws);
/* u2_bx_bask(): note `wad` allocated/freed words in basket.
*/
void
@ -159,7 +159,7 @@
/* u2_bx_rise(): go shallower (return) in the C stack.
*/
void
void
u2_bx_rise(u2_ray wir_r);
/* u2_bx_used(): report a user count.

View File

@ -5,7 +5,7 @@
/** Hash-table design:
***
*** The cash system is a 16-way hash tree designed to
*** scale smoothly, remaining small for small usage
*** scale smoothly, remaining small for small usage
*** and fast for big usage. It is also salted for use
*** of multiple associations in the same table.
***
@ -14,11 +14,11 @@
*** sample list. Matches are in every case within
*** the salt.
***
*** All the nouns in the sample list are equal, but
*** All the nouns in the sample list are equal, but
*** duplicate. Comparing duplicates is expensive, so
*** the hash-table stores every duplicate it finds.
***
*** The search key is the mug of the salt, XORed
*** The search key is the mug of the salt, XORed
*** with the mug of the sample. [XX - This sacrifices
*** efficiency to internal convenience and should
*** be replaced with direct salt.]
@ -32,7 +32,7 @@
*** all improbable, revert to linear search. 16 collisions
*** on the same 31-bit key will produce storage failure.
***
*** Future revisions should add a reclamation mode based on
*** Future revisions should add a reclamation mode based on
*** the "clock algorithm" (a variant on LRU). The clock
*** rotates around search-key space. Entries are reclaimed
*** if they are clocked out and either key or value has a
@ -41,7 +41,7 @@
/** Tunable constants.
**/
/* A 16-way subtable with remaining keyspace switches up to laminar
/* A 16-way subtable with remaining keyspace switches up to laminar
** mode when it exceeds `cash_hi` recursively counted entries, and
** reverts to collision mode when it falls back below `cash_lo`.
*/
@ -150,7 +150,7 @@
*/
u2_ray // produce
u2_cs_make(u2_ray ral_r);
/* u2_cs_find():
**
** Find `sam` for `sel`, or return `u2_none`.

View File

@ -50,7 +50,7 @@
u2_weak
u2_ch_find(u2_ray cad_r,
u2_noun nam);
/* u2_ch_find_cell():
**
** Find value for `[hed tal]` in `cad`, or return `u2_none`.
@ -68,7 +68,7 @@
u2_ch_find_mixt(u2_ray cad_r,
const c3_c* hed_c,
u2_noun tal);
/* u2_ch_save():
**
** Save `val` under `nam` in `cad`, allocating in `ral`.

View File

@ -7,14 +7,14 @@
*** Generally modeled on stage 223, but ideally isolated from it.
*** Currently depends for implementation on direct-linked jets.
***
*** Functions of the same name and tier may vary subtly from
*** Functions of the same name and tier may vary subtly from
*** kernel semantics. Be wary and read the header comment.
***
*** Most coal functions depend on u2_Wire, a thread-local global,
*** which addresses all memory and other thread state. This in
*** turn depends on u2_System.
**/
/** Globals.
**/
c3_global u2_ray u2_Wire; // __thread or equivalent
@ -41,9 +41,9 @@
# define u2z(som) u2_cz(som)
/** u2_cx*: crash-only core traversal.
/** u2_cx*: crash-only core traversal.
***
*** unless otherwise noted, u2_cx callers *retain* ownership of
*** unless otherwise noted, u2_cx callers *retain* ownership of
*** all argument nouns and pointers, and *preserve* ownership of
*** all results.
***
@ -59,7 +59,7 @@
#else
/* u2_cx_h (u2h): head.
*/
u2_noun
u2_noun
u2_cx_h(u2_noun som);
/* u2_cx_t (u2t): tail.
@ -101,12 +101,12 @@
u2_noun* c,
u2_noun* d,
u2_noun* e);
#endif
/** u2_cr*: crash-free core traversal.
***
*** unless otherwise noted, u2_cr callers *retain* ownership of
*** unless otherwise noted, u2_cr callers *retain* ownership of
*** all argument nouns and pointers, and *preserve* ownership of
*** all results.
***
@ -149,7 +149,7 @@
# define u2_cr_pqrs(a, b, c, d, e, f) u2_as_pqrs(a, b, c, d, e, f)
# define u2_cr_pqrs(a, b, c, d, e, f) u2_as_pqrs(a, b, c, d, e, f)
# define u2_cr_met(a_y, b) u2_met(a_y, b)
# define u2_cr_bit(a_w, b) u2_bit(a_w, b)
# define u2_cr_bit(a_w, b) u2_bit(a_w, b)
# define u2_cr_byte(a_w, b) u2_byte(a_w, b)
# define u2_cr_bytes(a_w, b_w, c_y, d) u2_bytes(a_w, b_w, c_y, d)
# define u2_cr_chop(m, f, w, t, d, s) u2_chop(m, f, w, t, d, s)
@ -171,7 +171,7 @@
/* u2_cr_at(): fragment `a` of `b`, or none.
*/
u2_weak
u2_cr_at(u2_atom a,
u2_cr_at(u2_atom a,
u2_weak b);
/* u2_cr_mean():
@ -189,7 +189,7 @@
*/
c3_w
u2_cr_mug(u2_noun a);
/* u2_cr_mug_string():
**
** Compute the mug of `a`, LSB first.
@ -441,10 +441,10 @@
u2_noun* e,
u2_noun* f);
/* u2_cr_met():
/* u2_cr_met():
**
** Return the size of (b) in bits, rounded up to
** (1 << a_y).
** (1 << a_y).
**
** For example, (a_y == 3) returns the size in bytes.
*/
@ -459,7 +459,7 @@
c3_b
u2_cr_bit(c3_w a_w,
u2_atom b);
/* u2_cr_byte():
**
** Return byte (a_w) of (b).
@ -467,7 +467,7 @@
c3_y
u2_cr_byte(c3_w a_w,
u2_atom b);
/* u2_cr_bytes():
**
** Copy bytes (a_w) through (a_w + b_w - 1) from (d) to (c).
@ -521,12 +521,12 @@
/* u2_cr_string(): `a`, a text atom, as malloced C string.
*/
c3_c*
c3_c*
u2_cr_string(u2_atom a);
/* u2_cr_tape(): `a`, a list of bytes, as malloced C string.
*/
c3_y*
c3_y*
u2_cr_tape(u2_noun a);
@ -607,7 +607,7 @@
**
** Create an atomic string from a list of bytes.
*/
u2_noun
u2_noun
u2_ci_duck(u2_noun a);
/* u2_ci_decimal():
@ -655,7 +655,7 @@
/* u2_cf_flat_save(): save `som` as `mod` at `pas`.
*/
u2_bean
u2_cf_flat_save(u2_noun mod,
u2_cf_flat_save(u2_noun mod,
u2_noun pas,
u2_noun som);
@ -672,16 +672,16 @@
/* u2_cf_list(): list all the files in directory `pas`. List of cask.
*/
u2_noun
u2_noun
u2_cf_list(u2_noun pas);
/* u2_cf_path(): assemble local path with noun thap and ext.
*/
u2_noun
u2_cf_path(c3_c* top_c,
c3_c* ext_c,
u2_cf_path(c3_c* top_c,
c3_c* ext_c,
u2_noun tah);
/** u2_cn_*: natural constructors.
***
@ -746,14 +746,14 @@
u2_noun
u2_cn_moch(u2_noun bus,
u2_noun fol);
/** u2_cs_*: general-purpose internal hash tables
/** u2_cs_*: general-purpose internal hash tables
**/
/** u2_cg_*: garbage collection (exception cleanup only)
**/
/** u2_cc_*: memoization / caching
**/
@ -761,18 +761,18 @@
**
** Cache search for function (0 means nock) and sample.
*/
u2_weak
u2_weak
u2_cc_find(u2_mote fun_m,
u2_noun sam);
u2_noun sam);
/* u2_cc_save():
**
** Cache store for function (0 means nock), sample and product.
*/
u2_weak
u2_cc_save(u2_mote fun_m,
u2_noun sam,
u2_noun pro);
u2_weak
u2_cc_save(u2_mote fun_m,
u2_noun sam,
u2_noun pro);
/* u2_cc_uniq():
**
@ -788,28 +788,28 @@
u2_weak
u2_cc_find_cell(u2_mote, u2_noun, u2_noun);
u2_weak
u2_cc_find_trel(u2_mote, u2_noun, u2_noun, u2_noun);
u2_weak
u2_cc_find_trel(u2_mote, u2_noun, u2_noun, u2_noun);
u2_weak
u2_cc_find_qual(u2_mote, u2_noun, u2_noun, u2_noun, u2_noun);
u2_weak
u2_cc_find_qual(u2_mote, u2_noun, u2_noun, u2_noun, u2_noun);
/* u2_cc_save_cell(): as u2_cc_save(), for `sam=[a b]`.
** u2_cc_save_trel(): as u2_cc_save(), for `sam=[a b c]`.
** u2_cc_save_qual(): as u2_cc_save(), for `sam=[a b c d]`.
*/
u2_weak
u2_cc_save_cell(u2_mote, u2_noun, u2_noun, u2_noun);
u2_weak
u2_cc_save_cell(u2_mote, u2_noun, u2_noun, u2_noun);
u2_weak
u2_cc_save_trel(u2_mote, u2_noun, u2_noun, u2_noun, u2_noun);
u2_weak
u2_cc_save_trel(u2_mote, u2_noun, u2_noun, u2_noun, u2_noun);
u2_weak
u2_cc_save_qual(u2_ray, u2_mote, u2_noun,
u2_noun,
u2_noun,
u2_noun,
u2_noun);
u2_weak
u2_cc_save_qual(u2_ray, u2_mote, u2_noun,
u2_noun,
u2_noun,
u2_noun,
u2_noun);
/** u2_cw: exporting, printing, saving or publishing nouns.
**/
@ -824,7 +824,7 @@
u2_noun
u2_ch_molt(u2_noun som,
...);
/* u2_ch_molf():
**
** As u2_ch_molt(), with argument pointer.
@ -833,7 +833,7 @@
u2_ch_molf(u2_noun som,
va_list vap);
/* u2_ch_mong():
/* u2_ch_mong():
**
** Call a function by gate and sample.
*/
@ -844,7 +844,7 @@
/* u2_ch_hook():
**
** Execute hook from core.
*/
*/
u2_noun
u2_ch_hook(u2_noun cor,
const c3_c* tam_c);
@ -899,7 +899,7 @@
*/
void
u2_cm_poll();
/* u2_cm_trip(): descend into a memory region.
**
** Memory allocated in the heap above is senior & frozen.
@ -930,7 +930,7 @@
u2_cm_ruby(u2_noun som);
/* u2_cm_bail(): bail out to the local trap. Does not return.
**
**
** Bail structure:
**
** %exit
@ -940,7 +940,7 @@
** [%need p=*(list path)]
**
** c3__exit for normal exit
** c3__fail for abnormal failure
** c3__fail for abnormal failure
**
** When in doubt, fail.
*/
@ -1079,7 +1079,7 @@
/* u2_cp: profiling and debugging.
**
** Profiling information is automatically cleared on each
** Profiling information is automatically cleared on each
*/
/* u2_cm_slab(): produce profiling record.
*/
@ -1142,12 +1142,12 @@
*/
u2_weak
u2_ckd_by_get(u2_noun a, u2_noun b);
/* u2_ckd_by_got(): map get for key `b` in map `a` with fail.
*/
u2_noun
u2_ckd_by_got(u2_noun a, u2_noun b);
/* u2_ckd_by_put(): map put for key `b`, value `c` in map `a`.
*/
u2_weak

View File

@ -38,7 +38,7 @@
u2_ds_find(u2_wire wir_r,
u2_noun cor); // retain
/* u2_ds_mine():
/* u2_ds_mine():
**
** Register and/or replace core.
*/
@ -56,7 +56,7 @@
u2_noun cor, // retain
const c3_c* tam_c); // retain
/* u2_ds_wipe():
/* u2_ds_wipe():
**
** Clear dashboard.
*/

View File

@ -15,7 +15,7 @@
typedef u2_noun u2_menu;
typedef u2_noun u2_plan;
typedef u2_noun u2_plot;
typedef u2_noun u2_prop;
typedef u2_noun u2_prop;
typedef u2_noun u2_rack;
typedef u2_noun u2_rung;
typedef u2_noun u2_rope;
@ -29,7 +29,7 @@
**/
/** Miscellaneous operators - all old.
**/
/* u2_fj_op_add():
/* u2_fj_op_add():
**
** Produce the sum of (a) and (b).
*/
@ -88,7 +88,7 @@
u2_atom
u2_fj_op_log(u2_wire wir_r,
u2_atom atom);
/* u2_fj_op_lsh():
**
** Produce (b << a).
@ -184,10 +184,10 @@
u2_fj_pool_add(u2_wire wir_r,
u2_noun pig,
u2_pool pool_sub);
/* u2_fj_pool_list():
**
** Convert (pool) to a pseudo-randomly sorted list,
** Convert (pool) to a pseudo-randomly sorted list,
** prepending to (list).
*/
u2_list
@ -210,7 +210,7 @@
** Return path to node of (pig) in (pool), under (axe); or 0.
*/
u2_atom
u2_fj_pool_at(u2_wire wir_r,
u2_fj_pool_at(u2_wire wir_r,
u2_noun pig_in,
u2_atom axe,
u2_pool pool);
@ -232,7 +232,7 @@
u2_fj_book_in(u2_noun tag_in,
u2_book book);
/* u2_fj_book_get():
/* u2_fj_book_get():
**
** Produce the dog in (book) matching (tag_get), or u2_none.
*/
@ -263,7 +263,7 @@
/* u2_fj_book_list():
**
** Convert (book) to a pseudo-randomly sorted list of (tag dog)
** Convert (book) to a pseudo-randomly sorted list of (tag dog)
** cells, prepending to (list).
*/
u2_list
@ -273,7 +273,7 @@
/** Parsing.
**/
/* u2_fj_watt():
/* u2_fj_watt():
**
** Convert `zar`, a text atom, to a gene.
*/

View File

@ -102,13 +102,13 @@
# define j2_pb(a, b, p) _j2_qp(p, _j2_ab(a, b))
# define j2_pc(a, b, c, p) _j2_qp(p, _j2_abc(a, b, c))
# define j2_pd(a, b, c, d, p) _j2_qp(p, _j2_abcd(a, b, c, d))
# define j2_pe(a, b, c, d, e, p) _j2_qp(p, _j2_abcde(a, b, c, d, e))
# define j2_pe(a, b, c, d, e, p) _j2_qp(p, _j2_abcde(a, b, c, d, e))
# define j2_pac(a, p) _j2_qpc(p, _j2_a(a))
# define j2_pbc(a, b, p) _j2_qpc(p, _j2_ab(a, b))
# define j2_pcc(a, b, c, p) _j2_qpc(p, _j2_abc(a, b, c))
# define j2_pdc(a, b, c, d, p) _j2_qpc(p, _j2_abcd(a, b, c, d))
# define j2_pec(a, b, c, d, e, p) _j2_qpc(p, _j2_abcde(a, b, c, d, e))
# define j2_pec(a, b, c, d, e, p) _j2_qpc(p, _j2_abcde(a, b, c, d, e))
/** Types.
**/
@ -156,7 +156,7 @@
**
** c3__lite // does not bail
** c3__hevy // may bail
*/
*/
c3_m vok_m;
/* C function, on core. Declared.
@ -194,7 +194,7 @@
/* Control string - computed from seals.
*/
const c3_c* cos_c;
/* Function/formula jet array. Null `fcs` terminates.
*/
u2_ho_jet *fan_j;
@ -234,14 +234,14 @@
/** Functions.
**/
/* u2_ho_push():
/* u2_ho_push():
**
** Push a driver hangar (corresponding to a jet shed).
*/
void
u2_ho_push(void);
/* u2_ho_popp():
/* u2_ho_popp():
**
** Pop a driver hangar.
*/
@ -260,7 +260,7 @@
c3_c* // transfer
u2_ho_cstring(u2_noun xip); // retain
/* u2_ho_warn():
/* u2_ho_warn():
**
** Report a warning at file and line. This is assumed
** to have no semantic effect and negligible cost.

View File

@ -83,7 +83,7 @@
(LoomFrame == LoomFrameMax ? (LoomStop = 1) : LoomFrame++)
# define LoomRise \
(LoomFrame--)
// # define LoomFold
/** Data types.
@ -152,7 +152,7 @@
u2_ray hed_r;
u2_ray tel_r;
} u2_loom_cell;
/** Basic macros.
**/
/** Bitfield unpacking. See above.
@ -181,7 +181,7 @@
# define u2_fly_is_atom(a) \
(u2_fly_is_cat(a) || u2_dog_is_pug(a))
/** Bitfield packing. See above.
**/
@ -241,12 +241,12 @@
((ray) + \
( ((c3_w *)&((type *)0)->field) - \
((c3_w *)0) ) \
)
)
# define u2_fore(ray, type, field) \
((ray - 1) - \
( ((c3_w *)&((type *)0)->field) - \
((c3_w *)0) ) \
)
)
# define u2_at(ray, type, field) \
u2_at_ray(u2_aftr(ray, type, field))
@ -525,7 +525,7 @@
#if 0
u2_bean
u2_dust(u2_noun a)
#else
#else
# define u2_dust(a) \
(u2_fly_is_atom(a) ? u2_no : u2_yes)
#endif
@ -553,7 +553,7 @@
*/
c3_w
u2_mug(u2_noun a);
/* u2_mug_string():
**
** Compute the mug of `a`, LSB first.
@ -730,7 +730,7 @@
#if 0
u2_bean
u2_stud(u2_noun a)
#else
#else
# define u2_stud(a) \
(u2_fly_is_atom(a) ? u2_yes : u2_no)
#endif
@ -871,10 +871,10 @@
/** Atom access.
**/
/* u2_met():
/* u2_met():
**
** Return the size of (b) in bits, rounded up to
** (1 << a_y).
** (1 << a_y).
**
** For example, (a_y == 3) returns the size in bytes.
*/
@ -889,7 +889,7 @@
c3_b
u2_bit(c3_w a_w,
u2_atom b);
/* u2_byte():
**
** Return byte (a_w) of (b).
@ -897,7 +897,7 @@
c3_y
u2_byte(c3_w a_w,
u2_atom b);
/* u2_bytes():
**
** Copy bytes (a_w) through (a_w + b_w - 1) from (d) to (c).

View File

@ -70,10 +70,10 @@
# define u2_plow_(wir_r, pat) \
*u2_at(u2_wire_plo_r(wir_r), u2_loom_plow, pat)
/** Functions.
**/
/* u2_pl_boot():
/* u2_pl_boot():
**
** Initialize plow support context.
*/

View File

@ -224,7 +224,7 @@
void
u2_rl_ok(u2_ray ral_r,
u2_noun som); // retain
/* u2_rl_junior():
**
** Yes iff `dus` is junior in `ral` - ie, must be copied
@ -251,7 +251,7 @@
/* u2_rl_leap_part():
**
** Reverse and split rail, inserting partition of size `num/dem`
** plus `tip`.
** plus `tip`.
**
** Returns partition rail, `aux_r`.
*/
@ -293,7 +293,7 @@
c3_w
u2_rl_gc_mark(u2_ray ral_r);
/* u2_rl_gc_sweep():
/* u2_rl_gc_sweep():
**
** Sweep memory, freeing unused blocks. Match live, save leaked.
*/
@ -450,7 +450,7 @@
c3_w a_w,
const c3_y* b_y);
/* u2_rl_cell():
/* u2_rl_cell():
**
** Produce the cell `[a b]`.
*/
@ -489,7 +489,7 @@
u2_rl_molt(u2_rail ral_r,
u2_weak som, // retain
...); // transfer
/* u2_rl_molv():
**
** As u2_rl_molt(), by argument pointer.
@ -621,19 +621,19 @@
** Extend as needed...
*/
u2_weak // transfer
u2_rl_find_cell(u2_ray, u2_mote, u2_noun, // retain
u2_rl_find_cell(u2_ray, u2_mote, u2_noun, // retain
u2_noun); // retain
u2_weak // transfer
u2_rl_find_trel(u2_ray, u2_mote, u2_noun, // retain
u2_rl_find_trel(u2_ray, u2_mote, u2_noun, // retain
u2_noun, // retain
u2_noun); // retain
u2_weak // transfer
u2_rl_find_qual(u2_ray, u2_mote, u2_noun, // retain
u2_rl_find_qual(u2_ray, u2_mote, u2_noun, // retain
u2_noun, // retain
u2_noun, // retain
u2_noun); // retain
u2_weak // transfer
u2_rl_find_quil(u2_ray, u2_mote, u2_noun, // retain
u2_rl_find_quil(u2_ray, u2_mote, u2_noun, // retain
u2_noun, // retain
u2_noun, // retain
u2_noun, // retain
@ -647,25 +647,25 @@
** Extended
*/
u2_weak // transfer
u2_rl_save_cell(u2_ray, u2_mote, u2_noun, // retain
u2_rl_save_cell(u2_ray, u2_mote, u2_noun, // retain
u2_noun, // retain
u2_noun); // transfer
u2_weak // transfer
u2_rl_save_trel(u2_ray, u2_mote, u2_noun, // retain
u2_rl_save_trel(u2_ray, u2_mote, u2_noun, // retain
u2_noun, // retain
u2_noun, // retain
u2_noun); // transfer
u2_weak // transfer
u2_rl_save_qual(u2_ray, u2_mote, u2_noun, // retain
u2_rl_save_qual(u2_ray, u2_mote, u2_noun, // retain
u2_noun, // retain
u2_noun, // retain
u2_noun, // retain
u2_noun); // transfer
u2_weak // transfer
u2_rl_save_quil(u2_ray, u2_mote, u2_noun, // retain
u2_rl_save_quil(u2_ray, u2_mote, u2_noun, // retain
u2_noun, // retain
u2_noun, // retain
u2_noun, // retain

View File

@ -52,20 +52,20 @@
/** Functions.
**/
/* u2_sh_init():
/* u2_sh_init():
**
** Initialize shed, with parent if any.
*/
void
u2_sh_init(u2_wire wir_r);
/* u2_sh_find(): find chip by core, or none. Includes validate.
*/
u2_weak // senior
u2_sh_find(u2_wire wir_r,
u2_noun cor); // retain
/* u2_sh_mine():
/* u2_sh_mine():
**
** Register and/or replace core.
*/

View File

@ -74,7 +74,7 @@
/* Number of samples in interpreted code.
*/
c3_d erp_d;
} wer;
} wer;
/* Profiling.
*/
@ -163,7 +163,7 @@
/* u2_tx_done(): produce a profile slab to render. Close tracing.
**
** type:
*/
*/
u2_noun // produce
u2_tx_done(u2_ray wir_r);
@ -221,24 +221,24 @@
*/
# define u2_tx_add_mem(ral_r, det_ws) \
( (0 == ral_r) ? u2_tx_add_men(ral_r, det_ws) \
: u2_tx_add_bek(0, det_ws)
: u2_tx_add_bek(0, det_ws)
/* u2_tx_did_act(): record user actions.
*/
void
u2_tx_did_act(u2_ray wir_r,
void
u2_tx_did_act(u2_ray wir_r,
u2_noun did); // retain
/* u2_tx_sys_bit(): set system bit, returning old value.
*/
u2_bean
u2_tx_sys_bit(u2_ray wir_r,
u2_tx_sys_bit(u2_ray wir_r,
u2_bean val);
/* u2_tx_glu_bit(): set glue bit within system bit.
*/
u2_bean
u2_tx_glu_bit(u2_ray wir_r,
u2_tx_glu_bit(u2_ray wir_r,
u2_bean val);
/** Tasks.
**/
@ -247,7 +247,7 @@
** u2_yes iff the task is not already in the stack.
*/
u2_bean
u2_tx_task_in(u2_ray wir_r,
u2_tx_task_in(u2_ray wir_r,
u2_noun tak); // retain
/* u2_tx_task_out(): leave a task for profiling purposes.

View File

@ -26,7 +26,7 @@
const c3_c* src_c,
const c3_c* dat_c,
const c3_c* oxt_c,
u2_life nex_l);
u2_life nex_l);
/* u2_ux_live(): load/reload a monitored source; u2_yes for change.
*/

View File

@ -49,7 +49,7 @@
} u2_loom_wire;
# define u2_wire_bas_r(wir_r) *u2_at(wir_r, u2_loom_wire, bas_r)
# define u2_wire_des_r(wir_r) u2_aftr(wir_r, u2_loom_wire, des_s)
# define u2_wire_des_r(wir_r) u2_aftr(wir_r, u2_loom_wire, des_s)
# define u2_wire_kit_r(wir_r) *u2_at(wir_r, u2_loom_wire, kit_r)
# define u2_wire_bex_r(wir_r) *u2_at(wir_r, u2_loom_wire, bex_r)
# define u2_wire_rac_r(wir_r) *u2_at(wir_r, u2_loom_wire, rac_r)

View File

@ -8,7 +8,7 @@
*/
# define FirstKernel 164
# define DefaultKernel 164
#define RECK
/** Data types.
@ -26,7 +26,7 @@
/* u2_hbod: http body block. Also used for responses.
*/
typedef struct _u2_hbod {
struct _u2_hbod* nex_u;
struct _u2_hbod* nex_u;
c3_w len_w;
c3_y hun_y[0];
} u2_hbod;
@ -34,7 +34,7 @@
/* u2_hrat: http parser state.
*/
typedef enum {
u2_hreq_non,
u2_hreq_non,
u2_hreq_nam,
u2_hreq_val
} u2_hrat;
@ -44,7 +44,10 @@
typedef enum {
u2_csat_dead = 0, // connection dead
u2_csat_addr = 1, // connection addressed
u2_csat_live = 2, // connection open
u2_csat_clyr = 2, // connection open in cleartext
u2_csat_crop = 3, // connection open, ssl needs hs
u2_csat_sing = 4, // connection handshaking ssl
u2_csat_cryp = 5, // connection open, ssl open
} u2_csat;
/* u2_hmet: http method. Matches jhttp encoding.
@ -58,7 +61,7 @@
u2_hmet_nop, // virtual method
u2_hmet_other // ie, unsupported
} u2_hmet;
/* u2_hreq: incoming http request.
*/
typedef struct _u2_hreq {
@ -70,7 +73,7 @@
c3_c* url_c; // url
u2_bean liv; // keepalive
u2_bean end; // all responses added
u2_hhed* hed_u; // headers
u2_hhed* hed_u; // headers
u2_hbod* bod_u; // body parts (exit)
u2_hbod* dob_u; // body parts (entry)
struct _u2_hreq* nex_u; // next in request queue
@ -95,7 +98,7 @@
uv_tcp_t wax_u; // event handler state
c3_w coq_l; // connection number
c3_w seq_l; // next request number
struct _u2_http* htp_u; // backlink to server
struct _u2_http* htp_u; // backlink to server
struct _u2_hcon* nex_u; // next in server's list
struct _u2_hreq* ruc_u; // request under construction
struct _u2_hreq* req_u; // exit of request queue
@ -120,7 +123,7 @@
u2_hrat rat_e; // parser state
void* par_u; // struct http_parser *
c3_w sas_w; // status code
u2_hhed* hed_u; // headers
u2_hhed* hed_u; // headers
u2_hbod* bod_u; // exit of body queue
u2_hbod* dob_u; // entry of body queue
} u2_cres;
@ -141,12 +144,21 @@
struct _u2_creq* nex_u; // next in queue
} u2_creq;
/* u2_sslx: per-connection ssl context.
*/
typedef struct _u2_sslx {
void* ssl_u; // struct SSL*
void* rio_u; // struct BIO* for read
void* wio_u; // struct BIO* for write
} u2_sslx;
/* u2_ccon: outgoing http connection.
*/
typedef struct _u2_ccon { // client connection
uv_tcp_t wax_u; // i/o handler state
uv_connect_t cot_u; // connection handler state
uv_connect_t cot_u; // connection handler state
uv_getaddrinfo_t adr_u; // resolver state
u2_sslx ssl; // ssl state
u2_csat sat_e; // connection state
c3_c* hot_c; // hostname
c3_s por_s; // port
@ -207,7 +219,7 @@
/* u2_ubuf: unix tty i/o buffer.
*/
typedef struct _u2_ubuf {
struct _u2_ubuf* nex_u;
struct _u2_ubuf* nex_u;
c3_w len_w;
c3_y hun_y[0]; // bytes to send
} u2_ubuf;
@ -227,7 +239,7 @@
} mir;
struct { // escape code control
u2_bean ape; // escape received
u2_bean ape; // escape received
u2_bean bra; // bracket or O received
} esc;
@ -284,7 +296,7 @@
*/
typedef struct _u2_unod {
uv_fs_event_t was_u; // stat watcher
u2_bean dir; // always
u2_bean dir; // always
u2_bean dry; // ie, unmodified
c3_c* pax_c; // absolute path
struct _u2_udir* par_u; // in directory
@ -332,7 +344,7 @@
struct _u2_usig* nex_u;
} u2_usig;
/* u2_unix: clay support system, also
/* u2_unix: clay support system, also
*/
typedef struct _u2_unix {
uv_timer_t tim_u; // clay timer
@ -354,14 +366,14 @@
typedef struct {
struct {
const c3_y* kcuu1_y; // key_up
const c3_y* kcud1_y; // key_down
const c3_y* kcud1_y; // key_down
const c3_y* kcub1_y; // key_back
const c3_y* kcuf1_y; // key_forward
c3_w max_w; // maximum input sequence length
} inn;
struct {
const c3_y* clear_y; // clear_screen
const c3_y* el_y; // clr_bol clear to beginning
const c3_y* el_y; // clr_bol clear to beginning
// const c3_y* el1_y; // clr_eol clear to end
const c3_y* ed_y; // clear to end of screen
const c3_y* bel_y; // bel sound bell
@ -370,7 +382,7 @@
const c3_y* cuu1_y; // parm_up
const c3_y* cud1_y; // parm_down
// const c3_y* cub_y; // parm_left_cursor #num
// const c3_y* cuf_y; // parm_right_cursor #num
// const c3_y* cuf_y; // parm_right_cursor #num
} out;
} u2_utfo;
@ -430,21 +442,21 @@
/* u2_raft: raft state.
*/
typedef struct {
uv_tcp_t wax_u;
uv_timer_t tim_u;
u2_ulog lug_u; // event log
c3_w ent_w;
c3_w lat_w;
u2_raty typ_e;
struct _u2_rnam* nam_u;
struct _u2_rcon* run_u;
c3_w pop_w;
c3_w vot_w;
c3_c* str_c; // our name
// persistent state, restored on start
c3_w tem_w;
c3_c* vog_c;
// end persistent state
uv_tcp_t wax_u; // TCP listener
uv_timer_t tim_u; // election/heartbeat timer
u2_ulog lug_u; // event log
c3_w ent_w; // last log index
c3_w lat_w; // last log term
u2_raty typ_e; // server type
struct _u2_rnam* nam_u; // list of peers
struct _u2_rcon* run_u; // unknown connections
c3_w pop_w; // population count
c3_w vot_w; // votes in this election
c3_c* str_c; // our name
// persistent state
c3_w tem_w; // current term
c3_c* vog_c; // who we voted for this term
// end persistent state
} u2_raft;
/* u2_rreq: raft request.
@ -466,27 +478,27 @@
/* u2_rcon: raft connection.
*/
typedef struct _u2_rcon {
uv_tcp_t wax_u;
struct _u2_rnam* nam_u;
u2_rbuf* red_u;
u2_bean red;
u2_rbuf* wri_u;
u2_raft* raf_u;
u2_rreq* out_u;
u2_rreq* tou_u;
struct _u2_rcon* nex_u;
u2_bean liv;
uv_tcp_t wax_u; // TCP handle
struct _u2_rnam* nam_u; // peer we're connected to
u2_rbuf* red_u; // read buffer
u2_bean red; // u2_yes on new data
u2_rbuf* wri_u; // write buffer
u2_raft* raf_u; // back-reference to server
u2_rreq* out_u; // exit of request queue
u2_rreq* tou_u; // entry of request queue
struct _u2_rcon* nex_u; // pointer to next con
u2_bean liv; // are we live?
} u2_rcon;
/* u2_rnam: raft peer name.
*/
typedef struct _u2_rnam {
c3_c* str_c;
c3_c* nam_c;
c3_c* por_c;
u2_rcon* ron_u;
struct _u2_rnam* nex_u;
u2_bean vog;
c3_c* str_c; // our name
c3_c* nam_c; // hostname
c3_c* por_c; // port
u2_rcon* ron_u; // connection
struct _u2_rnam* nex_u; // pointer to next peer
u2_bean vog; // did they vote for us?
} u2_rnam;
/* u2_opts:
@ -494,7 +506,7 @@
typedef struct _u2_opts {
c3_c* cpu_c;
c3_c* imp_c;
c3_c* hom_c;
c3_c* hom_c;
c3_c* nam_c;
c3_c* raf_c;
c3_w kno_w;
@ -526,7 +538,7 @@
uv_loop_t* lup_u; // libuv event loop
u2_http* htp_u; // http servers
u2_cttp ctp_u; // http clients
u2_utty* uty_u; // all terminals
u2_utty* uty_u; // all terminals
u2_utty* tem_u; // main terminal (1)
u2_ames sam_u; // packet interface
u2_save sav_u; // autosave
@ -534,12 +546,14 @@
u2_unix unx_u; // sync and clay
u2_batz beh_u; // batz timer
u2_bean liv; // if u2_no, shut down
void* ssl_u; // struct SSL_CTX*
u2_reck* arv_u; // runtime
} u2_host; // host == computer == process
# define u2L u2_Host.lup_u // global event loop
# define u2R (&(u2_Raft))
# define u2S u2_Host.ssl_u
/* u2_funk: standard system function.
*/
@ -580,14 +594,14 @@
** platform OS will not ignore them, of course, so they must be detected
** and counteracted. Perhaps this phenomenon will soon find an endpoint.
*/
/* u2_time_sec_in(): urbit seconds from unix time.
/* u2_time_sec_in(): urbit seconds from unix time.
**
** Adjust (externally) for future leap secs!
*/
c3_d
u2_time_sec_in(c3_w unx_w);
/* u2_time_sec_out(): unix time from urbit seconds.
/* u2_time_sec_out(): unix time from urbit seconds.
**
** Adjust (externally) for future leap secs!
*/
@ -662,7 +676,7 @@
u2_noun
u2_walk(u2_reck* rec_u, const c3_c* dir_c, u2_noun old);
/* u2_path(): C unix path in computer for file or directory.
/* u2_path(): C unix path in computer for file or directory.
*/
c3_c*
u2_path(u2_bean fyl, u2_noun pax);
@ -729,9 +743,9 @@
/* u2_reck_http_request(): hear http request on channel.
*/
void
u2_reck_http_request(u2_reck* rec_u,
u2_reck_http_request(u2_reck* rec_u,
u2_bean sec,
u2_noun pox,
u2_noun pox,
u2_noun req);
/* u2_reck_http_respond(): apply http response.
@ -761,7 +775,7 @@
/* u2_reck_keep(): measure timer.
*/
u2_noun
u2_noun
u2_reck_keep(u2_reck* rec_u, u2_noun hap);
/* u2_reck_pike(): poke with floating core.
@ -793,7 +807,7 @@
*/
void
u2_reck_time(u2_reck* rec_u);
/* u2_reck_wind(): set the reck time artificially.
*/
void
@ -904,7 +918,7 @@
*/
void
u2_term_ef_ctlc(void);
/* u2_term_ef_bake(): initial effects for new server.
*/
void
@ -918,19 +932,19 @@
/* u2_term_io_init(): initialize terminal I/O.
*/
void
void
u2_term_io_init(void);
/* u2_term_io_exit(): terminate terminal I/O.
*/
void
void
u2_term_io_exit(void);
/* u2_term_io_poll(): update terminal IO state.
*/
void
u2_term_io_poll(void);
/* u2_term_io_hija(): hijack console for cooked print.
*/
FILE*
@ -959,7 +973,7 @@
/* u2_ames_io_init(): initialize ames I/O.
*/
void
void
u2_ames_io_init(void);
/* u2_ames_io_talk(): bring up listener.
@ -969,7 +983,7 @@
/* u2_ames_io_exit(): terminate ames I/O.
*/
void
void
u2_ames_io_exit(void);
/* u2_ames_io_poll(): update ames IO state.
@ -986,12 +1000,12 @@
/* u2_save_io_init(): initialize autosave.
*/
void
void
u2_save_io_init(void);
/* u2_save_io_exit(): terminate autosave.
*/
void
void
u2_save_io_exit(void);
/* u2_save_io_poll(): update autosave state.
@ -1001,7 +1015,7 @@
/** Storage, new school.
**/
/* u2_unix_ef_hold():
/* u2_unix_ef_hold():
*/
void
u2_unix_ef_hold();
@ -1030,7 +1044,7 @@
/* u2_unix_io_init(): initialize storage.
*/
void
void
u2_unix_io_init(void);
/* u2_unix_io_talk(): start listening for fs events.
@ -1040,7 +1054,7 @@
/* u2_unix_io_exit(): terminate storage.
*/
void
void
u2_unix_io_exit(void);
/* u2_unix_io_poll(): update storage state.
@ -1053,12 +1067,12 @@
**/
/* u2_batz_io_init(): initialize batz timer.
*/
void
void
u2_batz_io_init(void);
/* u2_batz_io_exit(): terminate timer.
*/
void
void
u2_batz_io_exit(void);
/* u2_batz_io_poll(): update batz IO state.
@ -1069,7 +1083,7 @@
/** HTTP server.
**/
/* u2_http_ef_thou(): send %thou effect to http.
/* u2_http_ef_thou(): send %thou effect to http.
*/
void
u2_http_ef_thou(c3_l sev_l,
@ -1090,7 +1104,7 @@
/* u2_http_io_init(): initialize http I/O.
*/
void
void
u2_http_io_init(void);
/* u2_http_io_talk(): start http listener.
@ -1100,7 +1114,7 @@
/* u2_http_io_exit(): terminate http I/O.
*/
void
void
u2_http_io_exit(void);
/* u2_http_io_poll(): update http IO state.
@ -1202,12 +1216,12 @@
/* u2_cttp_io_init(): initialize cttp I/O.
*/
void
void
u2_cttp_io_init(void);
/* u2_cttp_io_exit(): terminate cttp I/O.
*/
void
void
u2_cttp_io_exit(void);
/* u2_cttp_io_poll(): update cttp IO state.

378
v/cttp.c
View File

@ -19,15 +19,27 @@
#include <termios.h>
#include <term.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include "../outside/jhttp/http_parser.h" // Joyent HTTP
#include "all.h"
#include "v/vere.h"
/* Forward declarations.
#ifdef U2_OS_osx
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
/* Forward declarations.
*/
static void _cttp_ccon_kick(u2_ccon* coc_u);
static void _cttp_ccon_cryp_hurr(u2_ccon* coc_u, c3_i rev_i);
static void _cttp_ccon_cryp_rout(u2_ccon* coc_u);
static void _cttp_ccon_fill(u2_ccon* coc_u);
static void _cttp_ccon_fire(u2_ccon* coc_u, u2_creq* ceq_u);
static void _cttp_ccon_fail_cb(uv_handle_t* wax_u);
static c3_c* _cttp_creq_url(u2_noun pul);
/* _cttp_alloc(): libuv buffer allocator.
@ -180,7 +192,7 @@ _cttp_heds_math(u2_hhed* hed_u, u2_noun mah)
{
if ( u2_nul == mah ) {
return hed_u;
}
}
else {
u2_noun n_mah = u2h(mah);
u2_noun pn_mah = u2h(n_mah);
@ -332,7 +344,7 @@ _cttp_mcut_pfix(c3_c* buf_c, c3_w len_w, u2_noun hat)
}
#endif
/* _cttp_mcut_pork(): measure/cut path/extension.
/* _cttp_mcut_pork(): measure/cut path/extension.
*/
static c3_w
_cttp_mcut_pork(c3_c* buf_c, c3_w len_w, u2_noun pok)
@ -383,7 +395,7 @@ _cttp_mcut_url(c3_c* buf_c, c3_w len_w, u2_noun pul)
{
u2_noun q_pul = u2h(u2t(pul));
u2_noun r_pul = u2t(u2t(pul));
// len_w = _cttp_mcut_pfix(buf_c, len_w, u2k(p_pul));
len_w = _cttp_mcut_char(buf_c, len_w, '/');
len_w = _cttp_mcut_pork(buf_c, len_w, u2k(q_pul));
@ -625,6 +637,11 @@ _cttp_message_complete(http_parser* par_u)
c3_assert(ceq_u == coc_u->qec_u);
coc_u->qec_u = 0;
}
if ( u2_yes == coc_u->sec ) {
SSL_shutdown(coc_u->ssl.ssl_u);
_cttp_ccon_cryp_rout(coc_u);
uv_close((uv_handle_t*)&coc_u->wax_u, _cttp_ccon_fail_cb);
}
return 0;
}
@ -658,37 +675,37 @@ _cttp_cres_start(u2_creq* ceq_u)
/* _cttp_ccon_wax(): connection from wax_u.
*/
static u2_ccon*
static u2_ccon*
_cttp_ccon_wax(uv_tcp_t* wax_u)
{
u2_ccon* coc_u = 0;
return (u2_ccon*)(void *)
( ((c3_y *)(void *)wax_u) -
return (u2_ccon*)(void *)
( ((c3_y *)(void *)wax_u) -
(((c3_y *)(void *)&(coc_u->wax_u)) - ((c3_y *)(void *)(coc_u))) );
}
/* _cttp_ccon_cot(): connection from cot_u.
*/
static u2_ccon*
static u2_ccon*
_cttp_ccon_cot(uv_connect_t* cot_u)
{
u2_ccon* coc_u = 0;
return (u2_ccon*)(void *)
( ((c3_y *)(void *)cot_u) -
return (u2_ccon*)(void *)
( ((c3_y *)(void *)cot_u) -
(((c3_y *)(void *)&(coc_u->cot_u)) - ((c3_y *)(void *)(coc_u))) );
}
/* _cttp_ccon_adr(): connection from adr_u.
*/
static u2_ccon*
static u2_ccon*
_cttp_ccon_adr(uv_getaddrinfo_t* adr_u)
{
u2_ccon* coc_u = 0;
return (u2_ccon*)(void *)
( ((c3_y *)(void *)adr_u) -
return (u2_ccon*)(void *)
( ((c3_y *)(void *)adr_u) -
(((c3_y *)(void *)&(coc_u->adr_u)) - ((c3_y *)(void *)(coc_u))) );
}
@ -708,7 +725,7 @@ _cttp_ccon_waste(u2_ccon* coc_u, c3_c* msg_c)
}
_cttp_creq_free(ceq_u);
}
free(coc_u->hot_c);
_cttp_bods_free(coc_u->rub_u);
@ -720,6 +737,9 @@ _cttp_ccon_waste(u2_ccon* coc_u, c3_c* msg_c)
if ( coc_u->nex_u ) {
coc_u->nex_u->pre_u = coc_u->pre_u;
}
if ( coc_u->ssl.ssl_u ) {
SSL_free(coc_u->ssl.ssl_u);
}
free(coc_u);
}
@ -756,14 +776,22 @@ _cttp_ccon_reboot(u2_ccon* coc_u)
_cttp_ccon_waste(coc_u, "could not resolve address");
break;
}
case u2_csat_addr: {
case u2_csat_addr: {
/* Got an address but not a connection. Waste it.
*/
_cttp_ccon_waste(coc_u, "connection failed");
break;
}
case u2_csat_live: {
/* We had a connection but it broke. Either there are no
case u2_csat_crop:
case u2_csat_sing: {
/* Got a connection, but SSL failed. Waste it.
*/
_cttp_ccon_waste(coc_u, "ssl handshake failed");
break;
}
case u2_csat_cryp:
case u2_csat_clyr: {
/* We had a connection but it broke. Either there are no
** living requests, in which case waste; otherwise reset.
*/
if ( 0 == coc_u->ceq_u ) {
@ -803,7 +831,7 @@ _cttp_ccon_fail(u2_ccon* coc_u, u2_bean say)
uL(fprintf(uH, "cttp: %s\n", uv_strerror(uv_last_error(u2L))));
}
if ( coc_u->sat_e != u2_csat_live ) {
if ( coc_u->sat_e < u2_csat_crop ) {
_cttp_ccon_reboot(coc_u);
}
else {
@ -844,14 +872,14 @@ _cttp_ccon_kick_resolve(u2_ccon* coc_u)
c3_assert(u2_csat_dead == coc_u->sat_e);
snprintf(por_c, 7, "%d", 65535 & coc_u->por_s);
snprintf(por_c, 7, "%d", 65535 & coc_u->por_s);
memset(&hin_u, 0, sizeof(struct addrinfo));
hin_u.ai_family = PF_INET;
hin_u.ai_socktype = SOCK_STREAM;
hin_u.ai_protocol = IPPROTO_TCP;
if ( 0 != uv_getaddrinfo(u2L, &coc_u->adr_u,
_cttp_ccon_kick_resolve_cb,
if ( 0 != uv_getaddrinfo(u2L, &coc_u->adr_u,
_cttp_ccon_kick_resolve_cb,
coc_u->hot_c, por_c, &hin_u) )
{
_cttp_ccon_fail(coc_u, u2_yes);
@ -872,7 +900,9 @@ _cttp_ccon_kick_connect_cb(uv_connect_t* cot_u,
_cttp_ccon_fail(coc_u, u2_yes);
}
else {
coc_u->sat_e = u2_csat_live;
coc_u->sat_e = (u2_yes == coc_u->sec) ?
u2_csat_crop :
u2_csat_clyr;
_cttp_ccon_kick(coc_u);
}
}
@ -894,9 +924,9 @@ _cttp_ccon_kick_connect(u2_ccon* coc_u)
add_u.sin_port = htons(coc_u->por_s);
add_u.sin_addr.s_addr = htonl(coc_u->ipf_w);
if ( 0 != uv_tcp_connect(&coc_u->cot_u,
&coc_u->wax_u,
add_u,
if ( 0 != uv_tcp_connect(&coc_u->cot_u,
&coc_u->wax_u,
add_u,
_cttp_ccon_kick_connect_cb) )
{
_cttp_ccon_fail(coc_u, u2_yes);
@ -911,7 +941,7 @@ _cttp_ccon_kick_connect(u2_ccon* coc_u)
c3_y* buf_y;
} _u2_write_t;
/* _cttp_ccon_kick_write_cb(): general write callback.
/* _cttp_ccon_kick_write_cb(): general write callback
*/
static void
_cttp_ccon_kick_write_cb(uv_write_t* wri_u, c3_i sas_i)
@ -929,6 +959,32 @@ _cttp_ccon_kick_write_cb(uv_write_t* wri_u, c3_i sas_i)
u2_lo_shut(u2_no);
}
/* _cttp_ccon_kick_write()
*/
static void
_cttp_ccon_kick_write_cryp(u2_ccon* coc_u)
{
if (!SSL_is_init_finished(coc_u->ssl.ssl_u)) {
return;
}
while ( coc_u->rub_u ) {
u2_hbod* rub_u = coc_u->rub_u;
c3_i rev_i;
coc_u->rub_u = coc_u->rub_u->nex_u;
if ( 0 == coc_u->rub_u ) {
c3_assert(rub_u == coc_u->bur_u);
coc_u->bur_u = 0;
}
if ( 0 >
(rev_i = SSL_write(coc_u->ssl.ssl_u, rub_u->hun_y, rub_u->len_w)) ) {
_cttp_ccon_cryp_hurr(coc_u, rev_i);
_cttp_ccon_cryp_rout(coc_u);
}
}
}
/* _cttp_ccon_kick_write_buf(): transmit buffer.
*/
static void
@ -986,12 +1042,106 @@ _cttp_ccon_kick_write(u2_ccon* coc_u)
}
}
/* _cttp_ccon_read_cb()
*/
/* _cttp_ccon_cryp_rout: write the SSL buffer to the network
*/
static void
_cttp_ccon_kick_read_cb(uv_stream_t* tcp_u,
ssize_t siz_i,
uv_buf_t buf_u)
_cttp_ccon_cryp_rout(u2_ccon* coc_u)
{
uv_buf_t buf_u;
c3_i bur_i;
{
c3_y* buf_y = malloc(1<<14);
while ( 0 < (bur_i = BIO_read(coc_u->ssl.wio_u, buf_y, 1<<14)) ) {
buf_u = uv_buf_init((c3_c*)buf_y, bur_i);
_cttp_ccon_kick_write_buf(coc_u, buf_u);
}
}
}
/* _cttp_ccon_cryp_hurr: handle SSL errors
*/
static void
_cttp_ccon_cryp_hurr(u2_ccon* coc_u, int rev)
{
u2_sslx* ssl = &coc_u->ssl;
c3_i err = SSL_get_error(ssl->ssl_u, rev);
switch ( err ) {
default:
_cttp_ccon_waste(coc_u, "ssl lost");
break;
case SSL_ERROR_NONE:
case SSL_ERROR_ZERO_RETURN:
break;
case SSL_ERROR_WANT_WRITE: // XX maybe bad
break;
case SSL_ERROR_WANT_READ:
_cttp_ccon_cryp_rout(coc_u);
break;
}
}
/* _cttp_ccon_pars_shov: shove a data buffer into the parser
*/
static void
_cttp_ccon_pars_shov(u2_ccon* coc_u, void* buf_u, ssize_t siz_i)
{
u2_creq* ceq_u = coc_u->ceq_u;
if ( !ceq_u ) { // spurious input
uL(fprintf(uH, "http: response to no request\n"));
}
else {
if ( !ceq_u->res_u ) {
_cttp_cres_start(ceq_u);
}
if ( siz_i != http_parser_execute(ceq_u->res_u->par_u,
&_cttp_settings,
(c3_c*)buf_u,
siz_i) )
{
uL(fprintf(uH, "http: parse error\n"));
_cttp_ccon_fail(coc_u, u2_no);
}
}
}
/* _cttp_ccon_cryp_pull(): pull cleartext data off of the SSL buffer
*/
static void
_cttp_ccon_cryp_pull(u2_ccon* coc_u)
{
if ( SSL_is_init_finished(coc_u->ssl.ssl_u) ) {
static c3_c buf[1<<14];
c3_i ruf;
while ( 0 < (ruf = SSL_read(coc_u->ssl.ssl_u, &buf, sizeof(buf))) ) {
_cttp_ccon_pars_shov(coc_u, &buf, ruf);
}
if ( 0 >= ruf ) {
_cttp_ccon_cryp_hurr(coc_u, ruf);
}
}
else {
// not connected
c3_i r = SSL_connect(coc_u->ssl.ssl_u);
if ( 0 > r ) {
_cttp_ccon_cryp_hurr(coc_u, r);
}
else {
coc_u->sat_e = u2_csat_cryp;
_cttp_ccon_kick(coc_u);
}
}
_cttp_ccon_kick_write_cryp(coc_u);
}
static void
_cttp_ccon_kick_read_cryp_cb(uv_stream_t* tcp_u,
ssize_t siz_i,
uv_buf_t buf_u)
{
u2_ccon *coc_u = _cttp_ccon_wax((uv_tcp_t*)tcp_u);
@ -1009,18 +1159,8 @@ _cttp_ccon_kick_read_cb(uv_stream_t* tcp_u,
uL(fprintf(uH, "http: response to no request\n"));
}
else {
if ( !ceq_u->res_u ) {
_cttp_cres_start(ceq_u);
}
if ( siz_i != http_parser_execute(ceq_u->res_u->par_u,
&_cttp_settings,
(c3_c*)buf_u.base,
siz_i) )
{
uL(fprintf(uH, "http: parse error\n"));
_cttp_ccon_fail(coc_u, u2_no);
}
BIO_write(coc_u->ssl.rio_u, (c3_c*)buf_u.base, siz_i);
_cttp_ccon_cryp_pull(coc_u);
}
}
if ( buf_u.base ) {
@ -1030,14 +1170,78 @@ _cttp_ccon_kick_read_cb(uv_stream_t* tcp_u,
u2_lo_shut(u2_yes);
}
/* _cttp_ccon_kick_read(): start reading.
/* _cttp_ccon_read_clyr_cb()
*/
static void
_cttp_ccon_kick_read(u2_ccon* coc_u)
_cttp_ccon_kick_read_clyr_cb(uv_stream_t* tcp_u,
ssize_t siz_i,
uv_buf_t buf_u)
{
u2_ccon *coc_u = _cttp_ccon_wax((uv_tcp_t*)tcp_u);
u2_lo_open();
{
if ( siz_i < 0 ) {
uv_err_t las_u = uv_last_error(u2L);
_cttp_ccon_fail(coc_u, (UV_EOF == las_u.code) ? u2_no : u2_yes);
}
else {
_cttp_ccon_pars_shov(coc_u, buf_u.base, siz_i);
}
if ( buf_u.base ) {
free(buf_u.base);
}
}
u2_lo_shut(u2_yes);
}
/* _cttp_ccon_kick_read_clyr(): start reading on insecure socket.
*/
static void
_cttp_ccon_kick_read_clyr(u2_ccon* coc_u)
{
uv_read_start((uv_stream_t*)&coc_u->wax_u,
_cttp_alloc,
_cttp_ccon_kick_read_cb);
_cttp_ccon_kick_read_clyr_cb);
}
/* _cttp_ccon_kick_read_cryp(): start reading on secure socket.
*/
static void
_cttp_ccon_kick_read_cryp(u2_ccon* coc_u)
{
uv_read_start((uv_stream_t*)&coc_u->wax_u,
_cttp_alloc,
_cttp_ccon_kick_read_cryp_cb);
}
/* _cttp_ccon_kick_handshake(): start ssl handshake.
*/
static void
_cttp_ccon_kick_handshake(u2_ccon* coc_u)
{
coc_u->ssl.ssl_u = SSL_new(u2S);
c3_assert(coc_u->ssl.ssl_u);
coc_u->ssl.rio_u = BIO_new(BIO_s_mem());
c3_assert(coc_u->ssl.rio_u);
coc_u->ssl.wio_u = BIO_new(BIO_s_mem());
c3_assert(coc_u->ssl.wio_u);
BIO_set_nbio(coc_u->ssl.rio_u, 1);
BIO_set_nbio(coc_u->ssl.wio_u, 1);
SSL_set_bio(coc_u->ssl.ssl_u,
coc_u->ssl.rio_u,
coc_u->ssl.wio_u);
SSL_set_connect_state(coc_u->ssl.ssl_u);
SSL_do_handshake(coc_u->ssl.ssl_u);
coc_u->sat_e = u2_csat_sing;
_cttp_ccon_kick(coc_u);
}
/* _cttp_ccon_kick(): start appropriate I/O on client connection.
@ -1052,20 +1256,38 @@ _cttp_ccon_kick(u2_ccon* coc_u)
default: c3_assert(0);
case u2_csat_dead: {
_cttp_ccon_kick_resolve(coc_u);
_cttp_ccon_kick_resolve(coc_u);
break;
}
case u2_csat_addr: {
case u2_csat_addr: {
_cttp_ccon_kick_connect(coc_u);
break;
}
case u2_csat_live: {
case u2_csat_crop: {
_cttp_ccon_kick_handshake(coc_u);
break;
}
case u2_csat_sing: {
_cttp_ccon_kick_read_cryp(coc_u);
_cttp_ccon_cryp_pull(coc_u);
break;
}
case u2_csat_cryp: {
_cttp_ccon_fill(coc_u);
if ( coc_u->rub_u ) {
_cttp_ccon_kick_write_cryp(coc_u);
}
_cttp_ccon_cryp_pull(coc_u);
break;
}
case u2_csat_clyr: {
_cttp_ccon_fill(coc_u);
if ( coc_u->rub_u ) {
_cttp_ccon_kick_write(coc_u);
}
_cttp_ccon_kick_read(coc_u);
_cttp_ccon_kick_read_clyr(coc_u);
break;
}
}
@ -1090,7 +1312,7 @@ _cttp_ccon_new(u2_bean sec, c3_s por_s, c3_c* hot_c)
if ( u2_Host.ctp_u.coc_u ) {
coc_u->nex_u = u2_Host.ctp_u.coc_u;
u2_Host.ctp_u.coc_u->pre_u = coc_u;
}
}
u2_Host.ctp_u.coc_u = coc_u;
return coc_u;
@ -1136,7 +1358,7 @@ _cttp_creq_new(c3_l num_l, u2_noun hes)
u2_noun pul = u2h(hes);
u2_noun hat = u2h(pul);
u2_noun sec = u2h(hat);
u2_noun pus = u2h(u2t(hat));
u2_noun pus = u2h(u2t(hat));
u2_noun hot = u2t(u2t(hat));
u2_noun moh = u2t(hes);
u2_noun meh = u2h(moh);
@ -1147,7 +1369,8 @@ _cttp_creq_new(c3_l num_l, u2_noun hes)
ceq_u->num_l = num_l;
ceq_u->sec = sec;
ceq_u->por_s = (u2_nul == pus) ? 80 : u2t(pus);
ceq_u->por_s = (u2_nul == pus) ?
( (u2_yes == sec) ? 443 : 80 ) : u2t(pus);
ceq_u->hot_c = _cttp_creq_host(u2k(hot)); // XX duplicate work with url
ceq_u->url_c = _cttp_creq_url(u2k(pul));
@ -1171,7 +1394,7 @@ _cttp_creq_new(c3_l num_l, u2_noun hes)
u2z(hes);
return ceq_u;
}
/* _cttp_ccon_fire_body(): attach body to request buffers.
*/
static void
@ -1188,7 +1411,7 @@ _cttp_ccon_fire_body(u2_ccon* coc_u, u2_hbod *rub_u)
/* _cttp_ccon_fire_str(): attach string to request buffers.
*/
static void
static void
_cttp_ccon_fire_str(u2_ccon* coc_u, const c3_c* str_c)
{
_cttp_ccon_fire_body(coc_u, _cttp_bod(strlen(str_c), (const c3_y*)str_c));
@ -1210,7 +1433,7 @@ _cttp_ccon_fire_heds(u2_ccon* coc_u,
*/
static void
_cttp_ccon_fire(u2_ccon* coc_u, u2_creq* ceq_u)
{
{
switch ( ceq_u->met_e ) {
default: c3_assert(0);
@ -1225,7 +1448,10 @@ _cttp_ccon_fire(u2_ccon* coc_u, u2_creq* ceq_u)
_cttp_ccon_fire_str(coc_u, " HTTP/1.1\r\n");
_cttp_ccon_fire_str(coc_u, "User-Agent: urbit/vere.0.2\r\n");
_cttp_ccon_fire_str(coc_u, "Accept: */*\r\n");
_cttp_ccon_fire_str(coc_u, "Connection: Keep-Alive\r\n");
// XX it's more painful than it's worth to deal with SSL+Keepalive
if ( u2_no == coc_u->sec ) {
_cttp_ccon_fire_str(coc_u, "Connection: Keep-Alive\r\n");
}
_cttp_ccon_fire_body(coc_u, _cttp_bud("Host", ceq_u->hot_c));
_cttp_ccon_fire_heds(coc_u, ceq_u->hed_u);
@ -1254,14 +1480,14 @@ _cttp_ccon_fill(u2_ccon* coc_u)
while ( ceq_u ) {
//
// Fun POST handling. To minimize the likelihood that
// a connection accident will disrupt a POST (it can't
// a connection accident will disrupt a POST (it can't
// be utterly ruled out, because POST sucks), we ensure
// that there is always some request queued above the
// POST. To do this, we always throw in a NOP before XX should
// the POST. But if there is actually something real
// before the POST, we don't need it.
//
// So before a POST, there is always a sequence of
//
// So before a POST, there is always a sequence of
// idempotent requests, or if nothing else NOT, whose
// completion directly triggers the POST. This way,
// it's very unlikely for idling to break a POST.
@ -1299,14 +1525,14 @@ _cttp_ccon_send(u2_ccon* coc_u, u2_creq* ceq_u)
coc_u->qec_u->nex_u = ceq_u;
coc_u->qec_u = ceq_u;
}
}
}
/* u2_cttp_ef_thus(): send %thus effect (outgoing request) to cttp.
*/
void
u2_cttp_ef_thus(c3_l num_l,
u2_noun cuq)
{
{
if ( u2_nul == cuq ) {
uL(fprintf(uH, "thus: cancel?\n"));
}
@ -1320,12 +1546,37 @@ u2_cttp_ef_thus(c3_l num_l,
u2z(cuq);
}
/* u2_cttp_io_init(): initialize http I/O.
/* u2_cttp_io_init(): initialize http client I/O.
*/
void
u2_cttp_io_init()
{
c3_i rad;
c3_y buf[4096];
u2_Host.ctp_u.coc_u = 0;
SSL_library_init();
SSL_load_error_strings();
u2_Host.ssl_u = SSL_CTX_new(TLSv1_client_method());
SSL_CTX_set_options(u2S, SSL_OP_NO_SSLv2);
SSL_CTX_set_verify(u2S, SSL_VERIFY_PEER, NULL);
SSL_CTX_set_default_verify_paths(u2S);
SSL_CTX_set_session_cache_mode(u2S, SSL_SESS_CACHE_OFF);
SSL_CTX_set_cipher_list(u2S, "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:"
"ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:"
"RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS");
// RAND_status, at least on OS X, never returns true.
// 4096 bytes should be enough entropy for anyone, right?
rad = open("/dev/urandom", O_RDONLY);
if ( 4096 != read(rad, &buf, 4096) ) {
perror("rand-seed");
exit(1);
}
RAND_seed(buf, 4096);
close(rad);
}
/* u2_cttp_io_poll(): poll kernel for cttp I/O.
@ -1340,4 +1591,5 @@ u2_cttp_io_poll(void)
void
u2_cttp_io_exit(void)
{
SSL_CTX_free(u2S);
}

View File

@ -163,6 +163,7 @@ _lo_init()
u2_ames_io_init();
u2_term_io_init();
u2_http_io_init();
u2_cttp_io_init();
u2_save_io_init();
u2_batz_io_init();
}
@ -186,6 +187,7 @@ u2_lo_exit(void)
u2_ames_io_exit();
u2_term_io_exit();
u2_http_io_exit();
u2_cttp_io_exit();
u2_save_io_exit();
u2_batz_io_exit();
}

View File

@ -204,7 +204,8 @@ _main_getopt(c3_i argc, c3_c** argv)
static void
u2_ve_usage(c3_i argc, c3_c** argv)
{
fprintf(stderr, "%s: usage: [-v] [-k stage] [-p ames_port] computer\n", argv[0]);
fprintf(stderr, "%s: usage: [-v] [-k stage] [-p ames_port] computer\n",
argv[0]);
exit(1);
}

View File

@ -168,12 +168,18 @@ _raft_promote(u2_raft* raf_u)
else {
c3_i sas_i;
uL(fprintf(uH, "raft: promoting to leader\n"));
if ( 1 == raf_u->pop_w ) {
uL(fprintf(uH, "raft: -> lead\n"));
raf_u->typ_e = u2_raty_lead;
// TODO boot in multiuser mode
u2_sist_boot();
if ( u2_no == u2_Host.ops_u.bat ) {
u2_lo_lead(u2A);
}
}
else {
c3_assert(u2_raty_cand == raf_u->typ_e);
uL(fprintf(uH, "raft: cand -> lead\n"));
raf_u->typ_e = u2_raty_lead;
sas_i = uv_timer_stop(&raf_u->tim_u);
@ -182,14 +188,6 @@ _raft_promote(u2_raft* raf_u)
c3_assert(0 == sas_i);
}
}
/* TODO */
if ( 1 == raf_u->pop_w ) {
u2_sist_boot();
if ( u2_no == u2_Host.ops_u.bat ) {
u2_lo_lead(u2A);
}
}
}
/* _raft_demote(): demote to follower.
@ -197,18 +195,27 @@ _raft_promote(u2_raft* raf_u)
static void
_raft_demote(u2_raft* raf_u)
{
if ( u2_raty_lead == raf_u->typ_e ) {
uL(fprintf(uH, "raft: demoting leader\n"));
/* TODO just start dropping events */
u2_lo_bail(u2A);
u2_raty typ_e = raf_u->typ_e;
raf_u->vog_c = 0;
u2_sist_nil("vote");
raf_u->vot_w = 0;
raf_u->typ_e = u2_raty_foll;
if ( u2_raty_lead == typ_e ) {
c3_i sas_i;
uL(fprintf(uH, "raft: lead -> foll\n"));
sas_i = uv_timer_stop(&raf_u->tim_u);
c3_assert(0 == sas_i);
sas_i = uv_timer_start(&raf_u->tim_u, _raft_time_cb,
_raft_election_rand(), 0);
c3_assert(0 == sas_i);
// TODO dump not-yet-committed events
}
else {
c3_assert(u2_raty_cand == raf_u->typ_e);
uL(fprintf(uH, "raft: demoting to follower\n"));
raf_u->vog_c = 0;
u2_sist_nil("vote");
raf_u->vot_w = 0;
raf_u->typ_e = u2_raty_foll;
c3_assert(u2_raty_cand == typ_e);
uL(fprintf(uH, "raft: cand -> foll\n"));
}
}
@ -346,7 +353,7 @@ _raft_revo_done(u2_rreq* req_u, c3_w suc_w)
u2_raft* raf_u = ron_u->raf_u;
c3_assert(c3__revo == req_u->msg_u->typ_w);
if ( suc_w ) {
if ( suc_w && req_u->msg_u->tem_w == raf_u->tem_w ) {
if ( u2_no == ron_u->nam_u->vog ) {
ron_u->nam_u->vog = u2_yes;
raf_u->vot_w++;
@ -1286,7 +1293,7 @@ _raft_time_cb(uv_timer_t* tim_u, c3_i sas_i)
c3_assert(0);
}
case u2_raty_foll: {
uL(fprintf(uH, "raft: promoting to candidate\n"));
uL(fprintf(uH, "raft: foll -> cand\n"));
raf_u->typ_e = u2_raty_cand;
// continue to cand
}
@ -1306,7 +1313,7 @@ _raft_time_cb(uv_timer_t* tim_u, c3_i sas_i)
static void
_raft_foll_init(u2_raft* raf_u)
{
uL(fprintf(uH, "raft: starting follower\n"));
uL(fprintf(uH, "raft: none -> foll\n"));
raf_u->typ_e = u2_raty_foll;
// Initialize and count peers.

View File

@ -834,7 +834,7 @@ _reck_kick_norm(u2_reck* rec_u, u2_noun pox, u2_noun fav)
case c3__vega:
{
// uL(fprintf(uH, "reset\n"));
u2z(pox); u2z(fav);
u2z(pox); u2z(fav);
// u2_ds_wipe(u2_Wire); // doesn't work

View File

@ -486,6 +486,10 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u)
mpz_t mod_mp;
u2_ufil* fil_u;
if ( ( NULL == strrchr(out_u->d_name, '.')) ) {
continue;
}
{
u2_noun mod = c3_stat_mtime(&buf_u);