Skip to content

Commit

Permalink
lick: Shut bug (#563)
Browse files Browse the repository at this point in the history
There is a bug in lick where if a port still has a connection and lick
gets a %shut task the port can still send %soaks to arvo. Arvo poops
when this happens. This bug also shows up when the port is disconnected
and a %disconnect %soak is sent. This PR fixes both of these bugs
  • Loading branch information
pkova authored Dec 4, 2023
2 parents 3d93dc2 + 8240f12 commit 26927c4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/vere/io/lick.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ typedef struct _u3_shan {
typedef struct _u3_port {
c3_c* nam_c; // name of port
c3_o con_o;
c3_o liv_o;
struct _u3_shan* san_u; // server reference
struct _u3_lick* lic_u; // device backpointer
struct _u3_port* nex_u; // next pointer
Expand Down Expand Up @@ -214,7 +215,7 @@ _lick_close_chan(u3_chan* can_u)
}
can_u->mor_u.nex_u = NULL;

if ( NULL == san_u->can_u ) {
if ( NULL == san_u->can_u && c3y == gen_u->liv_o ) {
// send a close event to arvo and stop reading.
//
u3_noun wir, cad, dev, dat, mar;
Expand Down Expand Up @@ -301,6 +302,11 @@ static void
_lick_close_sock(u3_shan* san_u)
{
u3_lick* lic_u = san_u->gen_u->lic_u;

if ( NULL != san_u->can_u ) {
_lick_close_chan(san_u->can_u);
}

c3_w len_w = strlen(lic_u->fod_c) + strlen(san_u->gen_u->nam_c) + 2;
c3_c* paf_c = c3_malloc(len_w);
c3_i wit_i;
Expand Down Expand Up @@ -423,6 +429,7 @@ _lick_ef_shut(u3_lick* lic_u, u3_noun nam)

while ( NULL != cur_u ) {
if ( 0 == strcmp(cur_u->nam_c, nam_c) ) {
cur_u->liv_o = c3n;
_lick_close_sock(cur_u->san_u);
if( las_u == NULL ) {
lic_u->gen_u = cur_u->nex_u;
Expand Down Expand Up @@ -462,6 +469,7 @@ _lick_ef_spin(u3_lick* lic_u, u3_noun nam)
gen_u->san_u->gen_u = gen_u;
gen_u->nam_c = nam_c;
gen_u->con_o = c3n;
gen_u->liv_o = c3y;

_lick_init_sock(gen_u->san_u);
if ( NULL == las_u) {
Expand Down

0 comments on commit 26927c4

Please sign in to comment.