WIP cleanup and fixes

This commit is contained in:
Steve Dee 2014-02-18 16:48:46 -08:00
parent e0e37cc569
commit a957cd649e
5 changed files with 32 additions and 28 deletions

View File

@ -701,8 +701,8 @@
# define c3__ord c3_s3('o','r','d')
# define c3__orth c3_s4('o','r','t','h')
# define c3__outd c3_s4('o','u','t','d')
# define c3__ov c3_s2('o','v')
# define c3__over c3_s4('o','v','e','r')
# define c3__ovum c3_s4('o','v','u','m')
# define c3__pair c3_s4('p','a','i','r')
# define c3__palm c3_s4('p','a','l','m')
# define c3__palq c3_s4('p','a','l','q')

View File

@ -1053,8 +1053,10 @@
**
** XX Synchronous.
**
** typ_w is a mote describing the entry type: %ovum for Arvo
** logs, %raft for Raft events.
** typ_w is a mote describing the entry type: %ov for Arvo
** logs, %ra for Raft events.
**
** Returns the entry's sequence number.
*/
void
c3_w
u2_sist_pack(u2_reck* rec_u, c3_w typ_w, c3_w* bob_w, c3_w len_w);

View File

@ -11,14 +11,6 @@
#include "all.h"
#include "v/vere.h"
/* _raft_election_rand(): pseudorandom component of election timeout.
*/
static c3_w
_raft_election_rand()
{
return ((float) rand() / RAND_MAX) * 150;
}
/* _raft_readname(): parse a raft host:port peer name.
*/
static u2_bean
@ -71,6 +63,14 @@ u2_raft_readopt(u2_ropt* rop_u, const c3_c* arg_c)
return _raft_readname(rop_u, arg_c, strlen(arg_c));
}
/* _raft_election_rand(): pseudorandom component of election timeout.
*/
static c3_w
_raft_election_rand()
{
return ((float) rand() / RAND_MAX) * 150;
}
static void
_raft_listen_cb(uv_stream_t* wax_u, c3_i sas_i)
{
@ -160,7 +160,7 @@ _raft_sure(u2_reck* rec_u, u2_noun ovo, u2_noun vir, u2_noun cor)
u2_mug(rec_u->roc);
if ( u2_no == u2_sing(cor, rec_u->roc) ) {
rec_u->roe = u2nc(u2nc(ovo, u2_nul), rec_u->roe);
rec_u->roe = u2nc(u2nc(u2_nul, ovo), rec_u->roe);
u2z(rec_u->roc);
rec_u->roc = cor;
@ -317,18 +317,17 @@ _raft_comm(u2_reck* rec_u, c3_w bid_w)
u2_lo_shut(u2_no);
}
c3_w
u2_raft_push(u2_raft* raf_u, c3_w* bob_w, c3_w len_w)
static c3_w
_raft_push(u2_raft* raf_u, c3_w* bob_w, c3_w len_w)
{
static c3_w bid_w = 0;
if ( 0 != bob_w ) {
c3_assert(0 < len_w);
u2_sist_pack(u2A, c3__ovum, bob_w, len_w);
bid_w = u2_sist_pack(u2A, c3__ov, bob_w, len_w);
}
else c3_assert(0 == len_w);
bid_w++;
return bid_w;
}
@ -392,8 +391,7 @@ u2_raft_work(u2_reck* rec_u)
c3_assert(rec_u->vir == u2_nul);
while ( u2_nul != ova ) {
rec_u->ent_w++;
_raft_punk(rec_u, u2k(u2h(ova)));
_raft_punk(rec_u, u2k(u2t(u2h(ova))));
nex = u2k(u2t(ova));
u2z(ova); ova = nex;
}
@ -439,11 +437,11 @@ u2_raft_work(u2_reck* rec_u)
u2_cr_words(0, len_w, bob_w, ron);
u2z(ron);
bid_w = u2_raft_push(u2R, bob_w, len_w);
bid_w = _raft_push(u2R, bob_w, len_w);
egg_u->ent_w = bid_w;
}
else {
egg_u->ent_w = u2_raft_push(u2R, 0, 0);
else { // XX
egg_u->ent_w = _raft_push(u2R, 0, 0);
}
if ( 0 == rec_u->ova.geg_u ) {

View File

@ -974,7 +974,7 @@ u2_reck_plan(u2_reck* rec_u,
u2_noun fav)
{
u2_noun egg = u2nc(pax, fav);
rec_u->roe = u2nc(egg, rec_u->roe);
rec_u->roe = u2nc(u2nc(u2_nul, egg), rec_u->roe);
}
/* u2_reck_plow(): queue multiple ova (external).

View File

@ -22,22 +22,24 @@
/* u2_sist_pack(): write a blob to disk, retaining.
*/
void
u2_sist_pack(u2_reck* rec_u, u2_atom typ, c3_w* bob_w, c3_w len_w)
c3_w
u2_sist_pack(u2_reck* rec_u, c3_w typ_w, c3_w* bob_w, c3_w len_w)
{
u2_ulog* lug_u = &u2R->lug_u;
c3_d tar_d;
u2_ular lar_u;
rec_u->ent_w++;
tar_d = lug_u->len_d + len_w;
lar_u.syn_w = u2_cr_mug((c3_w)tar_d);
lar_u.mug_w = u2_cr_mug_both(u2_cr_mug_words(bob_w, len_w),
u2_cr_mug(typ));
u2_cr_mug(typ_w));
//lar_u.tem_w = u2R->tem_w; // TODO uncomment
lar_u.tem_w = 0;
lar_u.typ_w = typ;
lar_u.ent_w = rec_u->ent_w; // XX fix this
lar_u.typ_w = typ_w;
lar_u.ent_w = rec_u->ent_w;
lar_u.len_w = len_w;
if ( -1 == lseek64(lug_u->fid_i, 4ULL * tar_d, SEEK_SET) ) {
@ -69,6 +71,8 @@ u2_sist_pack(u2_reck* rec_u, u2_atom typ, c3_w* bob_w, c3_w len_w)
c3_assert(0);
}
lug_u->len_d += (c3_d)(lar_u.len_w + c3_wiseof(lar_u));
return rec_u->ent_w;
}
/* _sist_suck(): past failure.