version 1.181, 2009/01/14 23:28:23 |
version 1.188, 2009/04/04 10:12:51 |
|
|
/* $NetBSD$ */ |
/* $NetBSD$ */ |
|
|
/*- |
/*- |
* Copyright (c) 2002, 2007, 2008 The NetBSD Foundation, Inc. |
* Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. |
* All rights reserved. |
* All rights reserved. |
* |
* |
* This code is derived from software contributed to The NetBSD Foundation |
* This code is derived from software contributed to The NetBSD Foundation |
* by Jason R. Thorpe of Wasabi Systems, Inc. |
* by Jason R. Thorpe of Wasabi Systems, Inc, and by Andrew Doran. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* modification, are permitted provided that the following conditions |
Line 95 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 95 __KERNEL_RCSID(0, "$NetBSD$"); |
|
|
|
#ifdef COMPAT_50 |
#ifdef COMPAT_50 |
#include <compat/sys/time.h> |
#include <compat/sys/time.h> |
#define SO_OSNDTIMEO 0x1005 |
#include <compat/sys/socket.h> |
#define SO_ORCVTIMEO 0x1006 |
|
#endif |
#endif |
|
|
#include <uvm/uvm.h> |
#include <uvm/uvm.h> |
Line 681 soclose(struct socket *so) |
|
Line 680 soclose(struct socket *so) |
|
if ((so->so_state & SS_ISDISCONNECTING) && so->so_nbio) |
if ((so->so_state & SS_ISDISCONNECTING) && so->so_nbio) |
goto drop; |
goto drop; |
while (so->so_state & SS_ISCONNECTED) { |
while (so->so_state & SS_ISCONNECTED) { |
error = sowait(so, so->so_linger * hz); |
error = sowait(so, true, so->so_linger * hz); |
if (error) |
if (error) |
break; |
break; |
} |
} |
Line 1548 soshutdown(struct socket *so, int how) |
|
Line 1547 soshutdown(struct socket *so, int how) |
|
return error; |
return error; |
} |
} |
|
|
|
int |
|
sodrain(struct socket *so) |
|
{ |
|
int error; |
|
|
|
solock(so); |
|
so->so_state |= SS_ISDRAINING; |
|
cv_broadcast(&so->so_cv); |
|
error = soshutdown(so, SHUT_RDWR); |
|
sounlock(so); |
|
|
|
return error; |
|
} |
|
|
void |
void |
sorflush(struct socket *so) |
sorflush(struct socket *so) |
{ |
{ |
Line 1583 sorflush(struct socket *so) |
|
Line 1596 sorflush(struct socket *so) |
|
static int |
static int |
sosetopt1(struct socket *so, const struct sockopt *sopt) |
sosetopt1(struct socket *so, const struct sockopt *sopt) |
{ |
{ |
int error = 0, optval, opt; |
int error = EINVAL, optval, opt; |
struct linger l; |
struct linger l; |
struct timeval tv; |
struct timeval tv; |
|
|
Line 1620 sosetopt1(struct socket *so, const struc |
|
Line 1633 sosetopt1(struct socket *so, const struc |
|
case SO_REUSEPORT: |
case SO_REUSEPORT: |
case SO_OOBINLINE: |
case SO_OOBINLINE: |
case SO_TIMESTAMP: |
case SO_TIMESTAMP: |
|
#ifdef SO_OTIMESTAMP |
|
case SO_OTIMESTAMP: |
|
#endif |
error = sockopt_getint(sopt, &optval); |
error = sockopt_getint(sopt, &optval); |
solock(so); |
solock(so); |
if (error) |
if (error) |
Line 1690 sosetopt1(struct socket *so, const struc |
|
Line 1706 sosetopt1(struct socket *so, const struc |
|
case SO_ORCVTIMEO: { |
case SO_ORCVTIMEO: { |
struct timeval50 otv; |
struct timeval50 otv; |
error = sockopt_get(sopt, &otv, sizeof(otv)); |
error = sockopt_get(sopt, &otv, sizeof(otv)); |
|
if (error) { |
|
solock(so); |
|
break; |
|
} |
timeval50_to_timeval(&otv, &tv); |
timeval50_to_timeval(&otv, &tv); |
opt = opt == SO_OSNDTIMEO ? SO_SNDTIMEO : SO_RCVTIMEO; |
opt = opt == SO_OSNDTIMEO ? SO_SNDTIMEO : SO_RCVTIMEO; |
error = 1; |
error = 0; |
/*FALLTHROUGH*/ |
/*FALLTHROUGH*/ |
} |
} |
#endif /* COMPAT_50 */ |
#endif /* COMPAT_50 */ |
|
|
case SO_SNDTIMEO: |
case SO_SNDTIMEO: |
case SO_RCVTIMEO: |
case SO_RCVTIMEO: |
if (error == 0) |
if (error) |
error = sockopt_get(sopt, &tv, sizeof(tv)); |
error = sockopt_get(sopt, &tv, sizeof(tv)); |
solock(so); |
solock(so); |
if (error) |
if (error) |
Line 1813 sogetopt1(struct socket *so, struct sock |
|
Line 1833 sogetopt1(struct socket *so, struct sock |
|
case SO_BROADCAST: |
case SO_BROADCAST: |
case SO_OOBINLINE: |
case SO_OOBINLINE: |
case SO_TIMESTAMP: |
case SO_TIMESTAMP: |
|
#ifdef SO_OTIMESTAMP |
|
case SO_OTIMESTAMP: |
|
#endif |
error = sockopt_setint(sopt, (so->so_options & opt) ? 1 : 0); |
error = sockopt_setint(sopt, (so->so_options & opt) ? 1 : 0); |
break; |
break; |
|
|
Line 2301 sysctl_kern_somaxkva(SYSCTLFN_ARGS) |
|
Line 2324 sysctl_kern_somaxkva(SYSCTLFN_ARGS) |
|
} |
} |
|
|
static void |
static void |
sysctl_kern_somaxkva_setup() |
sysctl_kern_somaxkva_setup(void) |
{ |
{ |
|
|
KASSERT(socket_sysctllog == NULL); |
KASSERT(socket_sysctllog == NULL); |