Subject Hanging by a Thread
Author inoffensive_2006
Hi Folks:

I'm developing an application on Window's XP media,
a dual core AMD, with Visual C++ 6.0. Firebird 2.0.1
Super Server and the current IBPP. The database is
running on the same machine as the application, but
I'd like to give users the option of running Firebird
on remote machines.

The app needs to be able to run on any computer
with a newer version of Windows.

My application needs to share records between
independent processes. So I'm saving a few columns
of each row of the largest table in paged backed
file mapped nodes of a binary tree. "Page Backed"
means it's in shared memory, and not a disk file.

Loading this table from the database, withd all
of the overhead of manipulating the mapped nodes,
slows the IO. So I want this loaded by a thread,
while the app's main thread is setting up, with
other queries on the database, dialogs, and user
log ins.

Sometimes the thread to fill the mapped memory
tree runs fine, and sometimes the thread seems to
freeze.

The first task the thread performs is a count
of the records in the database. Then it runs
a SELECT on a small number of columns of the
table to fill the mapped tree.

The thread starts it's own transaction, and
gets a count of the number of rows in the table
with this SQL

The SQL for this is:

SELECT
COUNT(*)
FROM
CON;

and these IBPP statemes:

IBPP::Statement st;

st = IBPP::StatementFactory(database_id,
selected_transaction_ptr->
transaction);

st->Execute(sql_string.c_str());

int st_fetch_val = st->Fetch();

and that's it! Stepping through with the
debugger shows that the Fetch never returns.

The thread doesn't always freeze, but when it
does, it seems to always be in the Fetch() call.

Removing the multi-thread, and calling the
same function that runs the SQL from the main
thread of the application has resulted in code
that has never frozen.

The app fires off the thread and the main body
of code performs selects on some tables, including
the CON table, sets up dialogs in the display and
waits for user input, which may bring up a dialog
that needs the records the thread is selecting.
I'm working on a popup that will indicate to the
user the progress of the data being read.

I'm probably doing something wrong. This is
the first multithreaded app I've designed. I'm
using Firebird out of the box, perhaps there is
some configuration issue I don't appreciate.

Helen's book doesn't say much on the subject
of threads, but a perusal of this forum's archives
show that the subject has come up before.

From that discussion, I've added "localhost:"
to the front of the database name, the first time
I tried that it worked, but latter attempts still
freeze.

Any ideas, or suggestions on what I should try?

Thanks
Larry