[omniORB] socket descriptors, ownership and threading

Jakob Happach mrfynn at gmx.net
Wed Oct 22 15:10:34 BST 2008


Hello,

currently I'm trying to establish an omniORB for a new embedded system.

I have already made experiences with porting omniORB 3.0.4 to a older version of this operating system.

In both operating system versions the process model is a very simple one.

There are only processes (with priorities from 0 being highest to 31 being lowest priority).
Creating a posix process (posix support is available) results in creating a process with a special system predefined priority (for posix processes). There is no timeslice based scheduling (first come first serve, prority based).

In the new version of the operating system many enhancements regarding memory/filedescriptor ownership security were made.

When creating a file descriptors, the creating process is registered as owner of the handle. Thus calls of other processes using this filehandle will result in an error like EBADF.

The system handles socket descriptors the same way as file descriptors.

This means after creating a socket endpoint with the socket() call, the returned descriptor is bound to the calling process.

Trying to get omniORB 3.0.4 to operate fails as soon as the tcpSocketRendezvouser::run_undetached() call for the first incoming rope tries to call ::accept().

However there is a possibility in the operating system to forward a socket/file descriptor to another process:
- Both processes need to know each other via process handles.
- The owner process can forward a descriptor to a known receiver process. (Underlying an interprocess message is sent then from owner to receiver.)
- The receiver process has to wait for the sent descriptor.

Using a simple code like this ownership is transferred:
... GLOBAL ...
// getting sender process id from somwhere
PROCESS from;

... PROCESS A ...
pthread_t Thread;
if(pthread_create(&Thread, NULL, &ThreadB, (void *)"ThreadB") != 0)
{
   std::cout << "Starting ThreadB failed!" << std::endl;
}
else
{
   int iRes = 0;
   from = CurrentProcess();
   if ((iRes = DonateFD( pd_rendezvous, Thread))!=0)
   {
       std::cout << "DonateFD() is " << iRes << std::endl;
    }
}

... PROCESS B ...
pd_rendezvous = ReceiveFD(from);
//pd_rendezvous is now a valid socket descriptor


As far as I am familiar with omniORB 3.0.4 I think it is a better idea to start with omniORB 4.1.3 as it is the more actual an supported version (omniORB 3.0.4 worked however perfectly for the old embedded system).

As I have already almosted adapted the omniORB 4.1.3 I now face the problem of not knowing exactly the thread model of the new omniORB good enough to know if the are different threads used for creating, using and destroying the sockets.


Currently I face the following questions:

Are different threads used for creating, using and destroying sockets?

Which threads are used for creating, using and destroying the sockets.

Where a these threads created?

Where would be the best points to forward a socket descriptor ownership? 

Any hints or guesses are greatly appreciated!

Thanks a lot in advance!
Jakob



More information about the omniORB-list mailing list