rpc_td.c (7c478bd9) | rpc_td.c (61961e0f) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 5 unchanged lines hidden (view full) --- 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 5 unchanged lines hidden (view full) --- 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ |
22 |
|
22/* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 | 23/* 24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 28#pragma ident "%Z%%M% %I% %E% SMI" 29 |
29#if !defined(lint) && defined(SCCSIDS) 30static char sccsid[] = "@(#)rpc_td.c 1.32 89/03/16 Copyr 1988 Sun Micro"; 31#endif 32 | |
33#include "mt.h" 34#include "rpc_mt.h" 35#include <stdio.h> 36#include <rpc/rpc.h> | 30#include "mt.h" 31#include "rpc_mt.h" 32#include <stdio.h> 33#include <rpc/rpc.h> |
37#include <rpc/trace.h> | |
38#include <errno.h> 39#include <tiuser.h> 40#include <string.h> 41#include <stropts.h> 42#include <netinet/tcp.h> 43#include <stdlib.h> 44 45#define MAXOPTSIZE 64 46 47int | 34#include <errno.h> 35#include <tiuser.h> 36#include <string.h> 37#include <stropts.h> 38#include <netinet/tcp.h> 39#include <stdlib.h> 40 41#define MAXOPTSIZE 64 42 43int |
48__td_setnodelay(fd) 49 int fd; | 44__td_setnodelay(int fd) |
50{ 51 int rval = 0; 52 static mutex_t td_opt_lock = DEFAULTMUTEX; 53 static struct t_optmgmt t_optreq, t_optret; 54 int state; 55 56 57 /* VARIABLES PROTECTED BY td_opt_lock: t_optreq, t_optret */ 58 | 45{ 46 int rval = 0; 47 static mutex_t td_opt_lock = DEFAULTMUTEX; 48 static struct t_optmgmt t_optreq, t_optret; 49 int state; 50 51 52 /* VARIABLES PROTECTED BY td_opt_lock: t_optreq, t_optret */ 53 |
59 trace2(TR__td_setnodelay, 0, fd); 60 | |
61 if ((state = t_getstate(fd)) == -1) 62 return (-1); 63 | 54 if ((state = t_getstate(fd)) == -1) 55 return (-1); 56 |
64 mutex_lock(&td_opt_lock); | 57 (void) mutex_lock(&td_opt_lock); |
65 if ((state == T_IDLE) && (t_optreq.flags != T_NEGOTIATE)) { 66 int i = 1; 67 struct opthdr *opt; 68 69 t_optreq.flags = T_NEGOTIATE; 70 t_optreq.opt.maxlen = MAXOPTSIZE; | 58 if ((state == T_IDLE) && (t_optreq.flags != T_NEGOTIATE)) { 59 int i = 1; 60 struct opthdr *opt; 61 62 t_optreq.flags = T_NEGOTIATE; 63 t_optreq.opt.maxlen = MAXOPTSIZE; |
71 t_optreq.opt.buf = (char *)malloc(MAXOPTSIZE); | 64 t_optreq.opt.buf = malloc(MAXOPTSIZE); |
72 if (t_optreq.opt.buf == NULL) { | 65 if (t_optreq.opt.buf == NULL) { |
73 mutex_unlock(&td_opt_lock); | 66 (void) mutex_unlock(&td_opt_lock); |
74 t_errno = TSYSERR; 75 return (-1); 76 } | 67 t_errno = TSYSERR; 68 return (-1); 69 } |
70 /* LINTED pointer cast */ |
|
77 opt = (struct opthdr *)(t_optreq.opt.buf); 78 opt->name = TCP_NODELAY; 79 opt->len = 4; 80 opt->level = IPPROTO_TCP; 81 (void) memcpy((caddr_t)(t_optreq.opt.buf + 82 sizeof (struct opthdr)), &i, sizeof (int)); 83 t_optreq.opt.len = (int)(sizeof (struct opthdr) + 84 sizeof (int)); 85 86 t_optret.opt.maxlen = MAXOPTSIZE; 87 t_optret.opt.len = 0; | 71 opt = (struct opthdr *)(t_optreq.opt.buf); 72 opt->name = TCP_NODELAY; 73 opt->len = 4; 74 opt->level = IPPROTO_TCP; 75 (void) memcpy((caddr_t)(t_optreq.opt.buf + 76 sizeof (struct opthdr)), &i, sizeof (int)); 77 t_optreq.opt.len = (int)(sizeof (struct opthdr) + 78 sizeof (int)); 79 80 t_optret.opt.maxlen = MAXOPTSIZE; 81 t_optret.opt.len = 0; |
88 t_optret.opt.buf = (char *)malloc(MAXOPTSIZE); | 82 t_optret.opt.buf = malloc(MAXOPTSIZE); |
89 if (t_optret.opt.buf == NULL) { | 83 if (t_optret.opt.buf == NULL) { |
90 mutex_unlock(&td_opt_lock); | 84 (void) mutex_unlock(&td_opt_lock); |
91 free(t_optreq.opt.buf); 92 t_errno = TSYSERR; 93 return (-1); 94 } 95 } 96 97 if (state == T_IDLE) 98 rval = t_optmgmt(fd, &t_optreq, &t_optret); 99 | 85 free(t_optreq.opt.buf); 86 t_errno = TSYSERR; 87 return (-1); 88 } 89 } 90 91 if (state == T_IDLE) 92 rval = t_optmgmt(fd, &t_optreq, &t_optret); 93 |
100 mutex_unlock(&td_opt_lock); 101 trace2(TR__td_setnodelay, 1, fd); | 94 (void) mutex_unlock(&td_opt_lock); |
102 return (rval); 103} | 95 return (rval); 96} |