public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] DEBUG: Circular MBUF
@ 2004-06-25 16:38 Kevin S. Martin
  2004-06-25 16:45 ` Gary Thomas
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin S. Martin @ 2004-06-25 16:38 UTC (permalink / raw)
  To: ecos-discuss

I have a application that opens a TCP/IP socket connection and then at 
1Hz writes a bunch of data out on that connection. If "bunch" is  < 1000 
bytes (approx) then everything works fine however when "bunch" > 1000 
(i.e. 2000 or 8000+ bytes) then very quickly I get a series of messages 
on the console like:

DEBUG: Circular MBUF 0x004c7e80!
DEBUG: Circular MBUF 0x004c8500!
DEBUG: Circular MBUF 0x004c7e00!
DEBUG: Circular MBUF 0x004c7c80!

After I get these messages I assume that the network thread is in an 
infinite loop because all threads with lower priority never run again 
and all networking to/from the target stops.

I'm using a  i386 PCMB target with a fairly recent version of eCos 
(April 2004) from the CVS repository. Also, I'm using the FreeBSD 
networking stack. I've tried increasing the amount of memory designated 
for networking buffers but this didn't help.

The code I'm using to open the connection and write is (abbreviated):


    // open TCP socket
    if ( (fdListen = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
    {
      perror("can't open stream socket");
      exit(1);
    }

     // if the packet is "small" don't wait to send it (i.e. send it now)
    if( setsockopt( fdListen, IPPROTO_TCP, TCP_NODELAY, (char *)&yes, 
sizeof(yes) ) == -1 )
    {
      perror("setsockopt:TCP_NODELAY");
      exit(1);
    }

     // lose the pesky "address already in use" error message
    if (setsockopt(fdListen, SOL_SOCKET, SO_REUSEADDR, &yes, 
sizeof(yes)) == -1)
    {
      perror("setsockopt:SO_REUSEADDR");
      exit(1);
    }

    // bind our local address so client can connect to us
    bzero( &serv_addr, sizeof(serv_addr) );
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = INADDR_ANY;
    serv_addr.sin_port = htons(TCP_PORT1_TO_USE);
    if ( (reterr = bind(fdListen, (struct sockaddr *)&serv_addr, 
sizeof(serv_addr))) < 0 )
    {
      perror("can't bind local address");
      exit(1);
    }

     // listen
    if (listen(fdListen, 1) == -1)
    {
      perror("listen");
      exit(1);
    }
    addrlen = sizeof(cli_addr);

     // main loop
    for(;;)
    {
       // handle new connections
      if ((newfd = accept(fdListen, (struct sockaddr *)&cli_addr, 
&addrlen)) == -1)
      {
        perror("accept");
      }
      else
      {
        debug_printf("\nnew connection from %s on socket %d", 
inet_ntoa(cli_addr.sin_addr), newfd);
        debug_printf("\nFeed is ON");
        while ()
         {
             .
             .
             .
             if ((nwritten = write(newfd,buffer,size)) < 0)
             {
                 perror("\nwrite()");
                 break;
              }
             .
             .
             .
            cyg_thread_delay(100);  // delay for one second
         }
        debug_printf("\nFeed is OFF.");
        close(newfd); // bye!
      }
    }

Any ideas?

Thanks,
Kevin

-- 
Kevin S. Martin
Fermi National Accelerator Laboratory
Accelerator Division, EE Support Department
630.840.2983
ksmartin@fnal.gov


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ECOS] DEBUG: Circular MBUF
  2004-06-25 16:38 [ECOS] DEBUG: Circular MBUF Kevin S. Martin
@ 2004-06-25 16:45 ` Gary Thomas
  0 siblings, 0 replies; 2+ messages in thread
From: Gary Thomas @ 2004-06-25 16:45 UTC (permalink / raw)
  To: Kevin S. Martin; +Cc: ecos-discuss

On Fri, 2004-06-25 at 10:38, Kevin S. Martin wrote:
> I have a application that opens a TCP/IP socket connection and then at 
> 1Hz writes a bunch of data out on that connection. If "bunch" is  < 1000 
> bytes (approx) then everything works fine however when "bunch" > 1000 
> (i.e. 2000 or 8000+ bytes) then very quickly I get a series of messages 
> on the console like:
> 
> DEBUG: Circular MBUF 0x004c7e80!
> DEBUG: Circular MBUF 0x004c8500!
> DEBUG: Circular MBUF 0x004c7e00!
> DEBUG: Circular MBUF 0x004c7c80!
> 
> After I get these messages I assume that the network thread is in an 
> infinite loop because all threads with lower priority never run again 
> and all networking to/from the target stops.
> 
> I'm using a  i386 PCMB target with a fairly recent version of eCos 
> (April 2004) from the CVS repository. Also, I'm using the FreeBSD 
> networking stack. I've tried increasing the amount of memory designated 
> for networking buffers but this didn't help.

My guess is that you have stack overflow.  Where is the buffer (that 
contains 'bunch' of data)?  

If this isn't [obviously] the problem try running with asserts enabled
and see if it helps debug the failure.

-- 
Gary Thomas <gary@mlbassoc.com>
MLB Associates


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-06-25 16:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-25 16:38 [ECOS] DEBUG: Circular MBUF Kevin S. Martin
2004-06-25 16:45 ` Gary Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).