_XAllocID question

Jamey Sharp jamey at minilop.net
Mon May 22 11:50:38 PDT 2006


On Mon, May 22, 2006 at 09:39:26AM +0200, Wojciech Kromer wrote:
> Why there is a code:
>    if (id != 0x10000000) {
>     ....
>  }
> resource_mask and resource_max are  much smaller than  0x10000000

It's being used as a sentinel value, to prevent Xlib from reporting this
error more than once.

It seems like a strange sentinel value though. The protocol only
guarantees that the top three bits of a valid XID are 0, so I think
values up to 0x1fffffff ought to be valid XIDs. Perhaps this should have
been 0x20000000 or higher? I'd have picked (unsigned) -1, I guess.

> I'm not sure how _XAllocID  should work.
> Could anyone explain me it, or send a link to documentation?
> Where those IDs are de-allocated ?

You should probably read the core protocol documentation first if you
want to understand this. The specific kinds of XIDs -- WINDOW, PIXMAP,
GCONTEXT, etc. -- all have both Create and Free requests -- for example,
CreatePixmap/FreePixmap and CreateGC/FreeGC. Besides allocating and
freeing structures server-side, these requests also associate or
disassociate a particular XID with the structure.

The client (Xlib in this case) maintains a sort of simple cache of which
XIDs are available, but this is conservative: more XIDs are available
than the client is aware of. So eventually the client has to ask the
server to tell it again which XIDs are free, and that's what the XC-MISC
extension is for. My X server hands out an initial batch of 2 million
XIDs, so for most applications it takes a while before they have to
request a new batch.

> _XIDHandler can be called only once, and Ican't find any other code 
> changing dpy->resource_id.

Why do you think it can be called only once? I haven't inspected that
code carefully but it looks like _XIDHandler can be called every time
the client runs out of XIDs.

--Jamey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg/attachments/20060522/f829a29f/attachment.pgp>


More information about the xorg mailing list