From 8c255c15cc55a2e5254152c8e07a8ab45b22b7af Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 9 Jun 2011 09:49:09 +0200 Subject: [PATCH] version 1.4w10UCIb22 --- ChangeLog | 2 + config.h | 6 ++-- configure | 20 +++++++++--------- configure.ac | 2 +- main.cpp | 2 +- pipe.cpp | 59 +++++++++++++++----------------------------------------- pipe.h | 4 +++ polyglot.spec | 2 +- 8 files changed, 38 insertions(+), 59 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2b7dfa..b1562e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +=========1.4w10UCIb22=========== +- Polyglot now completely poll free... =========1.4w10UCIb21=========== - Crash bug in memory command fixed - Small optimizations diff --git a/config.h b/config.h index 4c57eae..f602e78 100644 --- a/config.h +++ b/config.h @@ -115,13 +115,13 @@ #define PACKAGE_NAME "polyglot" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "polyglot 1.4w10UCIb21" +#define PACKAGE_STRING "polyglot 1.4w10UCIb22" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "polyglot" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.4w10UCIb21" +#define PACKAGE_VERSION "1.4w10UCIb22" /* Define to 1 if the C compiler supports function prototypes. */ #define PROTOTYPES 1 @@ -150,7 +150,7 @@ #define TIME_WITH_SYS_TIME 1 /* Version number of package */ -#define VERSION "1.4w10UCIb21" +#define VERSION "1.4w10UCIb22" /* Define like PROTOTYPES; this can be used by system headers. */ #define __PROTOTYPES 1 diff --git a/configure b/configure index eb74a04..ebfd2d0 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for polyglot 1.4w10UCIb21. +# Generated by GNU Autoconf 2.61 for polyglot 1.4w10UCIb22. # # Report bugs to . # @@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='polyglot' PACKAGE_TARNAME='polyglot' -PACKAGE_VERSION='1.4w10UCIb21' -PACKAGE_STRING='polyglot 1.4w10UCIb21' +PACKAGE_VERSION='1.4w10UCIb22' +PACKAGE_STRING='polyglot 1.4w10UCIb22' PACKAGE_BUGREPORT='michel.vandenbergh@uhasselt.be' ac_unique_file="mainloop.cpp" @@ -1216,7 +1216,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures polyglot 1.4w10UCIb21 to adapt to many kinds of systems. +\`configure' configures polyglot 1.4w10UCIb22 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1282,7 +1282,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of polyglot 1.4w10UCIb21:";; + short | recursive ) echo "Configuration of polyglot 1.4w10UCIb22:";; esac cat <<\_ACEOF @@ -1368,7 +1368,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -polyglot configure 1.4w10UCIb21 +polyglot configure 1.4w10UCIb22 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1382,7 +1382,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by polyglot $as_me 1.4w10UCIb21, which was +It was created by polyglot $as_me 1.4w10UCIb22, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -2072,7 +2072,7 @@ fi # Define the identity of the package. PACKAGE='polyglot' - VERSION='1.4w10UCIb21' + VERSION='1.4w10UCIb22' cat >>confdefs.h <<_ACEOF @@ -7344,7 +7344,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by polyglot $as_me 1.4w10UCIb21, which was +This file was extended by polyglot $as_me 1.4w10UCIb22, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7397,7 +7397,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -polyglot config.status 1.4w10UCIb21 +polyglot config.status 1.4w10UCIb22 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.ac b/configure.ac index 409e38d..2875e95 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([polyglot], [1.4w10UCIb21], [michel.vandenbergh@uhasselt.be]) +AC_INIT([polyglot], [1.4w10UCIb22], [michel.vandenbergh@uhasselt.be]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([mainloop.cpp]) AC_CONFIG_HEADER([config.h]) diff --git a/main.cpp b/main.cpp index 07a02e1..64ee304 100644 --- a/main.cpp +++ b/main.cpp @@ -35,7 +35,7 @@ // constants -static const char * const Version = "1.4W10UCIb21"; +static const char * const Version = "1.4W10UCIb22"; static const char * const HelpMessage = "\ SYNTAX\n\ * polyglot [configfile]\n\ diff --git a/pipe.cpp b/pipe.cpp index 7f868bd..5d07844 100644 --- a/pipe.cpp +++ b/pipe.cpp @@ -20,6 +20,7 @@ void PipeStruct::Open(const char *szProcFile) { SECURITY_ATTRIBUTES sa; STARTUPINFO si; PROCESS_INFORMATION pi; + int fdInput; state=0; if (szProcFile == NULL) { hInput = GetStdHandle(STD_INPUT_HANDLE); @@ -67,6 +68,14 @@ void PipeStruct::Open(const char *szProcFile) { dwMode & ~(ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT)); FlushConsoleInputBuffer(hInput); } + fdInput=_open_osfhandle((intptr_t) hInput,_O_RDONLY); + if(fdInput==-1){ + my_fatal("PipeStruct::Open(): %s",my_error()); + } + fpInput=fdopen(fdInput,"r"); + if(fpInput==NULL){ + my_fatal("PipeStruct::Open(): %s",my_error()); + } nReadEnd = 0; lpFeedEnd = NULL; InitializeCriticalSection(&CriticalSection); @@ -134,50 +143,14 @@ void PipeStruct::set_Active(void){ int PipeStruct::ReadData(void){ DWORD dwBytes; - int ret; + char * ret; - if(!bPipe){ - fgets(lpReadBuffer,LINE_INPUT_MAX_CHAR,stdin); - dwBytes=strlen(lpReadBuffer); - if(!dwBytes){ - set_EOF_(); - lpReadBuffer[0]='\0'; - return 0; - } - }else{ - // Unfortunately we need to use polling here. - // Otherwise Windows returns single bytes if - // the engine runs at low priority. - // This kills performance. - while(TRUE){ - ret=PeekNamedPipe(hInput, - NULL, // don't read anything yet - 0, // no buffer - NULL, // no we don't read anything! - &dwBytes,// now we're talking - NULL); // nono we don't read anything - if(!ret){ - set_EOF_(); - lpReadBuffer[0]='\0'; - return 0; - } - if(dwBytes>0){ - break; - }else{ - Idle(); - } - - } - ret=ReadFile(hInput, - lpReadBuffer, - LINE_INPUT_MAX_CHAR, - &dwBytes, - NULL); - if(!ret){ - set_EOF_(); - lpReadBuffer[0]='\0'; - return 0; - } + ret=fgets(lpReadBuffer,LINE_INPUT_MAX_CHAR,fpInput); + dwBytes=strlen(lpReadBuffer); + if(!ret){ + set_EOF_(); + lpReadBuffer[0]='\0'; + return 0; } lpReadBuffer[dwBytes]='\0'; return dwBytes; diff --git a/pipe.h b/pipe.h index e90a4db..a8b086b 100644 --- a/pipe.h +++ b/pipe.h @@ -4,6 +4,9 @@ // includes #include +#include +#include +#include // constants @@ -19,6 +22,7 @@ const int LINE_INPUT_MAX_CHAR = 10*4096; struct PipeStruct { HANDLE hInput, hOutput; + FILE *fpInput; HANDLE hProcess; HANDLE hThread; HANDLE hEvent; diff --git a/polyglot.spec b/polyglot.spec index f3a7944..8ccf2f1 100644 --- a/polyglot.spec +++ b/polyglot.spec @@ -1,6 +1,6 @@ Summary: A Winboard protocol to UCI protocol adapter Name: polyglot -Version: 1.4w10UCIb21 +Version: 1.4w10UCIb22 Release: 1 License: GPL Group: Amusement/Games -- 1.7.0.4