1xparace(3)                    SAORD Documentation                   xparace(3)
2
3
4

NAME

6       XPA Race Conditions
7

SYNOPSIS

9       Potential XPA race conditions and how to avoid them.
10

DESCRIPTION

12       Currently, there is only one known circumstance in which XPA can get
13       (temporarily) deadlocked in a race condition: if two or more XPA
14       servers send messages to one another using an XPA client routine such
15       as XPASet(), they can deadlock while each waits for the other server to
16       respond.  (This can happen if the servers call XPAPoll() with a time
17       limit, and send messages in between the polling call.)  The reason this
18       happens is that both client routines send a string to the other server
19       to establish the handshake and then wait for the server response. Since
20       each client is waiting for a response, neither is able to enter its
21       event-handling loop and respond to the other's request. This deadlock
22       will continue until one of the timeout periods expire, at which point
23       an error condition will be triggered and the timed-out server will
24       return to its event loop.
25
26       Starting with version 2.1.6, this rare race condition can be avoided by
27       setting the XPA_IOCALLSXPA environment variable for servers that will
28       make client calls. Setting this variable causes all XPA socket IO calls
29       to process outstanding XPA requests whenever the primary socket is not
30       ready for IO. This means that a server making a client call will
31       (recursively) process incoming server requests while waiting for client
32       completion. It also means that a server callback routine can handle
33       incoming XPA messages if it makes its own XPA call.  The semi-public
34       routine oldvalue=XPAIOCallsXPA(newvalue) can be used to turn this
35       behavior off and on temporarily. Passing a 0 will turn off IO
36       processing, 1 will turn it back on. The old value is returned by the
37       call.
38
39       By default, the XPA_IOCALLSXPA option is turned off, because we judge
40       that the added code complication and overhead involved will not be
41       justified by the amount of its use.  Moreover, processing XPA requests
42       within socket IO can lead to non-intuitive results, since incoming
43       server requests will not necessarily be processed to completion in the
44       order in which they are received.
45
46       Aside from setting XPA_IOCALLSXPA, the simplest way to avoid this race
47       condition is to multi-process: when you want to send a client message,
48       simply start a separate process to call the client routine, so that the
49       server is not stopped. It probably is fastest and easiest to use fork()
50       and then have the child call the client routine and exit. But you also
51       can use either the system() or popen() routine to start one of the
52       command line programs and do the same thing. Alternatively, you can use
53       XPA's internal launch() routine instead of system(). Based on fork()
54       and exec(), this routine is more secure than system() because it does
55       not call /bin/sh.
56
57       Starting with version 2.1.5, you also can send an XPAInfo() message
58       with the mode string "ack=false". This will cause the client to send a
59       message to the server and then exit without waiting for any return
60       message from the server. This UDP-like behavior will avoid the server
61       deadlock when sending short XPAInfo messages.
62

SEE ALSO

64       See xpa(n) for a list of XPA help pages
65
66
67
68version 2.1.15                   July 23, 2013                      xparace(3)
Impressum