I have a message reader script for Synchronet that I've written in JavaScript. I've written it so that when the user reads a message that was written to them, it will mark the message as read (by setting the MSG_READ attribute). I'm using the put_msg_header() function to save a header with that attribute, and it seems there are some cases where put_msg_header() fails to save the header. I am checking to ensure the message was written to the user, so I don't think that would be the issue.. I did notice that one area where saving the header is failing is a FidoNet area - I'm not sure if that matters though.
This is how I enable the read attribute (msgHeader is the message header object):
msgHeader.attr |= MSG_READ;
I've tried calling put_msg_header a few different ways, using the message number vs. message offset:
msgbase.put_msg_header(true, msgHeader.offset, msgHeader); msgbase.put_msg_header(false, msgHeader.number, msgHeader); msgbase.put_msg_header(msgHeader.number, msgHeader);
I tried the 3rd one since the first parameter is optional (according to the Synchronet JS docs); I've also seen examples that omit the first parameter and just use the message number. Where it fails, I will exit my message reader and then read message again, and it thinks the message has not been read. I've also seen put_msg_header() return false in that case.
Why might put_msg_header() fail?
Why might put_msg_header() fail?
For a number of reasons. Try printing the msgbase.status and msgbase.error values when whever put_msg_header() fails along with the parameter values you're passing to put_msg_header(), and then share the results here. That'll help to isolate the cause of the error.
Re: MsgBase.put_msg_header() failing to save header
By: Digital Man to Nightfox on Wed Aug 10 2016 01:12:10
Why might put_msg_header() fail?
For a number of reasons. Try printing the msgbase.status and msgbase.error values when whever put_msg_header() fails along with the parameter values you're passing to put_msg_header(), and then share the results here. That'll help to isolate the cause of the error.
This is the status and error message I'm getting when it fails to save the message:
Status: -101
Error: illegal header length increase: 770 (4 blocks) vs 752 (3 blocks)
I get the same error whether I use the message number or offset. The parameters I'm passing to msgbase.put_msg_header are false, 2289, and the header object containing these values:
attr: 0
to: Eric Oulashin
from: robert wolfe
offset: 730
when_written_time: 1465744314
when_written_zone_offset: -300
when_imported_zone_offset: -480
auxattr: 0
netattr: 0
subject: BBS software for Mac OS X
id: <575D6BE8.2289.fido_bbscarni@digitaldistortionbbs.com>
reply_id: <57559F2C.2255.fido_bbscarni@digitaldistortionbbs.com> from_net_addr: 1:116/17
number: 2289
to_net_type: 0
to_agent: 0
from_net_type: 2
from_agent: 0
replyto_net_type: 0
replyto_agent: 0
ftn_msgid: 1:116/17 48cc417b
ftn_reply: 2255.fido_bbscarni@1:340/7 1bbaddfb
ftn_area: BBS_CARNIVAL
ftn_tid: Mystic BBS 1.12 A16
date: Sun, 12 Jun 2016 08:11:54 -0500
when_written_zone: 16684
when_imported_time: 1465740264
when_imported_zone: 16864
thread_id: 2239
thread_next: 0
thread_first: 0
field_list: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Why might put_msg_header() fail?
For a number of reasons. Try printing the msgbase.status and
msgbase.error values when whever put_msg_header() fails along with
the parameter values you're passing to put_msg_header(), and then
share the results here. That'll help to isolate the cause of the
error.
This is the status and error message I'm getting when it fails to save
the message:
Status: -101
Error: illegal header length increase: 770 (4 blocks) vs 752 (3
blocks)
This means that the modified message header requires more storage (blocks in the *.shd file) than what was allocated for the original message header. The read header used 752 bytes (3 256-byte blocks) and the modified header requires 770 bytes (4 256-byte blocks). Setting the "read" attribute should not increase the storage space for a header at all, so something else is changing between when you read the header and when you're attempting to write it.
The problem might lie in this field_list. Can you expand this array in your debug output so we can see what's being added to the header?
Also, the dump of the original header would be useful for comparison purposes.
Re: MsgBase.put_msg_header() failing to save header
By: Digital Man to Nightfox on Wed Aug 10 2016 22:00:02
Why might put_msg_header() fail?
For a number of reasons. Try printing the msgbase.status and
msgbase.error values when whever put_msg_header() fails along with DM>> the parameter values you're passing to put_msg_header(), and then DM>> share the results here. That'll help to isolate the cause of the DM>> error.
This is the status and error message I'm getting when it fails to save
the message:
Status: -101
Error: illegal header length increase: 770 (4 blocks) vs 752 (3
blocks)
This means that the modified message header requires more storage (blocks in the *.shd file) than what was allocated for the original message header. The read header used 752 bytes (3 256-byte blocks) and the modified header requires 770 bytes (4 256-byte blocks). Setting the "read" attribute should not increase the storage space for a header at all, so something else is changing between when you read the header and when you're attempting to write it.
My reader script shouldn't do anything that increases the size of the header before I write it.
If you don't pass 'false' as the 3rd argument to MsgBase.get_msg_header(), some header fields are expanded (e.g. missing message-IDs created) and some header fields which are non-existent or blank in the SMB are created in the JS instance of the header. So like the JS object model doc says: "Pass false for the expand_fields argument (default: true) if you will
be re-writing the header later with put_msg_header()"
Re: MsgBase.put_msg_header() failing to save header
By: Digital Man to Nightfox on Mon Aug 15 2016 21:14:17
If you don't pass 'false' as the 3rd argument to MsgBase.get_msg_header(), some header fields are expanded (e.g. missing message-IDs created) and some header fields which are non-existent or blank in the SMB are created in the JS instance of the header. So like the JS object model doc says: "Pass false for the expand_fields argument (default: true) if you will
be re-writing the header later with put_msg_header()"
Ah, I must have forgotten that note in the JS object model doc. That's what was causing put_msg_header to fail in my reader. Thanks.
Sysop: | fluid |
---|---|
Location: | wickliffe, ohio |
Users: | 5 |
Nodes: | 10 (0 / 10) |
Uptime: | 203:07:58 |
Calls: | 50 |
Files: | 15,838 |
Messages: | 50,766 |