ipxsocket.c (157139) | ipxsocket.c (157146) |
---|---|
1/*- 2 * Copyright (c) 2006 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2006 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/tools/regression/netipx/ipxsocket/ipxsocket.c 157139 2006-03-26 01:58:39Z rwatson $ | 26 * $FreeBSD: head/tools/regression/netipx/ipxsocket/ipxsocket.c 157146 2006-03-26 15:49:35Z rwatson $ |
27 */ 28 29/* 30 * Simple regression test to open and then immediately close various types of | 27 */ 28 29/* 30 * Simple regression test to open and then immediately close various types of |
31 * PF_IPX sockets. | 31 * PF_IPX sockets. Run with various waits in order to make sure that the 32 * various IPX/SPX timers have a chance to walk the pcb lists and hit the 33 * sockets. |
32 */ 33 34#include <sys/types.h> 35#include <sys/socket.h> 36 37#include <netipx/ipx.h> 38 39#include <err.h> 40#include <unistd.h> 41 | 34 */ 35 36#include <sys/types.h> 37#include <sys/socket.h> 38 39#include <netipx/ipx.h> 40 41#include <err.h> 42#include <unistd.h> 43 |
44static int 45maybe_sleep(int sec) 46{ 47 48 if (sec == 0) 49 return (0); 50 return (sleep(sec)); 51} 52 |
|
42int 43main(int argc, char *argv[]) 44{ | 53int 54main(int argc, char *argv[]) 55{ |
45 int s; | 56 int delay, s; |
46 | 57 |
47 s = socket(PF_IPX, SOCK_DGRAM, 0); 48 if (s < 0) 49 warn("socket(PF_IPX, SOCK_DGRAM, 0)"); 50 else 51 close(s); | 58 for (delay = 0; delay < 5; delay++) { 59 s = socket(PF_IPX, SOCK_DGRAM, 0); 60 if (s < 0) 61 warn("socket(PF_IPX, SOCK_DGRAM, 0)"); 62 else { 63 maybe_sleep(delay); 64 close(s); 65 } |
52 | 66 |
53 s = socket(PF_IPX, SOCK_STREAM, 0); 54 if (s < 0) 55 warn("socket(PF_IPX, SOCK_STREAM, 0)"); 56 else 57 close(s); | 67 s = socket(PF_IPX, SOCK_STREAM, 0); 68 if (s < 0) 69 warn("socket(PF_IPX, SOCK_STREAM, 0)"); 70 else { 71 maybe_sleep(delay); 72 close(s); 73 } |
58 | 74 |
59 s = socket(PF_IPX, SOCK_SEQPACKET, 0); 60 if (s < 0) 61 warn("socket(PF_IPX, SOCK_SEQPACKET, 0)"); 62 else 63 close(s); | 75 s = socket(PF_IPX, SOCK_SEQPACKET, 0); 76 if (s < 0) 77 warn("socket(PF_IPX, SOCK_SEQPACKET, 0)"); 78 else { 79 maybe_sleep(delay); 80 close(s); 81 } |
64 | 82 |
65 s = socket(PF_IPX, SOCK_RAW, 0); 66 if (s < 0) 67 warn("socket(PF_IPX, SOCK_RAW, 0)"); 68 else 69 close(s); | 83 s = socket(PF_IPX, SOCK_RAW, 0); 84 if (s < 0) 85 warn("socket(PF_IPX, SOCK_RAW, 0)"); 86 else { 87 maybe_sleep(delay); 88 close(s); 89 } 90 } |
70 71 return (0); 72} | 91 92 return (0); 93} |