From rpolzer@durchnull.ath.cx  Sat Dec 18 00:26:29 2004
Return-Path: <rpolzer@durchnull.ath.cx>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9EBE316A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 18 Dec 2004 00:26:29 +0000 (GMT)
Received: from ccc-offenbach.org (pD9EA669D.dip.t-dialin.net [217.234.102.157])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 788A743D31
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 18 Dec 2004 00:26:27 +0000 (GMT)
	(envelope-from rpolzer@durchnull.ath.cx)
Received: (qmail 58871 invoked by uid 1000); 18 Dec 2004 00:26:25 -0000
Message-Id: <20041218002625.58870.qmail@durchnull.ath.cx>
Date: 18 Dec 2004 00:26:25 -0000
From: Rudolf Polzer <freebsd-dr@durchnull.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc: fph@ngi.it
Subject: games/bastet does busy waiting
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         75208
>Category:       ports
>Synopsis:       games/bastet does busy waiting
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 18 00:30:27 GMT 2004
>Closed-Date:    Thu Dec 23 06:27:22 GMT 2004
>Last-Modified:  Sat Mar 26 10:40:01 GMT 2005
>Originator:     Rudolf Polzer
>Release:        FreeBSD 5.3-STABLE i386
>Organization:
>Environment:
System: FreeBSD katsuragi.div0.ccc-offenbach.org 5.3-STABLE FreeBSD 5.3-STABLE #3: Thu Dec 2 07:47:37 CET 2004 root@katsuragi.div0.ccc-offenbach.org:/usr/obj/usr/src/sys/DIV0_KERNEL i386


Athlon XP, nothing else required IMHO
>Description:
bastet does busy waiting because the select() call in game.c returns
with EINVAL. The reason is that timeout does not point to the struct
timeval in the program but to a ncurses function with the same name. I
renamed the variable to fix it. Also the value 1000000 is not a valid
timeout value because it would have to be encoded as 1 second and 0
microseconds. I fixed it trivially by using 999999 for that value.

Also I fixed a gcc warning. Anyway I think the function bast_clear has
to be declared somewhere else.

Should be easy to fix - temporarily I just put the diff below in my
files/ directory of the port.

Thanks!
>How-To-Repeat:
Play bastet (especially at level 0) and look at it in top.
>Fix:

diff -ru game.c bastet-0.41/game.c
--- game.c	Sat Dec 18 00:28:00 2004
+++ bastet-0.41/game.c	Sat Dec 18 00:56:26 2004
@@ -12,6 +12,9 @@
 #include "game.h"
 #include "main.h"
 #include "bast.h"
+#include <sys/select.h>
+
+void bast_clear();
 
 const DOT block_data[BLOCK_TYPES][BLOCK_ORIENTS][BLOCK_DOTS] =
 {
@@ -66,7 +70,7 @@
 
 /* Delay before block drop one step down (usec).
    We start at one sec. and then decreases the delay by 23% at each level. */
-const int delay[NO_LEVELS] = {1000000, 770000, 593000, 457000, 352000, 271000, 208000, 160000, 124000, 95000};
+const int delay[NO_LEVELS] = {999999, 770000, 593000, 457000, 352000, 271000, 208000, 160000, 124000, 95000};
 
 /* Window in which the action takes place. */
 WINDOW *well_win;
@@ -278,6 +282,7 @@
         refresh();
 }
 
+struct timeval mytimeout;
 /* Drop a block in the well. When done return y-cord. of where block
    ended. If it's not possible to even start with a new block return -1. */
 int drop_block(int type, int level)
@@ -288,14 +293,13 @@
         int orient = 0;
         int ch;
         fd_set inputs, test_fds;
-        struct timeval timeout;
         int sel_ret;
 
         if (0 == check_block_pos(y, x, type, orient))
                 return -1;      /* Oh no, game over. */
 
-        timeout.tv_sec = 0;
-        timeout.tv_usec = delay[level];
+        mytimeout.tv_sec = 0;
+        mytimeout.tv_usec = delay[level];
 
         FD_ZERO(&inputs);
         FD_SET(0, &inputs);
@@ -308,7 +312,7 @@
         while(1) {
                 test_fds = inputs;
 
-                sel_ret = select(FD_SETSIZE, &test_fds, (fd_set *) 0, (fd_set *) 0, &timeout);
+                sel_ret = select(FD_SETSIZE, &test_fds, (fd_set *) 0, (fd_set *) 0, &mytimeout);
 
                 ch = getch();
 
@@ -391,8 +402,8 @@
                                 set_block(y, x, type, orient);
                                 return y;
                         }
-                        timeout.tv_sec = 0;
-                        timeout.tv_usec = delay[level];
+                        mytimeout.tv_sec = 0;
+                        mytimeout.tv_usec = delay[level];
                 }
         }
 }
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: edwin 
State-Changed-When: Thu Dec 23 06:27:15 GMT 2004 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=75208 

From: Michael Nottebrock <michaelnottebrock@gmx.net>
To: freebsd-gnats-submit@FreeBSD.org, freebsd-dr@durchnull.de
Cc:  
Subject: Re: ports/75208: games/bastet does busy waiting
Date: Sat, 26 Mar 2005 11:39:32 +0100

 --nextPart1626875.h8Rv0nUkRu
 Content-Type: text/plain;
   charset="us-ascii"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: inline
 
 Just noticed this patch (I made the original port of the game) - have you=20
 submitted it to the author of the software as well and if not, could you do=
 =20
 so please?
 
 =2D-=20
    ,_,   | Michael Nottebrock               | lofi@freebsd.org
  (/^ ^\) | FreeBSD - The Power to Serve     | http://www.freebsd.org
    \u/   | K Desktop Environment on FreeBSD | http://freebsd.kde.org
 
 --nextPart1626875.h8Rv0nUkRu
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.0 (FreeBSD)
 
 iD8DBQBCRTvoXhc68WspdLARAh2hAJ4gEL7CFevinELHFzXOumM+vsbQ2wCghDV4
 BKAXviQOH8WgU5dEOd6mnnA=
 =/vHL
 -----END PGP SIGNATURE-----
 
 --nextPart1626875.h8Rv0nUkRu--
>Unformatted:
