TCP is still broken

2003-02-26 Thread Tim Robbins
This program, based on one from the Apache 2 configure script, still causes
-current to lock up solid despite the recent bug fixes to the tcptw code.
Explicitly closing connected_s before returning from main() seems to avoid
the problem.

#include stdio.h
#include unistd.h
#include sys/types.h
#include sys/socket.h
#include netinet/in.h
#include netinet/tcp.h
int main(void) {
int listen_s, connected_s, client_s;
int listen_port, rc;
struct sockaddr_in sa;
socklen_t sa_len;
socklen_t option_len;
int option;

listen_s = socket(AF_INET, SOCK_STREAM, 0);
if (listen_s  0) {
perror(socket);
exit(1);
}
memset(sa, 0, sizeof sa);
sa.sin_family = AF_INET;
/* leave port 0 to get ephemeral */
rc = bind(listen_s, (struct sockaddr *)sa, sizeof sa);
if (rc  0) {
perror(bind for ephemeral port);
exit(1);
}
/* find ephemeral port */
sa_len = sizeof(sa);
rc = getsockname(listen_s, (struct sockaddr *)sa, sa_len);
if (rc  0) {
perror(getsockname);
exit(1);
}
listen_port = sa.sin_port;
rc = listen(listen_s, 5);
if (rc  0) {
perror(listen);
exit(1);
}
client_s = socket(AF_INET, SOCK_STREAM, 0);
if (client_s  0) {
perror(socket);
exit(1);
}
memset(sa, 0, sizeof sa);
sa.sin_family = AF_INET;
sa.sin_port   = listen_port;
/* leave sin_addr all zeros to use loopback */
rc = connect(client_s, (struct sockaddr *)sa, sizeof sa);
if (rc  0) {
perror(connect);
exit(1);
}
sa_len = sizeof sa;
connected_s = accept(listen_s, (struct sockaddr *)sa, sa_len);
if (connected_s  0) {
perror(accept);
exit(1);
}
return 0;
}

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message


Re: TCP is still broken

2003-02-26 Thread Jonathan Lemon
In article local.mail.freebsd-current/[EMAIL PROTECTED] you write:
This program, based on one from the Apache 2 configure script, still causes
-current to lock up solid despite the recent bug fixes to the tcptw code.
Explicitly closing connected_s before returning from main() seems to avoid
the problem.

Thanks for the test case.  I've just committed a fix for this to -current.
-- 
Jonathan

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message