From owner-freebsd-emulation@FreeBSD.ORG Wed Mar 5 18:17:56 2008 Return-Path: Delivered-To: emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CF518106566C for ; Wed, 5 Mar 2008 18:17:56 +0000 (UTC) (envelope-from rdivacky@vlk.vlakno.cz) Received: from vlakno.cz (vlk.vlakno.cz [62.168.28.247]) by mx1.freebsd.org (Postfix) with ESMTP id 833728FC25 for ; Wed, 5 Mar 2008 18:17:55 +0000 (UTC) (envelope-from rdivacky@vlk.vlakno.cz) Received: from localhost (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id A347D67611F; Wed, 5 Mar 2008 19:17:54 +0100 (CET) X-Virus-Scanned: amavisd-new at vlakno.cz Received: from vlakno.cz ([127.0.0.1]) by localhost (vlk.vlakno.cz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bF4fs96NMATN; Wed, 5 Mar 2008 19:17:42 +0100 (CET) Received: from vlk.vlakno.cz (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 68743676110; Wed, 5 Mar 2008 19:17:42 +0100 (CET) Received: (from rdivacky@localhost) by vlk.vlakno.cz (8.13.8/8.13.8/Submit) id m25IHfXL016508; Wed, 5 Mar 2008 19:17:41 +0100 (CET) (envelope-from rdivacky) Date: Wed, 5 Mar 2008 19:17:41 +0100 From: Roman Divacky To: Alexander Leidinger Message-ID: <20080305181741.GA15620@freebsd.org> References: <20080304183529.kpaf3f76gcg4g0cs@webmail.leidinger.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080304183529.kpaf3f76gcg4g0cs@webmail.leidinger.net> User-Agent: Mutt/1.4.2.3i Cc: emulation@freebsd.org Subject: Re: epoll review continued X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Mar 2008 18:17:57 -0000 On Tue, Mar 04, 2008 at 06:35:29PM +0100, Alexander Leidinger wrote: > >@@ -57,7 +57,9 @@ > > > > if (args->size <= 0) > > return (EINVAL); > >- /* args->size is unused. Linux ignores it as well. */ > >+ /* + * args->size is unused. Linux just tests it + * and then > >forgets it as well. */ > > My proposal ("Submitted by: netchild" in the log): > /* > * The size is documented to be only a hint. We don't need > * it with kevent. The epoll_create man-page tells that the > * size has to be not-negative, but the linux kernel test > * for a value of at least 1, so for error compatibility we > * do the same. > */ > > The above comment should be before the if, not after. given that man pages and the source of the kernel are totally independent I would not trust the man pages... and certainly would not cite that as a reliable source > >static int > >linux_kev_copyin(void *arg, struct kevent *kevp, int count) > >@@ -193,7 +197,8 @@ > > break; > > case LINUX_EPOLL_CTL_MOD: > > /* TODO: DELETE && ADD maybe? */ > >- return (EINVAL); > >+ printf("linux_epoll_ctl: CTL_MOD not yet > >>implemented.\n"); > >+ return (ENOSYS); > > ENOSYS is "syscall not implemented". But we implement the syscall. > When glibc tests this syscall and gets back a ENOSYS, it may switch to > a different way of monitoring files. I think the EINVAL was better, as > it will result in an application error and notify us that we need to > take care about this part of the syscall. #define ENOSYS 78 /* Function not implemented */ its used for this purposes all over the kernel so I think its ok > > break; > > case LINUX_EPOLL_CTL_DEL: > > kev.flags = EV_DELETE | EV_DISABLE; > >@@ -241,6 +246,9 @@ > > > > error = kern_kevent(td, args->epfd, 0, args->maxevents, &k_ops, &ts); > > > >- /* translation? */ > >+ /* + * kern_keven might return ENOMEM which is not expected from > >epoll_wait. > >+ * Maybe we should translate that but I don't think it matters at > >all. > >+ */ > > return (error); > >} > > It is not even ENOMEM. After a quick look I think it should be like: > - ESRCH, ENOENT should map to EINVAL > - EACCESS should map to EFAULT or EINVAL (don't really know) > - ENOMEM should map to... ? > > You also need to deliver EINVAL, if maxevents is <= 0 (according to > the man page of epoll_wait). I fixed the maxevents bug but... the ESRCH/ENOENT/EACCESS apply only to epoll_wait (as that does the registering). I'd let it as it is and fix it if problems from real usage arise. can someone test this using java/apache/something? I dont have time/energy for that :( roman