diff options
author | 2003-01-19 23:08:31 +0000 | |
---|---|---|
committer | 2003-01-19 23:08:31 +0000 | |
commit | 660eb4bf232a3b74381d42c1ebaa6a2f38e011b5 (patch) | |
tree | eb466393f325149960023051ad5522a0b2195be0 /regress/lib/libc_r/socket | |
parent | add test to ensure select can be cancelled. (diff) | |
download | wireguard-openbsd-660eb4bf232a3b74381d42c1ebaa6a2f38e011b5.tar.xz wireguard-openbsd-660eb4bf232a3b74381d42c1ebaa6a2f38e011b5.zip |
repository move to libpthread
Diffstat (limited to 'regress/lib/libc_r/socket')
-rw-r--r-- | regress/lib/libc_r/socket/1/Makefile | 6 | ||||
-rw-r--r-- | regress/lib/libc_r/socket/1/socket1.c | 194 | ||||
-rw-r--r-- | regress/lib/libc_r/socket/2/Makefile | 7 | ||||
-rw-r--r-- | regress/lib/libc_r/socket/2/socket2.c | 191 | ||||
-rw-r--r-- | regress/lib/libc_r/socket/2a/Makefile | 19 | ||||
-rw-r--r-- | regress/lib/libc_r/socket/2a/socket2a.c | 119 | ||||
-rw-r--r-- | regress/lib/libc_r/socket/3/Makefile | 6 | ||||
-rw-r--r-- | regress/lib/libc_r/socket/3/socket3.c | 121 | ||||
-rw-r--r-- | regress/lib/libc_r/socket/Makefile | 5 | ||||
-rw-r--r-- | regress/lib/libc_r/socket/Makefile.inc | 3 |
10 files changed, 0 insertions, 671 deletions
diff --git a/regress/lib/libc_r/socket/1/Makefile b/regress/lib/libc_r/socket/1/Makefile deleted file mode 100644 index d523ed1e2a3..00000000000 --- a/regress/lib/libc_r/socket/1/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# $OpenBSD: Makefile,v 1.2 2002/01/03 00:43:48 art Exp $ - -PROG= socket1 -CFLAGS+= -I${.CURDIR}/../../include - -.include <bsd.regress.mk> diff --git a/regress/lib/libc_r/socket/1/socket1.c b/regress/lib/libc_r/socket/1/socket1.c deleted file mode 100644 index b5b0d1e0c42..00000000000 --- a/regress/lib/libc_r/socket/1/socket1.c +++ /dev/null @@ -1,194 +0,0 @@ -/* $OpenBSD: socket1.c,v 1.1.1.1 2001/08/15 14:37:10 fgsch Exp $ */ -/* - * Copyright (c) 1993, 1994, 1995, 1996 by Chris Provenzano and contributors, - * proven@mit.edu All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Chris Provenzano, - * the University of California, Berkeley, and contributors. - * 4. Neither the name of Chris Provenzano, the University, nor the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO, THE REGENTS OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* ==== test_sock_1.c ========================================================= - * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu - * - * Description : Test pthread_create() and pthread_exit() calls. - * - * 1.00 93/08/03 proven - * -Started coding this file. - */ - -#include <pthread.h> -#include <errno.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <unistd.h> -#include "test.h" -#include <sched.h> -#include <string.h> -#include <stdlib.h> - -struct sockaddr_in a_sout; -int success = 0; -pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -pthread_attr_t attr; - -static int counter = 0; - -void * -sock_connect(arg) - void *arg; -{ - char buf[1024]; - int fd; - - /* Ensure sock_read runs first */ - CHECKr(pthread_mutex_lock(&mutex)); - - a_sout.sin_addr.s_addr = htonl(0x7f000001); /* loopback */ - CHECKe(fd = socket(AF_INET, SOCK_STREAM, 0)); - - ASSERT(++counter == 2); - - /* connect to the socket */ - CHECKe(connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout))); - CHECKe(close(fd)); - - CHECKr(pthread_mutex_unlock(&mutex)); - - CHECKe(fd = socket(AF_INET, SOCK_STREAM, 0)); - ASSERT(++counter == 3); - CHECKe(connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout))); - - /* Ensure sock_read runs again */ - pthread_yield(); - sleep(1); - - CHECKr(pthread_mutex_lock(&mutex)); - CHECKe(read(fd, buf, 1024)); - - write(fd, "6", 1); - - ASSERT(++counter == atoi(buf)); - CHECKe(close(fd)); - success++; - CHECKr(pthread_mutex_unlock(&mutex)); - - return(NULL); -} - -void * -sock_write(arg) - void *arg; -{ - int fd = *(int *)arg; - - CHECKe(write(fd, "5", 1)); - return(NULL); -} - -void * -sock_accept(arg) - void *arg; -{ - pthread_t thread; - struct sockaddr a_sin; - int a_sin_size, a_fd, fd; - short port; - char buf[1024]; - - port = 3276; - a_sout.sin_family = AF_INET; - a_sout.sin_port = htons(port); - a_sout.sin_addr.s_addr = INADDR_ANY; - - CHECKe(a_fd = socket(AF_INET, SOCK_STREAM, 0)); - - while (1) { - if(0 == bind(a_fd, (struct sockaddr *) &a_sout, sizeof(a_sout))) - break; - if (errno == EADDRINUSE) { - a_sout.sin_port = htons((++port)); - continue; - } - DIE(errno, "bind"); - } - CHECKe(listen(a_fd, 2)); - - ASSERT(++counter == 1); - - CHECKr(pthread_create(&thread, &attr, sock_connect, - (void *)0xdeadbeaf)); - - a_sin_size = sizeof(a_sin); - CHECKe(fd = accept(a_fd, &a_sin, &a_sin_size)); - CHECKr(pthread_mutex_lock(&mutex)); - CHECKe(close(fd)); - - ASSERT(++counter == 4); - - a_sin_size = sizeof(a_sin); - CHECKe(fd = accept(a_fd, &a_sin, &a_sin_size)); - CHECKr(pthread_mutex_unlock(&mutex)); - - /* Setup a write thread */ - CHECKr(pthread_create(&thread, &attr, sock_write, &fd)); - CHECKe(read(fd, buf, 1024)); - - ASSERT(++counter == atoi(buf)); - - CHECKe(close(fd)); - - CHECKr(pthread_mutex_lock(&mutex)); - success++; - CHECKr(pthread_mutex_unlock(&mutex)); - - CHECKr(pthread_join(thread, NULL)); - return(NULL); -} - -int -main() -{ - pthread_t thread; - - setbuf(stdout, NULL); - setbuf(stderr, NULL); - - CHECKr(pthread_attr_init(&attr)); -#if 0 - CHECKr(pthread_attr_setschedpolicy(&attr, SCHED_FIFO)); -#endif - CHECKr(pthread_create(&thread, &attr, sock_accept, - (void *)0xdeadbeaf)); - - CHECKr(pthread_join(thread, NULL)); - - ASSERT(success == 2); - SUCCEED; -} diff --git a/regress/lib/libc_r/socket/2/Makefile b/regress/lib/libc_r/socket/2/Makefile deleted file mode 100644 index 9fc7ca397ea..00000000000 --- a/regress/lib/libc_r/socket/2/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# $OpenBSD: Makefile,v 1.2 2002/01/03 00:43:48 art Exp $ - -PROG= socket2 -CFLAGS+= -I${.CURDIR}/../../include -CLEANFILES+= socket2a - -.include <bsd.regress.mk> diff --git a/regress/lib/libc_r/socket/2/socket2.c b/regress/lib/libc_r/socket/2/socket2.c deleted file mode 100644 index 7ba7d19df7d..00000000000 --- a/regress/lib/libc_r/socket/2/socket2.c +++ /dev/null @@ -1,191 +0,0 @@ -/* $OpenBSD: socket2.c,v 1.3 2002/01/02 16:15:32 fgsch Exp $ */ -/* - * Copyright (c) 1993, 1994, 1995, 1996 by Chris Provenzano and contributors, - * proven@mit.edu All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Chris Provenzano, - * the University of California, Berkeley, and contributors. - * 4. Neither the name of Chris Provenzano, the University, nor the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO, THE REGENTS OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* ==== test_sock_1.c ========================================================= - * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu - * - * Description : Test pthread_create() and pthread_exit() calls. - * - * 1.00 93/08/03 proven - * -Started coding this file. - */ - -#include <pthread.h> -#include <pthread_np.h> -#include <errno.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <unistd.h> -#include <string.h> -#include <stdlib.h> -#include "test.h" - -struct sockaddr_in a_sout; - -#define MESSAGE5 "This should be message #5" -#define MESSAGE6 "This should be message #6" - -void * -sock_write(arg) - void *arg; -{ - int fd = *(int *)arg; - - SET_NAME("writer"); - CHECKe(write(fd, MESSAGE5, sizeof(MESSAGE5))); - return(NULL); -} - -static pthread_mutex_t waiter_mutex = PTHREAD_MUTEX_INITIALIZER; - -void* -waiter(sig) -{ - int status; - pid_t pid; - - SET_NAME("waiter"); - CHECKr(pthread_mutex_lock(&waiter_mutex)); - printf("waiting for child\n"); - CHECKe(pid = wait(&status)); - ASSERT(WIFEXITED(status)); - ASSERT(WEXITSTATUS(status) == 0); - printf("child exited\n"); - CHECKr(pthread_mutex_unlock(&waiter_mutex)); - return (NULL); -} - -void * -sock_accept(arg) - void *arg; -{ - pthread_t thread, wthread; - struct sockaddr a_sin; - int a_sin_size, a_fd, fd; - u_int16_t port; - char buf[1024]; - pid_t pid; - - port = 3276; - a_sout.sin_family = AF_INET; - a_sout.sin_port = htons(port); - a_sout.sin_addr.s_addr = INADDR_ANY; - - CHECKe(a_fd = socket(AF_INET, SOCK_STREAM, 0)); - - while(1) { - if (bind(a_fd, (struct sockaddr *)&a_sout, sizeof(a_sout))==0) - break; - if (errno == EADDRINUSE) { - a_sout.sin_port = htons((++port)); - continue; - } - DIE(errno, "bind"); - } - - printf("listening on port %d\n", port); - - CHECKe(listen(a_fd, 2)); - - printf("%d: This should be message #1\n", getpid()); - - CHECKr(pthread_mutex_init(&waiter_mutex, NULL)); - CHECKr(pthread_mutex_lock(&waiter_mutex)); - CHECKr(pthread_create(&wthread, NULL, waiter, NULL)); - - sprintf(buf, "%d", port); - - CHECKe(pid = fork()); - switch(pid) { - case 0: - execl("socket2a", "socket2a", "fork okay", buf, (char *)NULL); - DIE(errno, "execl"); - default: - break; - } - CHECKr(pthread_mutex_unlock(&waiter_mutex)); - pthread_yield(); - - a_sin_size = sizeof(a_sin); - CHECKe(fd = accept(a_fd, &a_sin, &a_sin_size)); - CHECKe(close(fd)); - - sleep(1); - - printf("%d: This should be message #4\n", getpid()); - - a_sin_size = sizeof(a_sin); - memset(&a_sin, 0, sizeof(a_sin)); - CHECKe(fd = accept(a_fd, &a_sin, &a_sin_size)); - - /* Setup a write thread */ - - CHECKr(pthread_create(&thread, NULL, sock_write, &fd)); - CHECKe(read(fd, buf, 1024)); - - printf("%d: %s\n", getpid(), buf); /* message 6 */ - - CHECKe(close(fd)); - - if (pthread_mutex_trylock(&waiter_mutex) == EBUSY) { - sleep(2); - if (pthread_mutex_trylock(&waiter_mutex) == EBUSY) { - /* forcibly kill child */ - CHECKe(kill(pid, SIGKILL)); - PANIC("child %d took too long to exit", pid); - } - } - CHECKr(pthread_join(wthread, NULL)); - - return(NULL); -} - -int -main() -{ - pthread_t thread; - - setbuf(stdout, NULL); - setbuf(stderr, NULL); - - CHECKr(pthread_create(&thread, NULL, sock_accept, - (void *)0xdeadbeaf)); - - CHECKr(pthread_join(thread, NULL)); - - SUCCEED; -} diff --git a/regress/lib/libc_r/socket/2a/Makefile b/regress/lib/libc_r/socket/2a/Makefile deleted file mode 100644 index 10dda960750..00000000000 --- a/regress/lib/libc_r/socket/2a/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# $OpenBSD: Makefile,v 1.5 2002/10/09 20:09:15 marc Exp $ - -PROG= socket2a -CFLAGS+= -I${.CURDIR}/../../include - -REGRESS_TARGETS=dummy - -# build prog and link into test 2 directory. Code is used by test 2 -# -dummy: ${PROG} - @cd ${.CURDIR}/../2; \ - if test -d ${__objdir} ; then \ - cd ${__objdir} ; \ - fi; \ - ln -sf ${.OBJDIR}/${PROG} - @echo ${PROG} ready - -.include <bsd.regress.mk> - diff --git a/regress/lib/libc_r/socket/2a/socket2a.c b/regress/lib/libc_r/socket/2a/socket2a.c deleted file mode 100644 index 67b8a07c4fb..00000000000 --- a/regress/lib/libc_r/socket/2a/socket2a.c +++ /dev/null @@ -1,119 +0,0 @@ -/* $OpenBSD: socket2a.c,v 1.3 2002/01/02 16:15:32 fgsch Exp $ */ -/* - * Copyright (c) 1993, 1994, 1995, 1996 by Chris Provenzano and contributors, - * proven@mit.edu All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Chris Provenzano, - * the University of California, Berkeley, and contributors. - * 4. Neither the name of Chris Provenzano, the University, nor the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO, THE REGENTS OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* ==== test_sock_1.c ========================================================= - * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu - * - * Description : Test pthread_create() and pthread_exit() calls. - * - * 1.00 93/08/03 proven - * -Started coding this file. - */ - -#include <pthread.h> -#include <errno.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <unistd.h> -#include <string.h> -#include <stdlib.h> -#include "test.h" - -struct sockaddr_in a_sout; - -#define MESSAGE5 "This should be message #5" -#define MESSAGE6 "This should be message #6" - -void * -sock_connect(arg) - void *arg; -{ - char buf[1024]; - int fd; - short port; - - port = atoi(arg); - a_sout.sin_family = AF_INET; - a_sout.sin_port = htons(port); - a_sout.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* loopback */ - - CHECKe(fd = socket(AF_INET, SOCK_STREAM, 0)); - - printf("%d: This should be message #2\n", getpid()); - - CHECKe(connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout))); - CHECKe(close(fd)); - - CHECKe(fd = socket(AF_INET, SOCK_STREAM, 0)); - - printf("%d: This should be message #3\n", getpid()); - - CHECKe(connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout))); - - /* Ensure sock_read runs again */ - - CHECKe(read(fd, buf, 1024)); - CHECKe(write(fd, MESSAGE6, sizeof(MESSAGE6))); - - printf("%d: %s\n", getpid(), buf); - - CHECKe(close(fd)); - return (NULL); -} - -int -main(argc, argv) - int argc; - char **argv; -{ - pthread_t thread; - - if (argc == 3 && (!strcmp(argv[1], "fork okay"))) { - sleep(1); - setbuf(stdout, NULL); - setbuf(stderr, NULL); - - CHECKr(pthread_create(&thread, NULL, sock_connect, - (void *)argv[2])); - CHECKr(pthread_join(thread, NULL)); - SUCCEED; - } else { - fprintf(stderr, "test_sock_2a needs to be exec'ed from " - "test_sock_2.\n"); - fprintf(stderr, "It is not a stand alone test.\n"); - PANIC("usage"); - } -} diff --git a/regress/lib/libc_r/socket/3/Makefile b/regress/lib/libc_r/socket/3/Makefile deleted file mode 100644 index a958deccdec..00000000000 --- a/regress/lib/libc_r/socket/3/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# $OpenBSD: Makefile,v 1.1 2002/10/10 00:45:20 marc Exp $ - -PROG= socket3 -CFLAGS+= -I${.CURDIR}/../../include - -.include <bsd.regress.mk> diff --git a/regress/lib/libc_r/socket/3/socket3.c b/regress/lib/libc_r/socket/3/socket3.c deleted file mode 100644 index 5f17bf9571c..00000000000 --- a/regress/lib/libc_r/socket/3/socket3.c +++ /dev/null @@ -1,121 +0,0 @@ -/* $OpenBSD: socket3.c,v 1.2 2002/10/12 19:02:51 marc Exp $ */ -/* PUBLIC DOMAIN Oct 2002 <marc@snafu.org> */ - -/* Test blocking/non-blocking mode inheritance on accept */ - -#include <sys/types.h> -#include <sys/socket.h> - -#include <netinet/in.h> - -#include <fcntl.h> -#include <poll.h> -#include <pthread.h> -#include <string.h> -#include <unistd.h> - -#include "test.h" - -/* - * connect to the test port passed in arg, then close the connection - * and return. - */ -void * -sock_connect(void *arg) -{ - struct sockaddr_in sin; - int port; - int sock; - - SET_NAME("connect"); - port = (int)arg; - CHECKe(sock = socket(AF_INET, SOCK_STREAM, 0)); - sin.sin_family = AF_INET; - sin.sin_port = htons(port); - sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - CHECKe(connect(sock, (struct sockaddr *)&sin, sizeof sin)); - CHECKe(close(sock)); - return NULL; -} - -/* - * listen for a connection, accept it using a non-blocking socket, and - * verify that the blocking mode of the socket returned from accept is - * also non-blocking - */ -void * -sock_accept(void *arg) -{ - pthread_t connect_thread; - struct pollfd fds; - struct sockaddr_in sa; - struct sockaddr accept_sa; - int accept_fd; - int accept_sa_size; - int flags; - int listen_fd; - int port; - - SET_NAME("accept"); - - /* listen for a connection */ - - port = 6543; - memset(&sa, 0, sizeof sa); - sa.sin_family = AF_INET; - sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - sa.sin_port = htons(port); - CHECKe(listen_fd = socket(AF_INET, SOCK_STREAM, 0)); - printf("listen_fd = %d\n", listen_fd); - while (1) { - if (bind(listen_fd, (struct sockaddr *)&sa, sizeof(sa)) == 0) - break; - if (errno == EADDRINUSE) { - sa.sin_port = htons(++port); - continue; - } - DIE(errno, "bind"); - } - CHECKe(listen(listen_fd, 2)); - - /* Create another thread to connect to the listening socket. */ - CHECKr(pthread_create(&connect_thread, NULL, sock_connect, - (void*)port)); - - /* - * Use poll to check for a pending connection as the socket - * passed to accept will be in non-blocking mode. - */ - fds.fd = listen_fd; - fds.events = POLLIN; - CHECKe(poll(&fds, 1, INFTIM)); - - /* - * set non blocking mode on the listening socket and close stdin - * (fd 0) so the accept will use fd 0 (needed to test boundary - * condition in the pthread accept code). - */ - flags = fcntl(listen_fd, F_GETFL); - CHECKr(fcntl(listen_fd, F_SETFL, flags |= O_NONBLOCK)); - CHECKe(close(STDIN_FILENO)); - accept_sa_size = sizeof accept_sa; - CHECKe(accept_fd = accept(listen_fd, &accept_sa, &accept_sa_size)); - /* verify O_NONBLOCK on the accepted fd */ - flags = fcntl(accept_fd, F_GETFL); - printf("accept_fd = %d, flags = %x\n", accept_fd, flags); - ASSERT(flags & O_NONBLOCK); - CHECKe(close(listen_fd)); - CHECKe(close(accept_fd)); - CHECKr(pthread_join(connect_thread, NULL)); - return NULL; -} - -int -main(int argc, char * argv[]) -{ - pthread_t accept_thread; - - CHECKr(pthread_create(&accept_thread, NULL, sock_accept, NULL)); - CHECKr(pthread_join(accept_thread, NULL)); - SUCCEED; -} diff --git a/regress/lib/libc_r/socket/Makefile b/regress/lib/libc_r/socket/Makefile deleted file mode 100644 index 5b242a0faaf..00000000000 --- a/regress/lib/libc_r/socket/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $OpenBSD: Makefile,v 1.3 2002/10/10 00:45:20 marc Exp $ - -SUBDIR= 1 2a 2 3 - -.include <bsd.subdir.mk> diff --git a/regress/lib/libc_r/socket/Makefile.inc b/regress/lib/libc_r/socket/Makefile.inc deleted file mode 100644 index dd4abfd15df..00000000000 --- a/regress/lib/libc_r/socket/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.1.1.1 2001/08/15 14:37:10 fgsch Exp $ - -.include "${.CURDIR}/../../Makefile.inc" |