[comp.windows.x] shared memory extension

trummel@island.COM (Keith Trummel) (06/15/91)

I am using the shared memory extension to X (MIT-SHM) which allows the client
and server to use XImages and Pixmaps in shared memory.  I want my program
to take advantage of this extension if it exists, but work properly in 
environments where it is not supported.  I use the function XShmQueryVersion 
to see if the server supports it, but I have the following problem.  If the
server supports this extension, but my client is running on a different
machine than the server I obviously can't take advantage of it.  So my 
question is how do I reliably tell if my client and the server are running 
on the same machine?

By the way, is it a bug that XShmQueryVersion says it supports the shared 
memory extension when you are running across the network?  i.e should 
XShmQueryVersion tell you if it can support shared memory for *some* client 
or for the client with the specified connection to the server?

				Keith Trummel
				Island Graphics Corporation
				San Rafael,  CA
				{sun,uunet}!island!trummel
				trummel@island.com
-- 
				Keith Trummel
				Island Graphics Corporation
				{sun,uunet}!island!trummel
				trummel@island.com

neideck@kaputt.enet.dec.com (Burkhard Neidecker-Lutz) (06/17/91)

The XShmQueryExtension call has no way of actually knowing whether it
will be able to honor the following requests for MITSHM connects
to a server other than whether the server supports the extension
as such. It's pretty difficult to tell whether the application
runs on the same host (don't suggest looking in IP-specific structures
to tell, I might connect via a DECnet link...). 

Why ? Because even if it knew you are on the same machine, you
still might be unable to actually get what you request (true of
X resources in general, but much more likely so in the case of MITSHM).

At least on my variant of UNIX, the number of shared memory segments 
a process (and hence, the X server) can have, is limited to a fairly
small number, so after a few connects, you run out of slots to attach
the client to the server.

The approach we used finally was to ask the server if it offered
MITSHM and then setting the XErrorHandler around the actual allocation.
Instead of crashing we would get to know silently whether we failed
(our error handler set's a flag) and could take appropriate action
(i.e. fall back to the no-MITSHM) case. Ugly, but very robust.


			Burkhard Neidecker-Lutz, Digital Equipment Corp.
			CEC Karlsruhe, Project NESTOR