Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Erwin's global board snippet error
|
Erwin's global board snippet error
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Frobozz
(75 posts) Bio
|
| Date
| Sun 02 Jan 2005 03:25 PM (UTC) |
| Message
| Alright!
I have had this code up and running for a while now, and I noticed something... And of course I do not know how to fix it!
Under Erwin's Board system there appears to be a point where no new notes can be -saved- on any of the boards over a reboot and Im not sure why this happens. But I did look through my log file and found these two entries:
Sat Jan 1 17:41:38 2005 :: Loading Global Boards
Sat Jan 1 17:41:38 2005 :: [*****] BUG: fread_string: string too long
Sat Jan 1 17:41:38 2005 :: [*****] BUG: Load_notes: bad key word.
I grepped for these phrases and found:
from db.c
if ( ln >= (MAX_STRING_LENGTH - 1) )
{
bug( "fread_string: string too long" );
*plast = '\0';
return STRALLOC( buf );
}
and from board.c in the function load_board
void load_board( GLOBAL_BOARD_DATA *board )
{
FILE *fp, *fp_archive;
NOTE_DATA *last_note;
char filename[200];
sprintf (filename, "%s%s", NOTE_DIR, board->short_name);
fp = fopen (filename, "r");
/* Silently return */
if (!fp)
return;
/* Start note fetching. copy of db.c: load_notes() */
last_note = NULL;
for ( ; ; )
{
NOTE_DATA *pnote;
char letter;
do
{
letter = getc( fp );
if ( feof(fp) )
{
fclose( fp );
return;
}
}
while ( isspace(letter) );
ungetc( letter, fp );
CREATE( pnote, NOTE_DATA, sizeof( *pnote ) );
if ( str_cmp( fread_word( fp ), "sender" ) )
break;
pnote->sender = fread_string( fp );
if ( str_cmp( fread_word( fp ), "date" ) )
break;
pnote->date = fread_string( fp );
if ( str_cmp( fread_word( fp ), "stamp" ) )
break;
pnote->date_stamp = fread_number( fp );
if ( str_cmp( fread_word( fp ), "expire" ) )
break;
pnote->expire = fread_number( fp );
if ( str_cmp( fread_word( fp ), "to" ) )
break;
pnote->to_list = fread_string( fp );
if ( str_cmp( fread_word( fp ), "subject" ) )
break;
pnote->subject = fread_string( fp );
if ( str_cmp( fread_word( fp ), "text" ) )
break;
pnote->text = fread_string( fp );
pnote->next = NULL; /* jic */
/* Should this note be archived right now ? */
if (pnote->expire < current_time)
{
char archive_name[200];
sprintf (archive_name, "%s%s.old", NOTE_DIR, board->short_name);
fp_archive = fopen (archive_name, "a");
if (!fp_archive)
bug ("Could not open archive boards for writing",0);
else
{
append_note (fp_archive, pnote);
fclose (fp_archive); /* it might be more efficient to close this later */
}
free_global_note (pnote);
board->changed = TRUE;
continue;
}
if ( board->note_first == NULL )
board->note_first = pnote;
else
last_note->next = pnote;
}
bug( "Load_notes: bad key word.", 0 );
return; /* just return */
}
Now being totally stumped on this, Im not sure why the board system will only load up 8 total posts but save all the rest into the ../notes directory.
Any ideas? | | Top |
|
| Posted by
| Frobozz
(75 posts) Bio
|
| Date
| Reply #1 on Sun 02 Jan 2005 04:49 PM (UTC) |
| Message
| Hmm.
I seemed to get around this problem, temporarily, by increasing MAX_STRING_LENGTH -1 to (MAX_..... *2)-1
But is there a better way to do this? | | Top |
|
| Posted by
| Zeno
USA (2,871 posts) Bio
|
| Date
| Reply #2 on Sun 02 Jan 2005 05:38 PM (UTC) |
| Message
| | You have the "notes" dir made in the smaug dir right? |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | | Top |
|
| Posted by
| Frobozz
(75 posts) Bio
|
| Date
| Reply #3 on Sun 02 Jan 2005 06:09 PM (UTC) |
| Message
| Definately do, yep!
That's the confusing part, all of the notes end up saved there but it looks like when they pass MAX_STRING_LENGTH those notes dont get loaded to the game, they stay alone in the ../smaug/notes directory.
For instance before I changed to MAX_STRING_LENGTH * 2 this was the output:
Name Unread Total Description
======== ====== ===== ===========
General [ 0] [ 3] General discussion
Ideas [ 0] [ 3] Suggestion for improvement
Announce [ 0] [ 2] Announcements from Immortals
Bugs [ 0] [ 0] Typos, bugs, errors
Personal [ 0] [ 0] Personal messages
But after the change:
Name Unread Total Description
======== ====== ===== ===========
General [ 0] [ 11] General discussion
Ideas [ 0] [ 7] Suggestion for improvement
Announce [ 0] [ 4] Announcements from Immortals
Bugs [ 0] [ 0] Typos, bugs, errors
Personal [ 0] [ 0] Personal messages
Thus my confusion! | | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #4 on Sun 02 Jan 2005 07:28 PM (UTC) |
| Message
|
Quote: MAX_STRING_LENGTH -1 to (MAX_..... *2)-1 You really don't want to do this... it's a safety feature to make sure that the string is of the right length, and if you read more than the buffer can hold you'll wreak havok on your memory.
What might be happening is that you have notes that are simply too long. You can either increase the max length of a note, but that's a pain, or you can more simply break the notes into multiple parts yourself. Is there any chance this is what's happening? Max string length is 2048 characters I believe. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
| Posted by
| Frobozz
(75 posts) Bio
|
| Date
| Reply #5 on Sun 02 Jan 2005 07:50 PM (UTC) |
| Message
| Hmm.
That's a good suggestion but it seems that the length of the note really doesn't matter. Posts with messages as simple as "test" or "testing" were being "unloaded" after a reboot.
Thus my confusion! | | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #6 on Sun 02 Jan 2005 08:28 PM (UTC) |
| Message
| | I think that anything that comes after a bad note is ignored... the server might stop reading the file after it finds a bad keyword. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
| Posted by
| Samson
USA (683 posts) Bio
|
| Date
| Reply #7 on Mon 03 Jan 2005 03:33 AM (UTC) |
| Message
| Yep, you've more or less already figured it out. You have a note with a message that's too long. So fread_string gave up trying to look for more. Problem is, the file pointer isn't advanced to where the tilde at the end of that string should be, and when the note reader picks up where it last left off, it didn't find what it though was supposed to be there. So the file stops reading.
MAX_STRING_LENGTH is 4096 in unmodified Smaug, so if you have a message longer than 4KB, that would do it. Should be fairly easy to spot something that big in the notes. | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
22,437 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top