The client API implementation is contained in fserv-client.c. It abstracts away the details of creating connections and exchanging messages in order to perform Fserv operations.
The client creates an LWMsgPeer structure and connects it to the local IPC server. After this is done, any number of concurrent calls can safely be dispatched to the server through this structure. Therefore, a single global instance is lazily initialized in fserv_construct()
using the pthread_once()
mechanism.
Before establishing the connection, we must first create a protocol structure which describes the protocol the peer node will speak. A protocol structure allows one or more protocol specifications to be combined together. First, the structure is created:
The protocol specification is then added:
We create the peer structure, passing in our protocol:
Now we can add an endpoint to connect to:
Finally, we connect the peer node to the server:
Connecting to the server gives us a session which can be used for handle management later.
To disconnect from the server, the client simply disconnects the peer structure and then deletes it:
Opening a file involves making a call to the server. First, we acquire a call handle from the peer structure:
The input parameters to the call are initialized:
The call can now be dispatched, sending the input parameters to the server and receiving back the output parameters in a single operation:
If the call succeeds, out.tag
is set to the type of the call result and out.data
is set to the result data. The function then checks what kind of result it received. If it received a normal open response, it returns the file handle to the caller. The data is nulled out of the parameters structure so that it is not freed later on. If it received a failure response, it extracts the error code and returns the error to the caller.
Before the function returns, it needs to clean up all resources allocated during the call. Any output parameters from the call that we have not saved are destroyed, and then the call handle is released.
Likewise Message Library, part of the Likewise platform
Copyright © 2020 Likewise Software. All rights reserved.