Contenues dans
Trouver plus de documentationRessources d'assistance comprises | Télécharger cet ouvrage au format PDF (911 Ko)
Appendix D Frequently Asked QuestionsThis appendix contains answers to the following questions about the ToolTalk service:
QuestionsThe following frequently asked questions contain additional information about ToolTalk services. What is the ToolTalk service?The ToolTalk service enables independent applications to communicate with each other without having direct knowledge of each other. Applications create and send ToolTalk messages to communicate with each other. The ToolTalk service receives these messages, determines the recipients, and then delivers the messages to the appropriate applications. Is the ToolTalk Service the Sun implementation of the Common Object Request Broker Architecture (CORBA)?No. The ToolTalk service is not the Sun CORBA-compliant Object Request Broker (ROB). The ToolTalk service was designed and shipped in 1991 — before the Object Management Group (OMG) CORBA specification was defined. The Sun CORBA-compliant ORB is the Distributed Object Management Facility (DOMF), which is part of the Sun Project DOE product. Sun is publicly committed to support the ToolTalk API running on the DOMF when the DOMF becomes generally available as part of Solaris. Applications that use the ToolTalk messaging service today will transition to the distributed object environment of the future. What files are part of the ToolTalk service?The ToolTalk files are found in the /usr/dt/bin, lib, and include/Tt, directories, as well as in /usr/openwin/bin, lib, include/desktop, and man directories. The reason for this is historical. ToolTalk existed before the Common Desktop Environment (CDE) and was shipped with Solaris in the /usr/openwin directory structure. When CDE was released, ToolTalk was visible from the /usr/dt directory structure using symbolic links, but was still actually installed in /usr/openwin. On a Solaris 2.5 or compatible system that has CDE installed, you will find that the ToolTalk files in /usr/dt are symbolic links to /usr/openwin. On a Solaris 2.4 or compatible system with CDE installed, you will find two different complete versions of ToolTalk installed: one in /usr/dt and one in /usr/openwin. However, only the ToolTalk in /usr/dt will work with CDE. Table D–1 describes the files. Table D–1 ToolTalk Files
Where is the initial X-based ttsession started?The first call to tt_open automatically starts ttsession if no ttsession is running. However, the /usr/dt/bin/Xsession file contains an entry such as the following, which will start a ttsession at login time automatically if you are using /usr/dt/bin/dtlogin:
Where is rpc.ttdbserverd started?The /etc/inet/inetd.conf file contains an entry similar to the following:
Where are the ToolTalk type databases stored?The environment variable
Note – The type files are read in reverse order of This environment variable also tells the ToolTalk service where to search for database server redirection files. The default locations are listed in Table D–2. Table D–2 Default Locations of ToolTalk Types Database
Do I need X Windows to use the ToolTalk service?The ToolTalk service does not use X messages or protocols to deliver messages. The ToolTalk service is only associated with X Windows if you run an X session. When you run an X session, the session name is advertised as a property
(named If there is no X server running at all (for example, you are running
a session that consists entirely of character-mode applications running on
a dumb terminal), use a process tree session. When you
run a process tree session, the session name is advertised in the environment
variable Can I use the ToolTalk service with MIT X?Yes. However,
the Where is the session id of the X-session?To get this identifier, enter the following command:
Note – An X session is a session that advertises its session id on the How does tt_open connect to a ttsession?After some internal initialization, tt_open tries to find a ttsession.
Note – Call tt_close on this file descriptor; do not call the close function. If you call the close function on the file descriptors returned by tt_fd, your file descriptor count will rise upon successive tt_open and close calls.
After calling tt_open, when does a session actually begin?If the default session is an X session and there is no ttsession running, libtt starts one; otherwise, the ttsession must be started first in order to get the session name. If another session is attached, does the first session get killed?No. The first session will still be running. How can processes on different machines communicate using the ToolTalk service?There are two ways in which processes on different machines can communicate using the ToolTalk service.
Connecting to the Same SessionTo connect the processes to the same session, you first need to determine
a common interest for the processes (for example, a scheme that associates
a session name with the common interest of the processes) and then you need
to determine how to propagate the session name to all of the processes. The
ToolTalk service does not provide a mechanism to distribute the session address
(other than the possible advertisement of a session id on the To get a session name, you can use the command
which forks off a new session and prints its name to stdout; or you can the command:
which sets the environment variable You then need to use some mechanism to put that session name in a place where the other processes can find it. Some examples of where you can place the session name are:
Alternately, the processes can use the session name in the tt_default_session_set call to connect to that session. You could also send messages in the ttsession associated with a particular X server to advertise the newly-created ttsessions. Scoping to a NFS-mounted FileFile scoping is when a process registers a file scope pattern. The name of that session is placed on a list in rpc.ttdbserverd that is associated with the registered file. When a file-scoped message is sent, the ToolTalk service retrieves the list of sessions for the file and forwards the message to each of the sessions on the rpc.ttdbserverd list for that file. Note – To scope to a file that is NFS-mounted on the machines involved requires a file system to be NFS mounted on all the systems and rpc.ttdbserverd to be run on the NFS server. What is the purpose of tt_default_session_set?tt_default_session_set determines the ttsession to which a call to tt_open will connect. How can a process connect to more than one session?Table D–3 describes several default variables that are used when communicating with the ToolTalk service. Table D–3 Some Default Variables
If you use the API functions for getting and setting the procid, your application can switch between multiple sessions. For example,
Note – The default file and ptype are part of the current default procid. Changing the default procid also changes the default file and ptype to the default file and ptype associated with that procid. Can you start a ttsession with a known session id?No. You have to get the session id from the ToolTalk service. What information does a session id contain?The session id consists of a number of fields, including:
The format of a session id is a private interface. Do not write ToolTalk clients that depend on the format of a session id. Is there a standard way to announce that a new program has joined a session?Broadcast a notice message to notify interested processes when a new process joins a session. To observe notice messages, a process that want to be notified if a new process joins a session must register patterns to observe these notices. Note – The Desktop Services "Started" message was developed for this purpose. Where is my message going?Use the -t (trace mode) at start-up to observe how ttsession processes each message you send. You can also toggle the trace mode on and off by sending ttsession a USR1 signal; for example:
Alternatively, you can use the ttsnoop and/or tttrace utilities to monitor a message. What is the basic flow of a message?There are two types of message flow:
Session-Scoped Message FlowThe basic flow of a session-scoped message is as follows:
File-Scoped Message FlowThe basic flow of a file-scoped message is as follows:
What happens when a message arrives to my application?When a message arrives to your application, the following occurs:
For example, the following input callback:
and the following message callback:
results in the following output:
How can I differentiate between messages?You can differentiate between messages as follows:
Example D–1 Differentiating Between Messages
Can a process send a request to itself?Yes. A process can send a request that gets handled by itself. A typical pattern for this type of request is:
However, in the case where the handler and the sender are the same process, the message has already been destroyed when the reply comes back (to the same process). Any messages (such as callbacks or user data) attached to the message by the sender are also destroyed. To avoid this situation, do not destroy the message; for example:
Can I pass my own data to a function registered by tt_message_callback_add?To pass your own data to a function registered by tt_message_callback_add, use the user data cells on the message; for example:
Note – User data can only be seen in the client where the data is sent. How can I send arbitrary data in a message?The ToolTalk service does not provide a built-in way to send structs; it only provides a way to send strings, ints, and byte arrays. To send structs, use an XDR routine to turn the struct into a byte array and put the bytes in the message. To deserialize, use the same XDR routine. Can I transfer files with the ToolTalk service?No, not directly. You can however:
How are memory (byte) ordering issues handled by the ToolTalk service?The ToolTalk service allows you to place ints, strings, and byte vectors into messages. An XDR routine ensures that these data types are correct for each client. If you have data that is not one of these three data types, you must serialize the data into a byte vector before you place it into a message. Can I re-use messages?No. Messages cannot be sent multiple times with different arguments. They must be iteratively created, sent, and then destroyed. What happens when I destroy a message?When you destroy a message, you destroy the handle but not the underlying message. The underlying message is destroyed only when ToolTalk is done with it and all the external handles are destroyed. For example, if you destroy a handle to a message immediately after you send it, you will get a new handle when the reply comes back. However, once you destroy a message, the ToolTalk service will not show it to you again under any circumstances. For example, if you register a pattern to observe a request you send and then destroy the message when your pattern matches it, you will not see the message when it is in state "handled" (that is, when it is a reply). Can I have more than one handler per message?No, not currently. If you want multiple processes, you can use notices; or you can use message rejection to force the ToolTalk service to deliver the request to all the possible handlers — however, each of these handlers must actually perform some kind of operation. Can I run more than one handler of a given ptype?Yes, you can run more than one handler of a given ptype. However, the ToolTalk service does not have a concept of load balancing; that is, the ToolTalk service will choose one of the handlers and deliver additional matching messages to the chosen handler only. There are several ways to force the ToolTalk service to deliver messages to other handlers:
The ToolTalk service will not route matching messages to the process when the pattern is not registered. When you want the process to receive messages again, re-register the pattern. Note – This method causes a race condition. For example, a second message could be sent and routed to the process in the time between the first tt_message_receive call and the tt_pattern_unregister call.
Note – This method assumes that the process only registers one pattern. What value is disposition in a message?Message disposition can override the disposition specified in the static
type definition. If the message specifies the handler ptype and the message
does not match any of the static signatures, the disposition set in the message
will be the one followed. For example, if the disposition in the message is What are the message status elements?The ToolTalk service does not use message_status_string. This message component is for use by the applications. The ToolTalk service only sets the message status if a problem occurs with message delivery; otherwise, this message component is set and read in an application-dependent manner. When should I use tt_free?libtt maintains an internal storage stack from which you receive data buffers. When you call a ToolTalk API routine, any char * or void * returned points to a copy that you are responsible for freeing. Use the mark and release functions to free allocated buffers during a sequence of operations. However, the release call frees everything allocated since the corresponding mark call. If you want to store certain data that was returned by the ToolTalk service, make a copy of the data before you do any operations that may free it. What does the ptype represent?Ptypes are programmer-defined strings that name tool kinds. (You can roughly translate ptype as process type.) Each ptype can be associated with a set of patterns that describe the messages in which that particular ptype is interested and a string for the ToolTalk service to invoke when an instance of that ptype needs to be started. The main purpose of ptypes is to allow tools to express interest in messages even when no instance of the tool is actually running in the scope in which the message is sent. If a tool is able to perform a message's requested operation, or wants to be notified when a particular message is sent, it indicates this instruction in its ptype and ToolTalk will start the tool when necessary. Since the ptypes database can also be modified by the system administrator or user, the mechanism allows the site's or user's favorite tool be designated as the tool to handle a particular message. Why are my new types not recognized?ttsession reads the types database on start-up, on receipt of a USR1 signal, or when notified by a special ToolTalk message that the types databases have changed. Normally there is no need to manually update a ttsession to reread the types files. However, if you wish to force a running ttsession to reread the types databases, you may do so by sending it the USR2 signal; for example:
Is ptype information used if a process of that ptype already exists?The ToolTalk service always looks for one handler and any number of observers for every message. In this case, even though the ToolTalk service finds a handler running, it will still look through the ptypes for any observe patterns that match the message. If a ptype with an observe pattern that matches does exist and there is no process of that ptype currently running, the ToolTalk service will start a new process or queue the message (as specified in the ptype pattern or in the message). Can the ptype definition be modified to always start an instance (whether or not one is already running)?No. Messages to a ptype are blocked during start-up until the ptype
either replies to the message, or issues a tt_message_accept
call. However, the implementation of the ptype can include tt_message_reject for any request it gets that do not have a status of What does tt_ptype_declare do?When you declare the ptype, your static patterns exist in ttsession memory. When a ptype is registered by an application, the ToolTalk service also checks for otypes that mention the ptype and registers the patterns found in these otypes. To activate the static patterns, your application must call the appropriate join functions. Note – Multiple declarations by an application of the same ptype are ignored. What is
|
|
Mechanism |
Description |
Match? |
|---|---|---|
|
|
This type of addressing is “point-to-point” delivery — the message is passed directly to the receiver. You cannot monitor point-to-point messages because registered patterns are never checked. |
No matching required. |
|
|
Scans list of static signatures (sig) that have same operation (op) and collects lists of observers and potential handlers. If the sig has no arguments and no contexts If sig prototype (number, type and mode of args) have different values If the sig contexts are a subset of the contexts in the message Saves information for any static observers that require queuing. Scans through dynamic patterns and adds to lists of observers and potential handlers. To form the lists, ttsession first uses the patterns with operations, then the patterns without operations. Checks reliability, states, class, address, handler, handler ptype, scope, object, otype, sender, sender_ptype, args, contexts. Delivers to observers first (because a handler can change state). Delivers to handler with best match — if more than one handler equally “best” matches, the handler is arbitrarily chosen. |
=> Match => No Match => Match |
|
|
Checks whether the otype argument is filled in If sig has a different otype If sig has no otype & scope is different Otherwise, matches
in the same manner as for |
=> No Match => No Match |
Currently, the ToolTalk service has only two kinds of scope: session scope and file scope.
X session is sometimes referred to as a scope; however, the X session is really a session scope.
The ToolTalk types databases store the static ptype and otype definitions. These definitions declare the messages to which applications and objects respond. The ToolTalk types compiler modifies the types database when you add or change static type definitions. Upon starting, ttsession reads in these type files.
The TT_DB database is created by rpc.ttdbserverd. The tt_db directories contain the associations between files in this partition and the sessions with patterns interested in these files. It also contains all the object spec information for files in this partition.
The tt_db databases currently contain the following ten files:
The permissions for these files are set to -rw-r--r-- .
The ToolTalk database server daemon performs three major functional duties:
It stores the ToolTalk session IDs of sessions with clients that have joined a file using the tt_file_join call.
It stores file-scoped messages that are queued because the
message disposition is TT_QUEUED
and a handler that can handle the message has not yet been started.
It stores ToolTalk objects specs.
It responds to requests into the ToolTalk filename mapping API.
No.
About 100 small messages per second. Performance mainly depends on how many recipients each message has; that is, notices that do not match any pattern are the cheapest while messages that match many observers are the most expensive.
No. However, while there is no designed limitation to the size of a ToolTalk message or the number of arguments ToolTalk does copy the data several times (both from one area in the client's address space to another area, and across the RPC connection to and from the server). For example, a megabyte of data in a ToolTalk message would be copied at least 4 times:
From your storage to the ToolTalk library's storage
From the ToolTalk library to the ToolTalk server
From the ToolTalk server to the receiver's library
From the receiver's library to the final resting place.
If there are processes observing the message, even more copying will take place. In addition, no other messages for this session can be delivered during the copy time because the ttsession process is single-threaded. Therefore, if you plan to send really big chunks of data very often, you probably want to consider using a non-ToolTalk way to pass the data.
Directly to process (that is, addressing the message using TT_HANDLER) is faster than procedural messages
that match only one receiver.
The ToolTalk service does not use hardware broadcast or multicast. The message is sent directly to the ttsession process for the session (whether across the network or not). When a pattern is registered, it also is sent directly to the ttsession process. The ttsession process matches the message against all the patterns and sends the message directly to only the processes that registered patterns that match the message — if no process on another machine is interested in a message, that machine does not need to wake up and look at it.
No, the ToolTalk service is not a load-distribution mechanism. If two processes with identical patterns are registered, the ToolTalk service arbitrarily chooses one of process and delivers all matched messages to it. You can do load distribution if you unregister the pattern while the process is busy and reject any messages that may have been received before the pattern was unregistered.
Coarse numbers indicate that several 100K of working set for a sending client, ttsession, and a receiving client is required to process messages. ToolTalk memory requirements do not grow over time, as long as clients process messages in a timely manner.
When ttsession crashes, the tt_fd
becomes active and most ToolTalk API calls will return the TT_ERR_NOMP error message
No Message Passer |
Most applications assume this message means that something has happened to ttsession and will stop sending or receiving ToolTalk messages. Possible recovery from this situation may include:
Recognize the TT_ERR_NOMP
situation
Call tt_close to clean up the connection from its end
Reinitialize the ToolTalk service
Call the sequence:
tt_open, tt_default_session_join, tt_fd
Re-register all patterns and re-declare ptypes
You may need to manipulate the setting of the environment variable TT_SESSION and the value of the TT_SESSION property of the root X window (if
it exists) when you restart a crashed ttsession to take over where the last
one left off. Also, you must inform other participants of the crashed session
of the restarted session and the new session id so that they can recover.
When ttsession crashes, you will not be able to recover the following:
Patterns registered by procids in the crashed session
Outstanding requests from procids in the crashed session
Messages that were passed the tt_message_send_on_exit call by procids in the crashed session
Session props
Session-queued messages
If rpc.ttdbserverd exits unexpectedly, inetd will start a new one to replace it. Data may be temporarily
unavailable but no data will be lost. However, one or more API calls may return TT_ERR_DBAVAIL; if the call returns TT_OK, the dbserver will update the ToolTalk
databases appropriately either immediately or when a new dbserver reads the
crash recovery log.
When TCP notices that a host or a link is down, the TCP connection breaks.
When a process connection to ttsession breaks, ttsession behaves as if the
process exited. All the patterns are cleaned up, and the process will receive
the error message TT_ERR_NOMP
if it attempts to send or receive messages.
When you call tt_close, ttsession only closes the current procid. If the current procid is the last procid to close, it cleans up all the ToolTalk structures created since the tt_open call was made. You must call tt_close on the file descriptor returned by tt_fd; otherwise, your file descriptor count will rise upon successive tt_open and close calls.
Yes, delivery is reliable because messages are sent using RPC on TCP/IP.
Between a given sender and receiver, message sequence is preserved; that is, if process A first sends message M1 and then later sends message M2 and both messages are received by process B, process B will receive message M1 before it receives message M2. However, there are two special exceptions:
If process B receives message M1 and then rejects it, message M1 is redispatched to process C. In the meantime, (while process B is deciding whether to reply or reject message M1), the ToolTalk service continues its message delivery. These subsequent messages can appear to "pass" the first request.
If process B's messages are queued, it will receive its queued messages when it declares a ptype that contains the pattern which caused the queuing. However, process B may not actually receive its queued messages (in this case, message M1) until it has already received subsequent messages from process A.
These are the three kinds of authentication:
unix tells you the uid of the entity that is making an rpc call on you. The dbserver enforces security on each RPC call and uses this kind of authentication by default.
xauth uses a read-protected file in your home directory to control access to your X display (and, thus, to your ttsession).
des uses the Data Encryption Standard (DES) to ensure that processes who talk to ttsession are really who they say they are.
No. The ToolTalk service intentionally does not provide a mechanism that allows one application lock out other applications from seeing its messages.
No. The “plug-and-play” concept of the ToolTalk service allows applications to install and deinstall tools of choice that best perform a particular task. If application B responds better to protocol X than does application A, protocol X should be allowed to deinstall application A and install application B.
File-scoped queued messages are stored in a database on the same filesystem as the file to which they are scoped. The database is readable to the super-user only, and the ToolTalk database server (running as root) only gives the messages to processes owned by a user with read access on the file.
Session-scoped queued messages are stored in the address space of the ttsession that manages the session. ttsession only gives the messages to a process that has satisfied the authentication mode in which the ttsession is running.
No.
To trace your message's progress, turn on the trace output of the ttsession involved. The easiest way to do this is by using the tttrace application, but you can also send a SIGUSR1 signal to a running ttsession process by using the following command:
kill -USR1 <unix_pid_of_the_ttsession_process> |
To isolate your debugging tool, use the "process tree session" mode. This mode places the session name in an environment variable to find the ttsession process. To use this mode, do the following:
Start a new process tree session with trace mode turned on.
% ttsession -t -c $SHELL * * ttsession (version 1.3, library 1.3) * ttsession: starting % |
ttsession starts, sets the environment variable,
and forks the given command ($SHELL). You are now running
in a subshell. All the commands run from this subshell will use the ttsession
started from the command line. You can check the value of the TT_SESSION environment variable for the session
id of this new ttsession.
Inside the subshell, run the test programs:
% ./my_receiver & [1] 4532 % ./my_sender & .. and look at the output of the ttsession trace. |
Exit the subshell after testing.
If you start any tool that uses the ToolTalk service in the subshell, it uses the process tree ttsession, not the X-session ttsession, which will produce undefined results.
Yes. The ToolTalk API header file is set up to deal with C++. When you use C++, tt_c.h declares all the API calls as extern C.
No. The ToolTalk service does not allow explicit hostname qualification of pathnames. If you use a filename that contains a colon (:) symbol, the ToolTalk service searches for a filename that contains the colon symbol. The tt_message_file and tt_default_file calls return the realpath of the specified file as it appears on the machine on which you invoked the call. The ToolTalk service ensures that
If two clients file-scope to the same file on different machines, they can talk to each other without regard to how the two files are actually mounted on each machine.
A locally-valid, canonical pathname is returned back to you.
ToolTalk objects are somewhat different from what you normally encounter in typical object-oriented languages.
Otypes and inheritance are for implementation only. Two specs can be of the same otype but have different properties — they only share the operations as defined by the signatures in the otype declaration. For each signature in the otype declaration, a ptype must be designated. The designated ptype (process-type) is the 'execution engine' for this operation on an object of this otype. The file part of a spec is similar to a required property: every spec must have a file name; however, that file does not need to exist. The filename part of the spec performs several functions, including:
Allows you to specify the host and partition on which the spec will be stored.
Provides a grouping mechanism for objects.
Allows the ToolTalk-enhanced standard operating commands (such as the ttmv command) to keep the database's view of the world consistent with the real world.
Yes. The ToolTalk news group is alt.soft-sys.tooltalk. You may also find the group comp.unix.cde useful, since the Common Desktop Environment makes significant use of ToolTalk for integration of new applications, launching of application programs, and so on.