Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Mar 2015 19:03:38 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Jilles Tjoelker <jilles@stack.nl>
Cc:        freebsd-hackers@FreeBSD.org, Ivan Radovanovic <radovanovic@gmail.com>
Subject:   Re: kevent behavior
Message-ID:  <20150329160338.GZ2379@kib.kiev.ua>
In-Reply-To: <20150329150316.GB95224@stack.nl>
References:  <550A6DA2.1070004@gmail.com> <20150324221541.GA67584@stack.nl> <20150325090041.GY2379@kib.kiev.ua> <20150325223530.GA79065@stack.nl> <20150326214551.GG2379@kib.kiev.ua> <20150326225826.GA97319@stack.nl> <20150327132654.GJ2379@kib.kiev.ua> <20150329150316.GB95224@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Mar 29, 2015 at 05:03:16PM +0200, Jilles Tjoelker wrote:
> On Fri, Mar 27, 2015 at 03:26:54PM +0200, Konstantin Belousov wrote:
> > +Otherwise, i.e. if
> > +.Fa nevents
> > +is zero, the call is not cancellable.
> 
> > +Cancellation can only occur when the call was blocked and no changes
> > +to the queue were requested.
> 
> This is not how the code works, but I think the code is correct. The
> code also allows cancellation before anything happens. As such, if
> cancellation occurs at kevent(2), the kqueue's state is unchanged (from
> that call).
Below is only a new diff for the man pages changes.  I found our list
of the cancellation points in the pthread_testcancel(3), but did not
checked it for correctness.

> 
> A new error should be added to the man page:
> 
> .It Bq Er EINTR
> A cancellation request was delivered to the thread, but not yet handled.
> 
> Both [EINTR] errors should have this sentence added to them:
> 
> All changes in the
> .Fa changelist
> have been applied.
> 
I formulated this after the error list.

diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2
index 93223f1..c5e8caf 100644
--- a/lib/libc/sys/kqueue.2
+++ b/lib/libc/sys/kqueue.2
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 18, 2014
+.Dd March 29, 2015
 .Dt KQUEUE 2
 .Os
 .Sh NAME
@@ -41,7 +41,7 @@
 .Fn kqueue "void"
 .Ft int
 .Fn kevent "int kq" "const struct kevent *changelist" "int nchanges" "struct kevent *eventlist" "int nevents" "const struct timespec *timeout"
-.Fn EV_SET "&kev" ident filter flags fflags data udata
+.Fn EV_SET "kev" ident filter flags fflags data udata
 .Sh DESCRIPTION
 The
 .Fn kqueue
@@ -550,6 +550,16 @@ On return,
 .Va fflags
 contains the users defined flags in the lower 24 bits.
 .El
+.Sh CANCELLATION BEHAVIOUR
+If
+.Fa nevents
+is non-zero, i.e. the function is potentially blocking, the call
+is a cancellation point.
+Otherwise, i.e. if
+.Fa nevents
+is zero, the call is not cancellable.
+Cancellation can only occur before any changes are made to the kqueue,
+or when the call was blocked and no changes to the queue were requested.
 .Sh RETURN VALUES
 The
 .Fn kqueue
@@ -620,6 +630,8 @@ The specified descriptor is invalid.
 .It Bq Er EINTR
 A signal was delivered before the timeout expired and before any
 events were placed on the kqueue for return.
+.It Bq Er EINTR
+A cancellation request was delivered to the thread, but not yet handled.
 .It Bq Er EINVAL
 The specified time limit or filter is invalid.
 .It Bq Er ENOENT
@@ -634,6 +646,14 @@ sysctl.
 .It Bq Er ESRCH
 The specified process to attach to does not exist.
 .El
+.Pp
+When
+.Fn kevent
+call fails with
+.Er EINTR
+error, all changes in the
+.Fa changelist
+have been applied.
 .Sh SEE ALSO
 .Xr aio_error 2 ,
 .Xr aio_read 2 ,
@@ -643,6 +663,7 @@ The specified process to attach to does not exist.
 .Xr select 2 ,
 .Xr sigaction 2 ,
 .Xr write 2 ,
+.Xr pthread_setcancelstate 3 ,
 .Xr signal 3
 .Sh HISTORY
 The
diff --git a/share/man/man3/pthread_testcancel.3 b/share/man/man3/pthread_testcancel.3
index ef6a1c1..4390c92 100644
--- a/share/man/man3/pthread_testcancel.3
+++ b/share/man/man3/pthread_testcancel.3
@@ -1,5 +1,5 @@
 .\" $FreeBSD$
-.Dd June 11, 2013
+.Dd March 29, 2015
 .Dt PTHREAD_TESTCANCEL 3
 .Os
 .Sh NAME
@@ -107,6 +107,7 @@ functions:
 .Fn close ,
 .Fn creat ,
 .Fn fsync ,
+.Fn kevent ,
 .Fn mq_receive ,
 .Fn mq_send ,
 .Fn mq_timedreceive ,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150329160338.GZ2379>