mirror of
https://github.com/urbit/shrub.git
synced 2024-12-24 11:24:21 +03:00
khan: remove _khan_close_socket
It was a mistake to call it except from _khan_close_chan, so just inline it at the one call site. Also lets us stop doing our own pointer juggling in _khan_io_exit. While we're at it, flip argument order in _khan_close_chan; superordinate first seems more natural.
This commit is contained in:
parent
18764678b0
commit
6a783cda55
@ -246,32 +246,14 @@ _khan_poke_bail(u3_ovum* egg_u, u3_noun lud)
|
|||||||
u3_ovum_free(egg_u);
|
u3_ovum_free(egg_u);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* _khan_close_chan(): send a close event to arvo and stop reading.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
_khan_close_socket(u3_khan* kan_u, u3_chan* can_u)
|
|
||||||
{
|
|
||||||
u3_noun wir, cad;
|
|
||||||
|
|
||||||
wir = u3nq(c3__khan,
|
|
||||||
u3dc("scot", c3__uv, kan_u->sev_l),
|
|
||||||
u3dc("scot", c3__ud, can_u->coq_l),
|
|
||||||
u3_nul);
|
|
||||||
cad = u3nc(c3__done, u3_nul);
|
|
||||||
u3_auto_peer(
|
|
||||||
u3_auto_plan(&kan_u->car_u,
|
|
||||||
u3_ovum_init(0, c3__k, wir, cad)),
|
|
||||||
0, 0, _khan_poke_bail);
|
|
||||||
u3_newt_moat_stop((u3_moat*)&can_u->mor_u, _khan_moat_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* _khan_close_chan(): close given channel, freeing.
|
/* _khan_close_chan(): close given channel, freeing.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
_khan_close_chan(u3_chan* can_u, u3_shan* san_u)
|
_khan_close_chan(u3_shan* san_u, u3_chan* can_u)
|
||||||
{
|
{
|
||||||
u3_chan* inn_u;
|
u3_khan* kan_u = san_u->kan_u;
|
||||||
u3_cran* ran_u;
|
u3_chan* inn_u;
|
||||||
|
u3_cran* ran_u;
|
||||||
|
|
||||||
// unset chan on all pending requests.
|
// unset chan on all pending requests.
|
||||||
//
|
//
|
||||||
@ -293,7 +275,23 @@ _khan_close_chan(u3_chan* can_u, u3_shan* san_u)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
can_u->mor_u.nex_u = NULL;
|
can_u->mor_u.nex_u = NULL;
|
||||||
_khan_close_socket(san_u->kan_u, can_u);
|
|
||||||
|
// send a close event to arvo and stop reading.
|
||||||
|
//
|
||||||
|
{
|
||||||
|
u3_noun wir, cad;
|
||||||
|
|
||||||
|
wir = u3nq(c3__khan,
|
||||||
|
u3dc("scot", c3__uv, kan_u->sev_l),
|
||||||
|
u3dc("scot", c3__ud, can_u->coq_l),
|
||||||
|
u3_nul);
|
||||||
|
cad = u3nc(c3__done, u3_nul);
|
||||||
|
u3_auto_peer(
|
||||||
|
u3_auto_plan(&kan_u->car_u,
|
||||||
|
u3_ovum_init(0, c3__k, wir, cad)),
|
||||||
|
0, 0, _khan_poke_bail);
|
||||||
|
u3_newt_moat_stop((u3_moat*)&can_u->mor_u, _khan_moat_free);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* _khan_moor_bail(): error callback for u3_moor.
|
/* _khan_moor_bail(): error callback for u3_moor.
|
||||||
@ -307,7 +305,7 @@ _khan_moor_bail(void* ptr_v, ssize_t err_i, const c3_c* err_c)
|
|||||||
if ( err_i != UV_EOF ) {
|
if ( err_i != UV_EOF ) {
|
||||||
u3l_log("khan: moor bail %zd %s\n", err_i, err_c);
|
u3l_log("khan: moor bail %zd %s\n", err_i, err_c);
|
||||||
}
|
}
|
||||||
_khan_close_chan(can_u, san_u);
|
_khan_close_chan(san_u, can_u);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* _khan_peek_cb(): scry result handler.
|
/* _khan_peek_cb(): scry result handler.
|
||||||
@ -656,15 +654,11 @@ _khan_io_exit(u3_auto* car_u)
|
|||||||
|
|
||||||
{
|
{
|
||||||
u3_shan* san_u = kan_u->san_u;
|
u3_shan* san_u = kan_u->san_u;
|
||||||
u3_chan* can_u = san_u ? san_u->can_u : 0;
|
|
||||||
u3_chan* nex_u;
|
|
||||||
|
|
||||||
while ( can_u ) {
|
|
||||||
nex_u = (u3_chan*)can_u->mor_u.nex_u;
|
|
||||||
_khan_close_socket(kan_u, can_u);
|
|
||||||
can_u = nex_u;
|
|
||||||
}
|
|
||||||
if ( san_u ) {
|
if ( san_u ) {
|
||||||
|
while ( san_u->can_u ) {
|
||||||
|
_khan_close_chan(san_u, san_u->can_u);
|
||||||
|
}
|
||||||
uv_close((uv_handle_t*)&san_u->pyp_u, _khan_close_cb);
|
uv_close((uv_handle_t*)&san_u->pyp_u, _khan_close_cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user