2002-07-20
----------
Okay, we can determine that the fd stored against domid IS connected
to a service of type SERVICE.  What we cannot do is verify that it is 
connected to the expected DOMAIN!

(ie two remote domains A and B are connected on fd's 4 and 5.
 Both domains drop.  The fd's are still associated with domains A and B.
 We send a message to domain B, which gets reconnected but with fd 4.
 We then send a message to domain A.  The fd against this domain is the
 stale '4'.  When we do the above validation, we discover that fd 4 is
 connected to a remote domain, and being handled by service SERVICE.
 But we THINK it's connected to domain A, when in fact it's connected to
 domain B ! )

A fix would be to maintain some sort of mapping between fd and Domain.
We've got a mapping from domain -> fd, and the reverse map will verify
that the connection really is valid.

An array of MAX_FDS (netengine/sesssions.h) chars will allow for up to
256 connected domains.  Use short for 65536, or longs for 2^32.
If we forget trying to keep the memory use down, using longs would
offer the best performance.

If the FD we have is NOT connected to the Domain we expect, then we need to
clear the fd against the domain and do a re-connect to get an fd that *is*
connected to that domain.

ie:
    session_id = -1;
    i_dom_array[domid].session_id = -1;

  .. code then detects session_id == -1 and performs a re-connect ..

  see domain_connect:dbridge.c


2002-06-17
----------
__gw_complete_request MUST be done once we've finished with a Domain message
(either a Request or a Response).
This is NOT being done yet as the code to send a message is only half in place,
and consequently there is:
1. A memory leak
2. The service usage (done) counter is not being incremented.


2002-06-10
----------
GWDBridge spins quite horrible, alternating between msgrecv and select, doing
semops along the way... Hmm...
We should block on msgrcv if all sessions are in the Idle phase AND there are
no events pending.
msgrcv should not block too long though, as we need to periodically check that
the connections to remote domains have not been lost.
Setting an alarm for 5 seconds or similar to break out of __gw_receive_request
is probably a good idea.
