From bddcfefdddfe81756b92ab85233e00263d932cda Mon Sep 17 00:00:00 2001 From: Steve Dee Date: Tue, 14 Jan 2014 18:12:46 -0800 Subject: [PATCH 1/9] Hack to fix the history-eating bug --- v/term.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/v/term.c b/v/term.c index 79c715b0c..8d5666a29 100644 --- a/v/term.c +++ b/v/term.c @@ -403,10 +403,22 @@ _term_it_show_wide(u2_utty* uty_u, c3_w len_w, c3_w* txt_w) u2_noun wad = u2_ci_words(len_w, txt_w); u2_noun txt = u2_do("tuft", wad); c3_c* txt_c = u2_cr_string(txt); + c3_w tsz_w = strlen(txt_c); + u2_noun dim = u2_term_get_blew(1); + u2_atom wid = u2h(dim); + c3_w ful_w; - _term_it_write_str(uty_u, txt_c); + c3_assert(u2_fly_is_cat(wid)); + + // XX hack to fix line eating bug + if ( wid < tsz_w ) { + ful_w = tsz_w / wid; + _term_it_write_str(uty_u, &txt_c[ful_w * wid]); + } + else _term_it_write_str(uty_u, txt_c); free(txt_c); u2z(txt); + u2z(dim); uty_u->tat_u.mir.cus_w += len_w; } @@ -419,11 +431,13 @@ _term_it_show_clear(u2_utty* uty_u) u2_utat* tat_u = &uty_u->tat_u; if ( tat_u->siz.col_l ) { +#if 0 c3_w ful_w = tat_u->mir.cus_w / tat_u->siz.col_l; while ( ful_w-- ) { _term_it_write_txt(uty_u, uty_u->ufo_u.out.cuu1_y); } +#endif _term_it_write_str(uty_u, "\r"); _term_it_write_txt(uty_u, uty_u->ufo_u.out.ed_y); From 712968d37e652aef0103064cf42b35d3c0886466 Mon Sep 17 00:00:00 2001 From: Steve Dee Date: Tue, 14 Jan 2014 18:37:17 -0800 Subject: [PATCH 2/9] Actually fix the history-eating bug --- v/term.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/v/term.c b/v/term.c index 8d5666a29..8446f6642 100644 --- a/v/term.c +++ b/v/term.c @@ -403,22 +403,10 @@ _term_it_show_wide(u2_utty* uty_u, c3_w len_w, c3_w* txt_w) u2_noun wad = u2_ci_words(len_w, txt_w); u2_noun txt = u2_do("tuft", wad); c3_c* txt_c = u2_cr_string(txt); - c3_w tsz_w = strlen(txt_c); - u2_noun dim = u2_term_get_blew(1); - u2_atom wid = u2h(dim); - c3_w ful_w; - c3_assert(u2_fly_is_cat(wid)); - - // XX hack to fix line eating bug - if ( wid < tsz_w ) { - ful_w = tsz_w / wid; - _term_it_write_str(uty_u, &txt_c[ful_w * wid]); - } - else _term_it_write_str(uty_u, txt_c); + _term_it_write_str(uty_u, txt_c); free(txt_c); u2z(txt); - u2z(dim); uty_u->tat_u.mir.cus_w += len_w; } @@ -431,13 +419,18 @@ _term_it_show_clear(u2_utty* uty_u) u2_utat* tat_u = &uty_u->tat_u; if ( tat_u->siz.col_l ) { -#if 0 c3_w ful_w = tat_u->mir.cus_w / tat_u->siz.col_l; + if ( 0 != tat_u->mir.cus_w && + ful_w * tat_u->siz.col_l == tat_u->mir.cus_w ) + { + ful_w--; + } + while ( ful_w-- ) { _term_it_write_txt(uty_u, uty_u->ufo_u.out.cuu1_y); } -#endif + _term_it_write_str(uty_u, "\r"); _term_it_write_txt(uty_u, uty_u->ufo_u.out.ed_y); From 7d19f2ed3367261cbe59b439be6c5be4cff418e1 Mon Sep 17 00:00:00 2001 From: Kingdon Barrett Date: Wed, 15 Jan 2014 12:16:50 -0500 Subject: [PATCH 3/9] -p to demand a listen port in ames --- include/v/vere.h | 1 + v/ames.c | 3 ++- v/main.c | 13 +++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/v/vere.h b/include/v/vere.h index 2c6a8f564..0e4842622 100644 --- a/include/v/vere.h +++ b/include/v/vere.h @@ -390,6 +390,7 @@ c3_c* hom_c; c3_w kno_w; c3_w fuz_w; + c3_s por_s; u2_bean abo; u2_bean gab; u2_bean dem; diff --git a/v/ames.c b/v/ames.c index 2f42df157..7a27b92db 100644 --- a/v/ames.c +++ b/v/ames.c @@ -281,7 +281,7 @@ u2_ames_io_init() srand(time(0)); // don't panic, only for fuzz testing - por_s = 0; + por_s = u2_Host.ops_u.por_s; if ( 0 != u2_Host.ops_u.imp_c ) { u2_noun imp = u2_ci_string(u2_Host.ops_u.imp_c); u2_noun num = u2_dc("slaw", 'p', imp); @@ -311,6 +311,7 @@ u2_ames_io_init() memset(&add_u, 0, sizeof(add_u)); add_u.sin_family = AF_INET; add_u.sin_addr.s_addr = htonl(INADDR_ANY); + //add_u.sin_port = htons(59009); add_u.sin_port = htons(por_s); if ( uv_udp_bind(&sam_u->wax_u, add_u, 0) != 0 ) { diff --git a/v/main.c b/v/main.c index 53899a36d..f58b529c7 100644 --- a/v/main.c +++ b/v/main.c @@ -56,7 +56,7 @@ _main_getopt(c3_i argc, c3_c** argv) u2_Host.ops_u.kno_w = DefaultKernel; u2_Host.ops_u.fuz_w = 0; - while ( (ch_i = getopt(argc, argv, "k:f:h:I:Lcdsagqv")) != -1 ) { + while ( (ch_i = getopt(argc, argv, "k:f:h:I:p:Lcdsagqv")) != -1 ) { switch ( ch_i ) { case 'L': { u2_Host.ops_u.loh = u2_yes; break; } case 'a': { u2_Host.ops_u.abo = u2_yes; break; } @@ -81,6 +81,15 @@ _main_getopt(c3_i argc, c3_c** argv) else return u2_no; break; } + case 'p': { + c3_w arg_w = atol(optarg); + + if ( (arg_w > 0) && (arg_w < 65536) ) { + u2_Host.ops_u.por_s = arg_w; + } + else return u2_no; + break; + } case 'I': { u2_Host.ops_u.imp_c = strdup(optarg); break; @@ -148,7 +157,7 @@ _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] computer\n", argv[0]); + fprintf(stderr, "%s: usage: [-v] [-k stage] [-p ames_port] computer\n", argv[0]); exit(1); } From e4343748555d0dad9a7a5eea7d9153d6389bd044 Mon Sep 17 00:00:00 2001 From: Steve Dee Date: Wed, 15 Jan 2014 11:19:30 -0800 Subject: [PATCH 4/9] Initialize por_s --- v/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/v/main.c b/v/main.c index f58b529c7..3ed476641 100644 --- a/v/main.c +++ b/v/main.c @@ -55,6 +55,7 @@ _main_getopt(c3_i argc, c3_c** argv) u2_Host.ops_u.vno = u2_no; u2_Host.ops_u.kno_w = DefaultKernel; u2_Host.ops_u.fuz_w = 0; + u2_Host.ops_u.por_s = 0; while ( (ch_i = getopt(argc, argv, "k:f:h:I:p:Lcdsagqv")) != -1 ) { switch ( ch_i ) { From 4605ac9c663a2efa6474b9ce66e6c7d3f998dc8a Mon Sep 17 00:00:00 2001 From: Steve Dee Date: Wed, 15 Jan 2014 11:21:50 -0800 Subject: [PATCH 5/9] Fix ames port logic Hey, we have a -p flag. Neat. --- v/ames.c | 5 ++--- v/main.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/v/ames.c b/v/ames.c index 7a27b92db..507aaebd3 100644 --- a/v/ames.c +++ b/v/ames.c @@ -281,7 +281,7 @@ u2_ames_io_init() srand(time(0)); // don't panic, only for fuzz testing - por_s = u2_Host.ops_u.por_s; + por_s = 0; if ( 0 != u2_Host.ops_u.imp_c ) { u2_noun imp = u2_ci_string(u2_Host.ops_u.imp_c); u2_noun num = u2_dc("slaw", 'p', imp); @@ -311,8 +311,7 @@ u2_ames_io_init() memset(&add_u, 0, sizeof(add_u)); add_u.sin_family = AF_INET; add_u.sin_addr.s_addr = htonl(INADDR_ANY); - //add_u.sin_port = htons(59009); - add_u.sin_port = htons(por_s); + add_u.sin_port = htons(u2_Host.ops_u.por_s); if ( uv_udp_bind(&sam_u->wax_u, add_u, 0) != 0 ) { uL(fprintf(uH, "ames: bind: %s\n", diff --git a/v/main.c b/v/main.c index 3ed476641..39dbd9ae0 100644 --- a/v/main.c +++ b/v/main.c @@ -55,7 +55,7 @@ _main_getopt(c3_i argc, c3_c** argv) u2_Host.ops_u.vno = u2_no; u2_Host.ops_u.kno_w = DefaultKernel; u2_Host.ops_u.fuz_w = 0; - u2_Host.ops_u.por_s = 0; + u2_Host.ops_u.por_s = 59009; while ( (ch_i = getopt(argc, argv, "k:f:h:I:p:Lcdsagqv")) != -1 ) { switch ( ch_i ) { From dcf378536399978758dbefb64c828ce5acc18613 Mon Sep 17 00:00:00 2001 From: Steve Dee Date: Wed, 15 Jan 2014 11:59:08 -0800 Subject: [PATCH 6/9] Sort opts, remove unused -s --- v/main.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/v/main.c b/v/main.c index 39dbd9ae0..443c4ed3b 100644 --- a/v/main.c +++ b/v/main.c @@ -57,20 +57,10 @@ _main_getopt(c3_i argc, c3_c** argv) u2_Host.ops_u.fuz_w = 0; u2_Host.ops_u.por_s = 59009; - while ( (ch_i = getopt(argc, argv, "k:f:h:I:p:Lcdsagqv")) != -1 ) { + while ( (ch_i = getopt(argc, argv, "I:f:h:k:p:Lacdgqv")) != -1 ) { switch ( ch_i ) { - case 'L': { u2_Host.ops_u.loh = u2_yes; break; } - case 'a': { u2_Host.ops_u.abo = u2_yes; break; } - case 'c': { u2_Host.ops_u.nuu = u2_yes; break; } - case 'd': { u2_Host.ops_u.dem = u2_yes; break; } - case 'g': { u2_Host.ops_u.gab = u2_yes; break; } - case 'k': { - c3_w arg_w = atoi(optarg); - - if ( (arg_w > 0) && (arg_w < 256) ) { - u2_Host.ops_u.kno_w = arg_w; - } - else return u2_no; + case 'I': { + u2_Host.ops_u.imp_c = strdup(optarg); break; } case 'f': { @@ -82,8 +72,21 @@ _main_getopt(c3_i argc, c3_c** argv) else return u2_no; break; } + case 'h': { + u2_Host.ops_u.hom_c = strdup(optarg); + break; + } + case 'k': { + c3_w arg_w = atoi(optarg); + + if ( (arg_w > 0) && (arg_w < 256) ) { + u2_Host.ops_u.kno_w = arg_w; + } + else return u2_no; + break; + } case 'p': { - c3_w arg_w = atol(optarg); + c3_w arg_w = atoi(optarg); if ( (arg_w > 0) && (arg_w < 65536) ) { u2_Host.ops_u.por_s = arg_w; @@ -91,14 +94,11 @@ _main_getopt(c3_i argc, c3_c** argv) else return u2_no; break; } - case 'I': { - u2_Host.ops_u.imp_c = strdup(optarg); - break; - } - case 'h': { - u2_Host.ops_u.hom_c = strdup(optarg); - break; - } + case 'L': { u2_Host.ops_u.loh = u2_yes; break; } + case 'a': { u2_Host.ops_u.abo = u2_yes; break; } + case 'c': { u2_Host.ops_u.nuu = u2_yes; break; } + case 'd': { u2_Host.ops_u.dem = u2_yes; break; } + case 'g': { u2_Host.ops_u.gab = u2_yes; break; } case 'q': { u2_Host.ops_u.veb = u2_no; break; } case 'v': { u2_Host.ops_u.veb = u2_yes; break; } case 'V': { u2_Host.ops_u.vno = u2_yes; break; } From d7052254fe230ea9d1ac6e2454823c469dbbfbf2 Mon Sep 17 00:00:00 2001 From: Steven Dee Date: Wed, 15 Jan 2014 20:21:04 +0000 Subject: [PATCH 7/9] Fix warning on implicit wait decl --- v/save.c | 1 + 1 file changed, 1 insertion(+) diff --git a/v/save.c b/v/save.c index 82e60091d..980fa1eb0 100644 --- a/v/save.c +++ b/v/save.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include From b8aec6e5d8c6f0522c470f8c566bd4b8037babe4 Mon Sep 17 00:00:00 2001 From: Steve Dee Date: Wed, 15 Jan 2014 13:00:04 -0800 Subject: [PATCH 8/9] Get a random UDP port... --- v/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v/main.c b/v/main.c index 443c4ed3b..3e8fea258 100644 --- a/v/main.c +++ b/v/main.c @@ -55,7 +55,7 @@ _main_getopt(c3_i argc, c3_c** argv) u2_Host.ops_u.vno = u2_no; u2_Host.ops_u.kno_w = DefaultKernel; u2_Host.ops_u.fuz_w = 0; - u2_Host.ops_u.por_s = 59009; + u2_Host.ops_u.por_s = 0; while ( (ch_i = getopt(argc, argv, "I:f:h:k:p:Lacdgqv")) != -1 ) { switch ( ch_i ) { From 97eeb27d4122537116b9f9d05ec6b21a488c6a9d Mon Sep 17 00:00:00 2001 From: Steve Dee Date: Wed, 15 Jan 2014 17:41:30 -0800 Subject: [PATCH 9/9] Batch pier creation --- include/v/vere.h | 6 ++++++ v/loop.c | 13 ++++++++++--- v/main.c | 17 ++++++++++++++--- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/include/v/vere.h b/include/v/vere.h index 0e4842622..e3a5dda72 100644 --- a/include/v/vere.h +++ b/include/v/vere.h @@ -392,6 +392,7 @@ c3_w fuz_w; c3_s por_s; u2_bean abo; + u2_bean bat; u2_bean gab; u2_bean dem; u2_bean loh; @@ -697,6 +698,11 @@ /** Main loop, new style. **/ + /* u2_lo_boot(): restore or create pier. + */ + void + u2_lo_boot(void); + /* u2_lo_loop(): enter main event loop. */ void diff --git a/v/loop.c b/v/loop.c index 1c0aafdb3..b431fa8ef 100644 --- a/v/loop.c +++ b/v/loop.c @@ -1832,10 +1832,10 @@ _lo_slow() #endif } -/* u2_lo_loop(): begin main event loop. +/* u2_lo_boot(): restore or create pier. */ void -u2_lo_loop(u2_reck* rec_u) +u2_lo_boot() { uv_loop_t* lup_u = uv_default_loop(); @@ -1846,6 +1846,13 @@ u2_lo_loop(u2_reck* rec_u) _lo_init(); _lo_boot(); +} + +/* u2_lo_loop(): begin main event loop. +*/ +void +u2_lo_loop(u2_reck* rec_u) +{ { u2_unix_ef_look(); u2_reck_plan(rec_u, u2nt(c3__gold, c3__ames, u2_nul), @@ -1867,7 +1874,7 @@ u2_lo_loop(u2_reck* rec_u) _lo_slow(); #endif - uv_run(lup_u, UV_RUN_DEFAULT); + uv_run(u2L, UV_RUN_DEFAULT); } /* _lo_mark_reck(): mark a reck. diff --git a/v/main.c b/v/main.c index 3e8fea258..d9b3bee5f 100644 --- a/v/main.c +++ b/v/main.c @@ -45,6 +45,7 @@ _main_getopt(c3_i argc, c3_c** argv) c3_i ch_i; u2_Host.ops_u.abo = u2_no; + u2_Host.ops_u.bat = u2_no; u2_Host.ops_u.gab = u2_no; u2_Host.ops_u.loh = u2_no; u2_Host.ops_u.dem = u2_no; @@ -57,7 +58,7 @@ _main_getopt(c3_i argc, c3_c** argv) u2_Host.ops_u.fuz_w = 0; u2_Host.ops_u.por_s = 0; - while ( (ch_i = getopt(argc, argv, "I:f:h:k:p:Lacdgqv")) != -1 ) { + while ( (ch_i = getopt(argc, argv, "I:f:h:k:p:Labcdgqv")) != -1 ) { switch ( ch_i ) { case 'I': { u2_Host.ops_u.imp_c = strdup(optarg); @@ -96,6 +97,7 @@ _main_getopt(c3_i argc, c3_c** argv) } case 'L': { u2_Host.ops_u.loh = u2_yes; break; } case 'a': { u2_Host.ops_u.abo = u2_yes; break; } + case 'b': { u2_Host.ops_u.bat = u2_yes; break; } case 'c': { u2_Host.ops_u.nuu = u2_yes; break; } case 'd': { u2_Host.ops_u.dem = u2_yes; break; } case 'g': { u2_Host.ops_u.gab = u2_yes; break; } @@ -108,6 +110,11 @@ _main_getopt(c3_i argc, c3_c** argv) } } + if ( u2_yes == u2_Host.ops_u.bat ) { + u2_Host.ops_u.dem = u2_yes; + u2_Host.ops_u.nuu = u2_yes; + } + if ( u2_Host.ops_u.hom_c == 0 ) { u2_Host.ops_u.hom_c = getenv("URBIT_HOME"); @@ -228,7 +235,7 @@ main(c3_i argc, } u2_ve_sysopt(); - if ( u2_yes == u2_Host.ops_u.dem ) { + if ( u2_yes == u2_Host.ops_u.dem && u2_no == u2_Host.ops_u.bat ) { printf("Starting daemon\n"); } @@ -347,6 +354,10 @@ main(c3_i argc, u2_lo_grab("main", u2_none); - u2_lo_loop(u2_Host.arv_u); + u2_lo_boot(); + + if ( u2_no == u2_Host.ops_u.bat ) { + u2_lo_loop(u2_Host.arv_u); + } return 0; }