74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * CDDL HEADER START
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * The contents of this file are subject to the terms
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * of the Common Development and Distribution License
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * (the "License"). You may not use this file except
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * in compliance with the License.
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * You can obtain a copy of the license at
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * See the License for the specific language governing
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * permissions and limitations under the License.
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * When distributing Covered Code, include this CDDL
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * HEADER in each file and include the License file at
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * usr/src/OPENSOLARIS.LICENSE. If applicable,
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * add the following below this CDDL HEADER, with the
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * fields enclosed by brackets "[]" replaced with your
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * own identifying information: Portions Copyright [yyyy]
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * [name of copyright owner]
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * CDDL HEADER END
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * Use is subject to license terms.
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Boschtypedef struct {
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch " [-a] (measure accept() only)\n"
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch " [-c] (measure connect() only)\n"
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch "notes: measures connect()/accept()\n");
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch (void) setfdlimit(3 * lm_optB * lm_optT + 10);
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch ts->ts_lsns = (int *)malloc(lm_optB * sizeof (int));
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch ts->ts_accs = (int *)malloc(lm_optB * sizeof (int));
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch ts->ts_cons = (int *)malloc(lm_optB * sizeof (int));
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch sizeof (struct sockaddr_in));
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch for (i = 0; i < lm_optB; i++) {
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch ts->ts_lsns[i] = socket(AF_INET, SOCK_STREAM, 0);
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * make accept socket non-blocking so in case of errors
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch * we don't hang
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch if (fcntl(ts->ts_lsns[i], F_SETFL, O_NDELAY) == -1) {
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch if ((host = gethostbyname("localhost")) == NULL) {
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch sizeof (struct sockaddr_in));
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch (void) memcpy(&ts->ts_adds[i].sin_addr.s_addr,
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch host->h_addr_list[0], sizeof (struct in_addr));
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch sizeof (struct sockaddr_in)) == 0) {
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch if (errors += benchmark_initbatch_once(tsd) == -1) {
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch for (i = 0; i < lm_optB; i++) {
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch ts->ts_cons[i] = socket(AF_INET, SOCK_STREAM, 0);
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch if (fcntl(ts->ts_cons[i], F_SETFL, O_NDELAY) == -1) {
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch sizeof (struct sockaddr_in));
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch if ((result == -1) && (errno != EINPROGRESS)) {
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch for (i = 0; i < lm_optB; i++) {
74bc7e646663255703e10e0c0b7242ad7ad52f94Stephan Bosch sizeof (struct sockaddr_in));
2b1933b133f3e3571b32fa56fb823b4a6f9aab57Stephan Bosch for (i = 0; i < lm_optB; i++) {