This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: problems with MBUFs (TCP/IP stack)
- TO: "Hugo 'NOx' Tyson" <hmt at cygnus dot co dot ukx>
- Subject: RE: [ECOS] problems with MBUFs (TCP/IP stack)
- From: "Marco Monguzzi" <marco at sitek dot it>
- Date: Tue, 11 Jul 2000 17:28:31 +0200
- CC: <ecos-discuss at sourceware dot cygnus dot com>
> I've seen the out-of-mbufs issue in a variant of the ping test that I'm
> playing with, but as usual, it was cured by remembering to close
> the socket
> when I'm done with it. That cures it anyway, it seems.
>
> Maybe it depends on what you do with the socket even if you do close it?
>
> Just a data point.
Hello.
Even the below (dummy) client works (running on target server_test.c that
shows the MBUFs counter we got no problems). The problem (the MBUFs not
freed
that generate the panic/warning) occours using the telnet client via shell
(or with this code if you comment the line "close(sockfd);").
In other words, when only the server closes the connection.
We observed the same path running the Web server. The connection is
established,
the web server honours the HTTP request and it closes (two steps: shutdown()
in
SHUT_WR mode + close() ). But, at the end, the MBUF counter shows that one
MBUF has
not been freed for each request served.
Regards,
Marco
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <string.h>
#define SERVER_HOST_ADDR "192.168.0.116" //target IP
#define SERVER_TCP_PORT 7734
#define NTIMES 100
int main(int argc, char* argv[]){
int sockfd, len, ii;
struct sockaddr_in serv_addr;
char out[256];
char in[256];
if(argc != 2){
printf("usage: client_test \"string to be sent\"\n");
exit(-1);
}
strcpy(out, argv[1]);
bzero((char*) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr(SERVER_HOST_ADDR);
serv_addr.sin_port = htons(SERVER_TCP_PORT);
for(ii=0; ii<NTIMES; ii++){
if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
printf("cannot open stream socket!\n");
exit(-1);
}
if ( connect(sockfd, (struct sockaddr_in *) &serv_addr,
sizeof(serv_addr)) < 0) {
printf("cannot connect to the server!\n");
exit(-1);
}
len = read(sockfd, in, sizeof(in));
in[len-1] = '\0';
printf("connected! read %d bytes from target:%s\n", len, in);
write(sockfd, out, sizeof(out));
close(sockfd);
}
exit(0);
}