[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] GTP sometimes fails

From: Darren Cook
Subject: Re: [gnugo-devel] GTP sometimes fails
Date: Sat, 19 Mar 2005 11:00:33 +0900
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

> I cannot really read your code, but it seems correct.  I can think of
> two possible problems: bad pipe setup or too small `readbuf'.  If you
> send `list_commands', two kilobytes might be not enough...

It is failing on set_random_seed, which is the first command after
getting the connection. Specifically it fails on my 3rd unit test -
whichever order I do the unit tests in. Each unit test does a connect,
some commands and a disconnect.

> You may want to look at Quarry's ( way of
> handling GTP.  It can be used asynchronously and the main program does
> it that way.  The simple test in `src/gtp/gtp-test.c' demonstrates
> setting up the pipes, connecting to an engine and printing basic info.

Thanks. I've been studying the code. There were a couple of things I
wasn't doing (and that oracle.c isn't doing either):
  1. Set FD_CLOEXEC  [1]
  2. Closing the unused pipes [2]

But they didn't help. In fact after these changes it always failed on
the 3rd test, not just sometimes. But I think that was coincidence as it
 is back to failing only sometimes again.

I also noticed you don't seem to have a \n after the commands you send.
So I tried stripping the \n off in my program, but then nothing works.
So I guess I'm mis-reading your code and the \n is required?

So I'll try running with a debugger to see if I can track it down.


P.S. You have a few lines like "assert(pipe(engine_in_pipe) == 0);". I
guess in a test program this is academic and therefore just programmer
style, but the code won't work with asserts disabled.

[1]: line 108:
      int open_max = sysconf(_SC_OPEN_MAX);

      for (descriptor = 0; descriptor < open_max; descriptor++) {
        if (descriptor != STDERR_FILENO)
          fcntl(descriptor, F_SETFD, FD_CLOEXEC);

[2]: line 124:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]