From owner-freebsd-hackers@FreeBSD.ORG Sun Mar 29 17:53:30 2015 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 20272E10 for ; Sun, 29 Mar 2015 17:53:30 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9B9AFE4 for ; Sun, 29 Mar 2015 17:53:29 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id t2THrKsH025066 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 29 Mar 2015 20:53:20 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua t2THrKsH025066 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id t2THrKBf025065; Sun, 29 Mar 2015 20:53:20 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 29 Mar 2015 20:53:20 +0300 From: Konstantin Belousov To: Jilles Tjoelker Subject: Re: kevent behavior Message-ID: <20150329175320.GA2379@kib.kiev.ua> 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> <20150329160338.GZ2379@kib.kiev.ua> <20150329172207.GC95224@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150329172207.GC95224@stack.nl> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: freebsd-hackers@FreeBSD.org, Ivan Radovanovic X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Mar 2015 17:53:30 -0000 On Sun, Mar 29, 2015 at 07:22:07PM +0200, Jilles Tjoelker wrote: > Given that the special case for fcntl() is mentioned in > pthread_testcancel(3) (only a cancellation point if cmd is F_SETLKW), > the same should be done for kevent(). > > Looks good to me otherwise. Below is the update. I will commit after some tests finish. 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..a6b27f6 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 , @@ -147,12 +148,20 @@ functions: .Fn waitpid , .Fn write , .Fn writev . +.Pp The .Fn fcntl function is a cancellation point if .Fa cmd is .Dv F_SETLKW . +.Pp +The +.Fn kevent +function is a cancellation point if it is potentially blocking, +i.e. when the +.Fa nevents +argument is non-zero. .Sh RETURN VALUES If successful, the .Fn pthread_setcancelstate