From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <994ac677ae295f63e42e22b7cbbe5a70@gmx.de> To: 9fans@9fans.net Date: Sat, 30 Aug 2008 20:09:49 +0200 From: cinap_lenrek@gmx.de In-Reply-To: <003239afe18d1b7672c1f71363ec9e64@coraid.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] notes and traps Topicbox-Message-UUID: 0b9aad20-ead4-11e9-9d60-3106f5b1d025 > i'm not convinced that you've explained why this change is > correct or why it could solve the problem. after all, the > NNOTED array is only 5 entries long. what if one gets 5 > user notes before the system note? > do you kill the process (isn't this how it works now?), > make notes unreliable or block the sender? none of these > options seems like an improvement to me. Hm, i think here would be a better way to handle it without losing user notes while make sure internal system notes get posted (and handled) in any case. What if we change postnote to: int postnote(Proc *p, int dolock, char *n, int flag) { int x, s, ret; Rendez *r; Proc *d, **l; if(dolock) qlock(&p->debug); if(flag != NUser){ x = 0; if(p->nnote < NNOTE){ if(p->nnote) memmove(&p->note[0], &p->note[1], p->nnote * sizeof(p->note[0])); p->nnote++; } } else { x = -1; if(p->nnote+1 < NNOTE) x = p->nnote++; } ret = 0; if(x >= 0) { strcpy(p->note[x].msg, n); p->note[x].flag = flag; ret = 1; } p->notepending = 1; if(dolock) qunlock(&p->debug); ... In that case, if a external note is posted, we make sure here is always room for one further internal note in the array. (see the p->nnote+1 < NNOTE) On arrival of a internal note, we move the rest down the array and put our note in the first entry. So the following conditions hold true: - internal notes get *always* posted (so the process gets terminated if its not handled or while in the note handler) - we do not drop external notes on internal note arrival and the sender can detect if posting the note failed. - internal notes get not queued after external notes so they will be handled by the next call to notify() and not tick notify() to think that while processing a previous user note, that this caused an internal note and kill the process before it has a chance to see the that note. Anything wrong here? -- cinap