Subj : MsgBase first_msg property. To : Digital Man From : deon Date : Sun May 08 2022 22:41:46 Re: MsgBase first_msg property. By: Digital Man to deon on Sat May 07 2022 09:44 am > Currently, I'm not scrubbing any cached values (namely, the contents of the SMB "status header", which includes such things as the last > message number). The first message number must be queried every time the property is read, that value is not cached in any SMB data > structure. > > > I know I can create new variables with those values that I need, but that does seem a waste when I have a variable that has this > > object already (especially if it is updated when I reopen the message base). > > You can look at js_msgbase.c if you're curious how/why it works the way it does and offer suggestions, but right now, it's working as > designed and expected. OK, thanks for the guidance - I see what's going on now. Would you be adverse to something like this: diff --git a/src/sbbs3/js_msgbase.c b/src/sbbs3/js_msgbase.c index d52c7000f..8df7a7d9c 100644 -+- a/src/sbbs3/js_msgbase.c +++ b/src/sbbs3/js_msgbase.c @@ -2967,6 +2967,7 @@ static JSBool js_msgbase_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp) idxrec_t idx; private_t* p; jsrefcount rc; + static uint32_t first_msg = 0; if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) return JS_FALSE; @@ -2997,6 +2998,11 @@ static JSBool js_msgbase_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp) rc=JS_SUSPENDREQUEST(cx); memset(&idx,0,sizeof(idx)); smb_getfirstidx(&(p->smb),&idx); + if (SMB_IS_OPEN(&(p->smb))) { + first_msg = idx.number; + } else { + idx.number = first_msg; + } JS_RESUMEREQUEST(cx, rc); *vp=UINT_TO_JSVAL(idx.number); break; IE: I'm hoping the smb.status header retains it's values when the msgbase is closed (and you can trust those values as correct as at the time of closure). I'm assuming this wont affect anything else, given that you can see if the message base is open (and thus the values are current), if "is_open = true". ....лоеп --- ю Synchronet ю Alterant | an SBBS in Docker on Pi! * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705) .