-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tue, 19 Aug 2003 11:08:46 -0700 (PDT)
"Krishna N. Ramachandran" <krishna@cs.ucsb.edu> wrote:
> Hi,
> The sample program given below freezes my 5.1R installation. This
> program is from a bug report - kern/54331. That bug report
> (http://lists.freebsd.org/pipermail/freebsd-bugs/2003-July/001608.html) is
> for the shutdown function call, whereas my machine basically just freezes
> up and reboots on kevent itself. I am also noticing this problem with
> another program i wrote (but too long to include here).
>
> Here is my uname output
> FreeBSD marvin 5.1-RELEASE FreeBSD 5.1-RELEASE #0: Fri Aug 1 16:14:43
> GMT 2003 root@:/usr/obj/usr/src/sys/EC5 i386
>
> thank you in advance,
> Krishna
>
The program exits cleanly on my -STABLE system. But just for my curiosity, why
didn't you call kevent() using "&events" instead of
"events". The function
prototype says that this argument should be a pointer to a kevent structure,
right? Furthermore, you there have an array of 10 such structures. Why is that,
as long as you're only using the first one ?
> Sample Program:
>
> #include <stdio.h>
> #include <sys/types.h>
> #include <sys/event.h>
> #include <unistd.h>
> #include <netdb.h>
> #include <sys/socket.h>
> #include <netinet/in.h>
> #include <netinet/tcp.h>
> #include <string.h>
> #include <stdlib.h>
> #include <time.h>
>
>
> int
> main( int argc, char **argv )
> {
> int queue, sock, i;
> struct sockaddr_in addr;
> struct kevent events[ 10 ];
> struct timespec ktime;
>
> queue = kqueue();
> if( queue == -1 ) {
> perror( "kqueue() failure" );
> exit( 1 );
> }
>
> sock = socket( AF_INET, SOCK_STREAM, 0 );
> /* NOTE: None of this bind() and listen() code is necessary for the
> crash,
> * I'm including it to show the crash in 'normal operation'
> */
> memset( &addr, 0, sizeof( addr ));
> addr.sin_family = AF_INET;
> addr.sin_port = htons( 3456 );
> addr.sin_addr.s_addr = INADDR_ANY;
> if( bind( sock, (struct sockaddr *) &addr, sizeof( addr )) < 0 )
{
> perror( "bind" );
> exit( 1 );
> }
> if( listen( sock, 32 ) < 0 ) {
> perror( "listen" );
> exit( 1 );
> }
>
> /* Must add the socket to the kqueue for it to crash */
> events[ 0 ].ident = sock;
> events[ 0 ].udata = 0;
> events[ 0 ].filter = EVFILT_READ;
> events[ 0 ].flags = EV_ADD;
>
> ktime.tv_sec = 1;
> ktime.tv_nsec = 0;
>
> /* CRASHES HERE ITSELF */
> i = kevent( queue, events, 1, events, 10, &ktime );
> printf( "kevent() returned %d\n", i );
>
> printf( "Closing socket\n" );
>
> /* CRASH!!! Must be a shutdown() call, close() alone won't do it. */
> shutdown( sock, SHUT_RDWR );
> close( sock );
>
> /* Cleanup if we survive */
> printf( "Closing queue\n" );
> close( queue );
>
> return 0;
> }
>
>
>
>
> _______________________________________________
> freebsd-stable@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-stable
> To unsubscribe, send any mail to
"freebsd-stable-unsubscribe@freebsd.org"
>
- --
Vlad Galu
Network & Systems Administrator
Romania Data Systems NOC in Bucharest
Phone: +40 21 30 10 850
http://www.rdsnet.ro
- ---------------------------------------------------------------------------
Privileged/Confidential Information may be contained in this message. If
you are not the addressee indicated in this message (or responsible for
delivery of the message to such a person), you may not copy or deliver this
message to anyone. In such a case, you should destroy this message and
kindly notify the sender by reply e-mail.
- ---------------------------------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)
iD8DBQE/QmoEP5WtpVOrzpcRAobKAJ9hpuciABNu09PRSiouRpEnK3lHZACcCnrv
D+dNYS9UyhaV0aln1HIpiow=MAlu
-----END PGP SIGNATURE-----