comm.c EOF Encountered on read

Posted by Benjamin Peters on Thu 15 Dec 2022 03:49 AM — 11 posts, 27,130 views.

#0
Running SWRFUSS 1.3 that I've modified. Everything compiles clean, runs indefinitely without crash... however I keep seeing the EOF error from bool read_from_descriptor on some connections. Inevitably it seems to end in a disconnect on their end.

The read_from_descriptor call in game_loop:
--------------------------------------------

            d->fcommand = FALSE;

            if( FD_ISSET( d->descriptor, &in_set ) )
            {
               compressEnd(d); // Disable MCCP
               d->idle = 0;
               if( d->character )
                  d->character->timer = 0;
               if( !read_from_descriptor( d ) )
               {
                  FD_CLR( d->descriptor, &out_set );
                  if( d->character && ( d->connected == CON_PLAYING || d->connected == CON_EDITING ) )
                     save_char_obj( d->character );
                  d->outtop = 0;
                  close_socket( d, FALSE );
                  continue;
               }
            }


--------------------------------------------

bool read_from_descriptor( DESCRIPTOR_DATA * d )
{
   int iStart;

   /*
    * Hold horses if pending command already. 
    */
   if( d->incomm[0] != '\0' )
      return TRUE;

   /*
    * Check for overflow. 
    */
   iStart = strlen( d->inbuf );
   if( iStart >= sizeof( d->inbuf ) - 10 )
   {
      sprintf( log_buf, "%s input overflow!", d->host );
      log_string( log_buf );
      write_to_descriptor( d, "\r\n*** PUT A LID ON IT!!! ***\r\n", 0 );
      return FALSE;
   }

   for( ;; )
   {
      int nRead;

//      nRead = read( d->descriptor, d->inbuf + iStart, sizeof( d->inbuf ) - 10 - iStart );

      nRead = recv (d->descriptor, d->inbuf + iStart, sizeof (d->inbuf) - 10 - iStart, 0);
    if( nRead > 0 )
      {
         iStart += nRead;
         if( d->inbuf[iStart - 1] == '\n' || d->inbuf[iStart - 1] == '\r' )
            break;
      }
      else if( nRead == 0 )
      {
         log_string_plus( "EOF encountered on read. Something Amiss", LOG_COMM, sysdata.log_level );
         return FALSE;
      }
      else if( errno == EWOULDBLOCK )
         break;
      else
      {
         perror( "Read_from_descriptor" );
         return FALSE;
      }
   }

   d->inbuf[iStart] = '\0';
   return TRUE;
}

--------------------------------------------------
I figured this might be a client end issue with MCCP so I added compressEnd to a few choice spots within the connection functions and hotboot.

This has solved instances of folks that would be DC'ed on hotboot(the disabling of MCCP in hotboot.c). However I can't seem to solve the new connection DC issue for others.

So I know it's returning a false check because nRead == 0 but why it's coming to that is beyond me.


Anyone else run into this on SWRFUSS or SmaugFUSS?
Amended on Thu 15 Dec 2022 04:15 PM by Benjamin Peters
USA Global Moderator #1
Template:codetag
To make your code more readable please use [code] tags as described here.


[code]
this is code
it has indents
[/code]

this is code
    it has indents
Amended on Thu 15 Dec 2022 03:59 PM by Fiendish
USA Global Moderator #2
Why did you replace read with recv? The behavior on zero-length datagrams is different. A return of 0 from recv does not necessarily mean EOF.
Amended on Thu 15 Dec 2022 04:16 PM by Fiendish
#3
Was the first ham fisted attempt I tried to see if it would make a difference.
Amended on Thu 15 Dec 2022 04:27 PM by Benjamin Peters
USA Global Moderator #4
What is the value of
sizeof( d->inbuf ) - 10 - iStart

when you see the problem?
Amended on Thu 15 Dec 2022 05:05 PM by Fiendish
#5

(gdb) print *d
$1 = {
  next = 0x0,
  prev = 0x146aae0,
  snoop_by = 0x0,
  character = 0x0,
  original = 0x0,
  mccp = 0x146c450,
  can_compress = 0 '\000',
  host = 0x1398650 "grapevine.haus",
  hostip = 0x0,
  port = 42333,
  descriptor = 6,
  connected = -99,
  idle = 0,
  lines = 0,
  scrlen = 24,
  fcommand = 0 '\000',
  inbuf = "\000\376Vmssp-request\n", '\000' <repeats 1007 times>,
  incomm = "\000ssp-request", '\000' <repeats 1011 times>,
  inlast = "mssp-request", '\000' <repeats 1011 times>,
  repeat = 0,
  outbuf = 0x139f6b0 "Illegal name, try another.\r\nName: ",
  outsize = 2000,
  outtop = 0,
  pagebuf = 0x0,
  pagesize = 0,
  pagetop = 0,
  pagepoint = 0x0,
  pagecmd = 0 '\000',
  pagecolor = 0 '\000',
  newstate = 0,
  prevcolor = 7 '\a'
}


Still trying to figure out all the proper commands in gdb
USA Global Moderator #6
That output doesn't answer my question. I've edited the formatting to make the question more clear.
Amended on Thu 15 Dec 2022 05:05 PM by Fiendish
#7

Log: [*****] BUG: comm.c: sizeof(d->inbuf) - 10 - iStart = 1014
Comm: EOF encountered on read. Something Amiss


Sorry, looks like 1014.
Which means very little to me since network function are basically a foreign language for me. Lol
Amended on Thu 15 Dec 2022 05:44 PM by Benjamin Peters
USA Global Moderator #8
It seems like the EOF from read is telling you about the disconnect, not causing it.
#9
Very confusing, the bug log is just something I added to see the buffer values. However still thinking it has to be some sort of client side issue since it doesn't affect all players. Would definitely like to figure it out since any lost players truly is a shame with how niche the hobby is.

Wish I understood the read function better in general, curious as to what it actually means when nRead == 0. Has to be some reason to not just comment it out. ;)


Might just have to test out eliminating MCCP altogether and see if that helps.
Amended on Fri 16 Dec 2022 12:52 AM by Benjamin Peters
Australia Forum Administrator #10
I think Fiendish could assure you that Aardwolf runs with a MUSHclient front-end for a lot of players, and random disconnections (being the client's fault) are not a big problem.

It is more likely to be a server issue.

You could try disabling MCCP just to rule that out as an issue. These days with fast Internet connections it is probably not as useful as it was when people had slow-speed modems.