From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: 100% CPU on TCP servers Date: Wed, 12 Oct 2005 17:07:00 +0200 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1129129740 4972 80.91.229.2 (12 Oct 2005 15:09:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 12 Oct 2005 15:09:00 +0000 (UTC) Cc: Juanma Barranquero , Emacs Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 12 17:08:49 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EPiCy-0001oo-TT for ged-emacs-devel@m.gmane.org; Wed, 12 Oct 2005 17:07:57 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EPiCx-0000UD-Ru for ged-emacs-devel@m.gmane.org; Wed, 12 Oct 2005 11:07:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EPiCo-0000U6-S9 for emacs-devel@gnu.org; Wed, 12 Oct 2005 11:07:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EPiCn-0000Tu-DZ for emacs-devel@gnu.org; Wed, 12 Oct 2005 11:07:46 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EPiCn-0000Tq-B0 for emacs-devel@gnu.org; Wed, 12 Oct 2005 11:07:45 -0400 Original-Received: from [195.41.46.237] (helo=pfepc.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EPiCl-0006nG-Q2; Wed, 12 Oct 2005 11:07:43 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (unknown [80.165.4.124]) by pfepc.post.tele.dk (Postfix) with SMTP id DDDB62628B2; Wed, 12 Oct 2005 17:07:42 +0200 (CEST) Original-To: Jason Rumney In-Reply-To: (Jason Rumney's message of "Sat, 10 Sep 2005 08:47:06 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:43930 Archived-At: Jason Rumney writes: > Juanma Barranquero writes: > >> (A question for process-savvy people) >> >> It seems like >> >>> (make-network-process :name "test" :server t :service t) >> >> on Windows makes the server process to call server_accept_connection() >> continuously (in a 2.8 GHz Pentium IV I've measured around 10,200 >> calls in 3,5 s, almost 2,900 calls per second). It's no wonder Emacs >> is munching 50% CPU. >> >> Any idea why that can be happening? > > Probably a bug in sys_select() in w32proc.c I investigate it a little bit and found that it seems that w32 server sockets must use WSAAsyncSelect + FD_ACCEPT to request notifications of incoming connections -- but exactly how that is done is not for me to look at... In its current form, it sys_select says the socket is ready, so we call server_accept_connection which again calls accept() which returns -1 with errno == WSAEWOULDBLOCK (10035) indicating that there is no pending connection to accept. Can somebody pls. look into doing this the right way? -- Kim F. Storm http://www.cua.dk