coroipc_overview.8 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. .\"/*
  2. .\" * Copyright (c) 2009 Red Hat, Inc.
  3. .\" *
  4. .\" * All rights reserved.
  5. .\" *
  6. .\" * Author: Steven Dake (sdake@redhat.com)
  7. .\" *
  8. .\" * This software licensed under BSD license, the text of which follows:
  9. .\" *
  10. .\" * Redistribution and use in source and binary forms, with or without
  11. .\" * modification, are permitted provided that the following conditions are met:
  12. .\" *
  13. .\" * - Redistributions of source code must retain the above copyright notice,
  14. .\" * this list of conditions and the following disclaimer.
  15. .\" * - Redistributions in binary form must reproduce the above copyright notice,
  16. .\" * this list of conditions and the following disclaimer in the documentation
  17. .\" * and/or other materials provided with the distribution.
  18. .\" * - Neither the name of the MontaVista Software, Inc. nor the names of its
  19. .\" * contributors may be used to endorse or promote products derived from this
  20. .\" * software without specific prior written permission.
  21. .\" *
  22. .\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. .\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. .\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. .\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. .\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. .\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. .\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. .\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. .\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. .\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. .\" * THE POSSIBILITY OF SUCH DAMAGE.
  33. .\" */
  34. .TH COROIPC_OVERVIEW 8 2009-03-21 "corosync Man Page" "Corosync Cluster Engine Programmer's Manual"
  35. .SH OVERVIEW
  36. The coroipcs and coroipcc libraries provide a generically reusable very high
  37. performance shared memory IPC sytem for client and service applications.
  38. It supports many features including:
  39. .PP
  40. 65536 user services and 65536 command ids per service.
  41. .PP
  42. Shared memory implementation for very high performance.
  43. .PP
  44. A synchronous request/response channel and asynchronous response channel
  45. per ipc connection.
  46. .PP
  47. User defined private data per IPC connection.
  48. .PP
  49. Ability to call a function per service on ipc connection and disconnection.
  50. .PP
  51. Authenticated IPC connection with ability for developer to define which
  52. UIDs and GIDs are valid at connection time.
  53. .PP
  54. Fully abstracted poll system so that any poll library may be used.
  55. .PP
  56. User defined selector for determining the proper function to call per
  57. service and id.
  58. .SH Description of the libraries
  59. There are two shared libraries available for developing IPC client applications.
  60. The first library is coroipcs.so which is responsible for the server
  61. implementation. This library should be linked with the server and then
  62. initialized with coroipcs_init(3).
  63. Once the library is initialized, it will provide service to coroipcc.so library
  64. users.
  65. The second library is coroipcc.so which is responsible for the client
  66. implementation. This library should be linked with the client and requires
  67. no initialization. This library provides communication functions for sending
  68. and receiving synchronous requests, and also reading asynchronous message
  69. requests from the server.
  70. .SH Initializing the coroipcs library
  71. To use the coroipcs library, the developer creates a coroipcs_init_state
  72. structure and populates it with function names. The functions do various
  73. operations described in coroipcs_init(3) man page. Not all operations must
  74. be specified. If some are missing, the corosync ipcs library will
  75. automatically populate the structure with internal versions which provide
  76. basic functionality.
  77. .SH Communicating with the coroipcc clients
  78. Every ipc connection is represented by a void * pointer which uniquely
  79. identifies the data set for the IPC connection. Each IPC connection also
  80. contains user defined private data. To obtain this private data pointer, the
  81. function coroipcs_private_data_get(3) function can be called.
  82. There are two channels for communication. The primary channel is the
  83. synchronous request/response channel. Another channel is available for out of
  84. band asynchronous responses from the server.
  85. To send a response on the syncronous channel, coroipcs_response_send(3) or
  86. coroipcs_response_iov_send(3) should be used. To send a message on the
  87. asynchronous channel, coroipcs_dispatch_send(3) or coroipc_dispatch_iov_send(3)
  88. should be used.
  89. .SH The abstracted poll system
  90. There are many different poll systems in use in applications. They are usually
  91. intricately tied up in the implementation of the application and each provide
  92. different APIs and functionality. To manage this, the coroipcs library
  93. provides callbacks in coroipcs_init(3) which should be called when a new
  94. connection should be added for accept system calls or to dispatch messages.
  95. These callbacks add the relevant fd to the application's poll system. When the
  96. application poll system triggers the callback registered by the user defined
  97. poll adding functions, they then call either coroipc_handler_accept(3) or
  98. coroipc_handler_dispatch(3).
  99. .SH Initializing the coroipcc library
  100. No initialization is required in the coroipcc library.
  101. .SH Lifecycle of an IPC connection.
  102. An IPC connection is made to the server with coroipcc_service_connect(3). This
  103. function connects to the server and requests channels be created for
  104. communication. To disconnect, the client either exits or executes the
  105. function coroipcc_service_disconnect(3).
  106. .SH Synchronous communication
  107. There are two functions for sending a request and receiving a response. The
  108. first function coroipcc_msg_send_reply_receive(3) sends an iovector request
  109. and receives a response. This function copies the response into the response
  110. buffer. the second function coroipcc_msg_end_reply_receive_in_buf(3) does not
  111. copy the response buffer and allows for zero-copy reading of the response
  112. when the lifetime of the response buffer is known.
  113. .SH Asynchronous communication
  114. The coroipcc_dispatch_recv(3) function receives an out-of-band asyncronous
  115. message. Unlike the synchronous communication channel, the asynchronous
  116. messages are queued and can provide very high out-of-band performance.
  117. To determine when to call coroipcc_dispatch_recv(3) the corosync_fd_get(3) call
  118. is used to obtain a file descriptor used in the poll(2) or select(2) system
  119. calls.
  120. Finally the current dispatch flow control state can be obtained with
  121. coroipcc_flow_control_get(3).
  122. .SH Performance
  123. The ipc system is tuned for very high performance while also being comletely
  124. abstracted from the underlying poll mechanism and any internalisms required
  125. by the server. The ipc system achieves such high performance by using shared
  126. memory as oppossed to slower techniques such as UNIX_PF sockets.
  127. We intend to do further development to allow syncronous requests to return
  128. messages in an asyncronous way to avoid blocking involved in the syncronous
  129. request/response model used today for higher throughput in some use cases.
  130. .SH Security
  131. The ipc system uses default operating system security mechanics to ensure
  132. ipc connections are validated. A callback used with coroipcs_init(3) is called
  133. for every new ipc connection with the parameters of UID and GID. The callback
  134. then determines if the UID and GID are authenticated for communication. More
  135. about this topic can be viewed in the coroipcs_init(3) man page.
  136. .SH "SEE ALSO"
  137. .BR coroipcs_ipc_init (3),
  138. .BR coroipcs_ipc_exit (3),
  139. .BR coroipcs_private_data_get (3),
  140. .BR coroipcs_respone_send (3),
  141. .BR coroipcs_response_iov_send (3),
  142. .BR coroipcs_dispatch_send (3),
  143. .BR coroipcs_dispatch_iov_send (3),
  144. .BR coroipcs_refcount_inc (3),
  145. .BR coroipcs_refcount_dec (3),
  146. .BR coroipcs_handler_accept (3),
  147. .BR coroipcs_handler_dispatch (3),
  148. .BR cooripcc_service_connect (3),
  149. .BR coroipcc_service_disconnect (3),
  150. .BR coroipcc_msg_send_reply_receive (3),
  151. .BR coroipcc_msg_send_reply_receive_in_buf (3),
  152. .BR coroipcc_dispatch_recv (3),
  153. .BR coroipcc_fd_get(3),
  154. .BR coroipcc_dispatch_flow_control_get (3)