Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output

do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.
This commit is contained in:
dsl 2009-12-09 21:32:58 +00:00
parent e87b55405f
commit 7a42c833db
19 changed files with 66 additions and 68 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: xenevt.c,v 1.34 2009/10/19 18:41:11 bouyer Exp $ */
/* $NetBSD: xenevt.c,v 1.35 2009/12/09 21:32:58 dsl Exp $ */
/*
* Copyright (c) 2005 Manuel Bouyer.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.34 2009/10/19 18:41:11 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.35 2009/12/09 21:32:58 dsl Exp $");
#include "opt_xen.h"
#include <sys/param.h>
@ -81,7 +81,7 @@ static const struct fileops xenevt_fileops = {
.fo_stat = fbadop_stat,
.fo_close = xenevt_fclose,
.fo_kqfilter = /* xenevt_fkqfilter */ fnullop_kqfilter,
.fo_drain = fnullop_drain,
.fo_abort = fnullop_abort,
};
dev_type_open(xenevtopen);

View File

@ -1,4 +1,4 @@
/* $NetBSD: svr4_net.c,v 1.56 2009/04/04 10:12:51 ad Exp $ */
/* $NetBSD: svr4_net.c,v 1.57 2009/12/09 21:32:58 dsl Exp $ */
/*-
* Copyright (c) 1994, 2008, 2009 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_net.c,v 1.56 2009/04/04 10:12:51 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_net.c,v 1.57 2009/12/09 21:32:58 dsl Exp $");
#define COMPAT_SVR4 1
@ -108,7 +108,7 @@ static const struct fileops svr4_netops = {
.fo_stat = soo_stat,
.fo_close = svr4_soo_close,
.fo_kqfilter = soo_kqfilter,
.fo_drain = soo_drain,
.fo_abort = soo_abort,
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: svr4_32_net.c,v 1.19 2009/04/04 10:12:51 ad Exp $ */
/* $NetBSD: svr4_32_net.c,v 1.20 2009/12/09 21:32:58 dsl Exp $ */
/*-
* Copyright (c) 1994, 2008, 2009 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_32_net.c,v 1.19 2009/04/04 10:12:51 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_32_net.c,v 1.20 2009/12/09 21:32:58 dsl Exp $");
#define COMPAT_SVR4 1
@ -102,7 +102,7 @@ static const struct fileops svr4_32_netops = {
.fo_poll = soo_poll,
.fo_stat = soo_stat,
.fo_close = svr4_soo_close,
.fo_drain = soo_drain,
.fo_abort = soo_abort,
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: dmover_io.c,v 1.35 2009/05/01 00:15:57 nonaka Exp $ */
/* $NetBSD: dmover_io.c,v 1.36 2009/12/09 21:32:58 dsl Exp $ */
/*
* Copyright (c) 2002, 2003 Wasabi Systems, Inc.
@ -55,7 +55,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dmover_io.c,v 1.35 2009/05/01 00:15:57 nonaka Exp $");
__KERNEL_RCSID(0, "$NetBSD: dmover_io.c,v 1.36 2009/12/09 21:32:58 dsl Exp $");
#include <sys/param.h>
#include <sys/queue.h>
@ -761,7 +761,7 @@ static const struct fileops dmio_fileops = {
.fo_stat = dmio_stat,
.fo_close = dmio_close,
.fo_kqfilter = fnullop_kqfilter,
.fo_drain = fnullop_drain,
.fo_abort = fnullop_abort,
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: putter.c,v 1.24 2009/12/07 13:41:44 pooka Exp $ */
/* $NetBSD: putter.c,v 1.25 2009/12/09 21:32:59 dsl Exp $ */
/*
* Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: putter.c,v 1.24 2009/12/07 13:41:44 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: putter.c,v 1.25 2009/12/09 21:32:59 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -206,7 +206,7 @@ static const struct fileops putter_fileops = {
.fo_stat = putter_fop_stat,
.fo_close = putter_fop_close,
.fo_kqfilter = putter_fop_kqfilter,
.fo_drain = fnullop_drain,
.fo_abort = fnullop_abort,
};
static int

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_descrip.c,v 1.200 2009/10/27 02:58:28 rmind Exp $ */
/* $NetBSD: kern_descrip.c,v 1.201 2009/12/09 21:32:59 dsl Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.200 2009/10/27 02:58:28 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.201 2009/12/09 21:32:59 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -624,7 +624,7 @@ fd_close(unsigned fd)
}
/* Try to drain out descriptor references. */
(*fp->f_ops->fo_drain)(fp);
(*fp->f_ops->fo_abort)(fp);
mutex_enter(&fdp->fd_lock);
/*
@ -1787,7 +1787,7 @@ fnullop_kqfilter(file_t *fp, struct knote *kn)
}
void
fnullop_drain(file_t *fp)
fnullop_abort(file_t *fp)
{
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_drvctl.c,v 1.29 2009/09/16 16:34:50 dyoung Exp $ */
/* $NetBSD: kern_drvctl.c,v 1.30 2009/12/09 21:32:59 dsl Exp $ */
/*
* Copyright (c) 2004
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_drvctl.c,v 1.29 2009/09/16 16:34:50 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_drvctl.c,v 1.30 2009/12/09 21:32:59 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -90,7 +90,7 @@ static const struct fileops drvctl_fileops = {
.fo_stat = drvctl_stat,
.fo_close = drvctl_close,
.fo_kqfilter = fnullop_kqfilter,
.fo_drain = fnullop_drain,
.fo_abort = fnullop_abort,
};
#define MAXLOCATORS 100

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_event.c,v 1.66 2009/10/03 00:14:07 elad Exp $ */
/* $NetBSD: kern_event.c,v 1.67 2009/12/09 21:32:59 dsl Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.66 2009/10/03 00:14:07 elad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.67 2009/12/09 21:32:59 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -115,7 +115,7 @@ static const struct fileops kqueueops = {
.fo_stat = kqueue_stat,
.fo_close = kqueue_close,
.fo_kqfilter = kqueue_kqfilter,
.fo_drain = fnullop_drain,
.fo_abort = fnullop_abort,
};
static const struct filterops kqread_filtops =

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_mqueue.c,v 1.26 2009/11/01 21:46:09 rmind Exp $ */
/* $NetBSD: sys_mqueue.c,v 1.27 2009/12/09 21:32:59 dsl Exp $ */
/*
* Copyright (c) 2007-2009 Mindaugas Rasiukevicius <rmind at NetBSD org>
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.26 2009/11/01 21:46:09 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.27 2009/12/09 21:32:59 dsl Exp $");
#include <sys/param.h>
#include <sys/types.h>
@ -102,7 +102,7 @@ static const struct fileops mqops = {
.fo_stat = mq_stat_fop,
.fo_close = mq_close_fop,
.fo_kqfilter = fnullop_kqfilter,
.fo_drain = fnullop_drain,
.fo_abort = fnullop_abort,
};
static const struct syscall_package mqueue_syscalls[] = {

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_pipe.c,v 1.120 2009/12/06 20:26:55 dsl Exp $ */
/* $NetBSD: sys_pipe.c,v 1.121 2009/12/09 21:32:59 dsl Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.120 2009/12/06 20:26:55 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.121 2009/12/09 21:32:59 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -119,7 +119,7 @@ static const struct fileops pipeops = {
.fo_stat = pipe_stat,
.fo_close = pipe_close,
.fo_kqfilter = pipe_kqfilter,
.fo_drain = fnullop_drain,
.fo_abort = fnullop_abort,
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_socket.c,v 1.61 2009/04/08 21:02:09 ad Exp $ */
/* $NetBSD: sys_socket.c,v 1.62 2009/12/09 21:32:59 dsl Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.61 2009/04/08 21:02:09 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.62 2009/12/09 21:32:59 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -89,7 +89,7 @@ const struct fileops socketops = {
.fo_stat = soo_stat,
.fo_close = soo_close,
.fo_kqfilter = soo_kqfilter,
.fo_drain = fnullop_drain, /* soo_drain, */
.fo_abort = soo_abort,
};
/* ARGSUSED */
@ -260,8 +260,8 @@ soo_close(file_t *fp)
}
void
soo_drain(file_t *fp)
soo_abort(file_t *fp)
{
(void)sodrain(fp->f_data);
soabortop(fp->f_data);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uipc_socket.c,v 1.194 2009/11/07 07:27:49 cegger Exp $ */
/* $NetBSD: uipc_socket.c,v 1.195 2009/12/09 21:32:59 dsl Exp $ */
/*-
* Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.194 2009/11/07 07:27:49 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.195 2009/12/09 21:32:59 dsl Exp $");
#include "opt_compat_netbsd.h"
#include "opt_sock_counters.h"
@ -1624,18 +1624,16 @@ soshutdown(struct socket *so, int how)
return error;
}
int
sodrain(struct socket *so)
void
soabortop(struct socket *so)
{
int error;
#if 0 /* ad@ wrote this, then disabled it as 'not working' */
solock(so);
so->so_state |= SS_ISDRAINING;
so->so_state |= SS_ISABORTING;
cv_broadcast(&so->so_cv);
error = soshutdown(so, SHUT_RDWR);
soshutdown(so, SHUT_RDWR);
sounlock(so);
return error;
#endif
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: uipc_syscalls.c,v 1.136 2009/04/04 10:12:51 ad Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.137 2009/12/09 21:33:00 dsl Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.136 2009/04/04 10:12:51 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.137 2009/12/09 21:33:00 dsl Exp $");
#include "opt_pipe.h"
@ -317,7 +317,7 @@ do_sys_connect(struct lwp *l, int fd, struct mbuf *nam)
}
while ((so->so_state & SS_ISCONNECTING) != 0 && so->so_error == 0) {
error = sowait(so, true, 0);
if (__predict_false((so->so_state & SS_ISDRAINING) != 0)) {
if (__predict_false((so->so_state & SS_ISABORTING) != 0)) {
error = EPIPE;
interrupted = 1;
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_vnops.c,v 1.166 2009/05/17 05:54:42 yamt Exp $ */
/* $NetBSD: vfs_vnops.c,v 1.167 2009/12/09 21:32:59 dsl Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.166 2009/05/17 05:54:42 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.167 2009/12/09 21:32:59 dsl Exp $");
#include "veriexec.h"
@ -122,7 +122,7 @@ const struct fileops vnops = {
.fo_stat = vn_statfile,
.fo_close = vn_closefile,
.fo_kqfilter = vn_kqfilter,
.fo_drain = fnullop_drain,
.fo_abort = fnullop_abort,
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: bpf.c,v 1.148 2009/11/23 02:13:48 rmind Exp $ */
/* $NetBSD: bpf.c,v 1.149 2009/12/09 21:32:59 dsl Exp $ */
/*
* Copyright (c) 1990, 1991, 1993
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.148 2009/11/23 02:13:48 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.149 2009/12/09 21:32:59 dsl Exp $");
#if defined(_KERNEL_OPT)
#include "opt_bpf.h"
@ -165,7 +165,7 @@ static const struct fileops bpf_fileops = {
.fo_stat = bpf_stat,
.fo_close = bpf_close,
.fo_kqfilter = bpf_kqfilter,
.fo_drain = fnullop_drain,
.fo_abort = fnullop_abort,
};
dev_type_open(bpfopen);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_tap.c,v 1.60 2009/11/29 10:44:23 plunky Exp $ */
/* $NetBSD: if_tap.c,v 1.61 2009/12/09 21:32:59 dsl Exp $ */
/*
* Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation.
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.60 2009/11/29 10:44:23 plunky Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.61 2009/12/09 21:32:59 dsl Exp $");
#if defined(_KERNEL_OPT)
#include "bpfilter.h"
@ -161,7 +161,7 @@ static const struct fileops tap_fileops = {
.fo_stat = tap_fops_stat,
.fo_close = tap_fops_close,
.fo_kqfilter = tap_fops_kqfilter,
.fo_drain = fnullop_drain,
.fo_abort = fnullop_abort,
};
/* Helper for cloning open() */

View File

@ -1,4 +1,4 @@
/* $NetBSD: cryptodev.c,v 1.49 2009/04/11 23:05:26 christos Exp $ */
/* $NetBSD: cryptodev.c,v 1.50 2009/12/09 21:32:59 dsl Exp $ */
/* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */
/* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */
@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.49 2009/04/11 23:05:26 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.50 2009/12/09 21:32:59 dsl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -157,7 +157,7 @@ static const struct fileops cryptofops = {
.fo_stat = cryptof_stat,
.fo_close = cryptof_close,
.fo_kqfilter = fnullop_kqfilter,
.fo_drain = fnullop_drain,
.fo_abort = fnullop_abort,
};
struct csession *cryptodev_csefind(struct fcrypt *, u_int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: file.h,v 1.68 2009/05/17 05:54:42 yamt Exp $ */
/* $NetBSD: file.h,v 1.69 2009/12/09 21:33:00 dsl Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -100,7 +100,7 @@ struct file {
int (*fo_stat) (struct file *, struct stat *);
int (*fo_close) (struct file *);
int (*fo_kqfilter) (struct file *, struct knote *);
void (*fo_drain) (struct file *);
void (*fo_abort) (struct file *);
void (*fo_spare1) (void);
void (*fo_spare2) (void);
} *f_ops;
@ -162,7 +162,7 @@ int fbadop_write(struct file *, off_t *, struct uio *, kauth_cred_t, int);
int fbadop_ioctl(struct file *, u_long, void *);
int fbadop_close(struct file *);
int fbadop_stat(struct file *, struct stat *);
void fnullop_drain(struct file *);
void fnullop_abort(struct file *);
#endif /* _KERNEL */

View File

@ -1,4 +1,4 @@
/* $NetBSD: socketvar.h,v 1.121 2009/09/11 22:06:29 dyoung Exp $ */
/* $NetBSD: socketvar.h,v 1.122 2009/12/09 21:33:00 dsl Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@ -198,7 +198,7 @@ do { \
#define SS_CANTSENDMORE 0x010 /* can't send more data to peer */
#define SS_CANTRCVMORE 0x020 /* can't receive more data from peer */
#define SS_RCVATMARK 0x040 /* at mark on input */
#define SS_ISDRAINING 0x080 /* draining fd references */
#define SS_ISABORTING 0x080 /* aborting fd references - close() */
#define SS_ISDISCONNECTED 0x800 /* socket disconnected from peer */
#define SS_ASYNC 0x100 /* async i/o notify */
@ -256,7 +256,7 @@ int soo_poll(file_t *, int);
int soo_kqfilter(file_t *, struct knote *);
int soo_close(file_t *);
int soo_stat(file_t *, struct stat *);
void soo_drain(file_t *);
void soo_abort(file_t *);
void sbappend(struct sockbuf *, struct mbuf *);
void sbappendstream(struct sockbuf *, struct mbuf *);
int sbappendaddr(struct sockbuf *, const struct sockaddr *, struct mbuf *,
@ -313,7 +313,7 @@ int sosend(struct socket *, struct mbuf *, struct uio *,
int sosetopt(struct socket *, struct sockopt *);
int so_setsockopt(struct lwp *, struct socket *, int, int, const void *, size_t);
int soshutdown(struct socket *, int);
int sodrain(struct socket *);
void soabortop(struct socket *);
void sowakeup(struct socket *, struct sockbuf *, int);
int sockargs(struct mbuf **, const void *, size_t, int);
int sopoll(struct socket *, int);