coroipc_overview.8 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 NAME
  36. coroipc_overview \- Overview of coroipc libraries
  37. .SH OVERVIEW
  38. The coroipcs and coroipcc libraries provide a generically reusable very high
  39. performance shared memory IPC sytem for client and service applications.
  40. It supports many features including:
  41. .PP
  42. 65536 user services and 65536 command ids per service.
  43. .PP
  44. Shared memory implementation for very high performance.
  45. .PP
  46. A synchronous request/response channel and asynchronous response channel
  47. per ipc connection.
  48. .PP
  49. User defined private data per IPC connection.
  50. .PP
  51. Ability to call a function per service on ipc connection and disconnection.
  52. .PP
  53. Authenticated IPC connection with ability for developer to define which
  54. UIDs and GIDs are valid at connection time.
  55. .PP
  56. Fully abstracted poll system so that any poll library may be used.
  57. .PP
  58. User defined selector for determining the proper function to call per
  59. service and id.
  60. .SH Description of the libraries
  61. There are two shared libraries available for developing IPC client applications.
  62. The first library is coroipcs.so which is responsible for the server
  63. implementation. This library should be linked with the server and then
  64. initialized with coroipcs_init(3).
  65. Once the library is initialized, it will provide service to coroipcc.so library
  66. users.
  67. The second library is coroipcc.so which is responsible for the client
  68. implementation. This library should be linked with the client and requires
  69. no initialization. This library provides communication functions for sending
  70. and receiving synchronous requests, and also reading asynchronous message
  71. requests from the server.
  72. .SH Initializing the coroipcs library
  73. To use the coroipcs library, the developer creates a coroipcs_init_state
  74. structure and populates it with function names. The functions do various
  75. operations described in coroipcs_init(3) man page. Not all operations must
  76. be specified. If some are missing, the corosync ipcs library will
  77. automatically populate the structure with internal versions which provide
  78. basic functionality.
  79. .SH Communicating with the coroipcc clients
  80. Every ipc connection is represented by a void * pointer which uniquely
  81. identifies the data set for the IPC connection. Each IPC connection also
  82. contains user defined private data. To obtain this private data pointer, the
  83. function coroipcs_private_data_get(3) function can be called.
  84. There are two channels for communication. The primary channel is the
  85. synchronous request/response channel. Another channel is available for out of
  86. band asynchronous responses from the server.
  87. To send a response on the syncronous channel, coroipcs_response_send(3) or
  88. coroipcs_response_iov_send(3) should be used. To send a message on the
  89. asynchronous channel, coroipcs_dispatch_send(3) or coroipc_dispatch_iov_send(3)
  90. should be used.
  91. .SH The abstracted poll system
  92. There are many different poll systems in use in applications. They are usually
  93. intricately tied up in the implementation of the application and each provide
  94. different APIs and functionality. To manage this, the coroipcs library
  95. provides callbacks in coroipcs_init(3) which should be called when a new
  96. connection should be added for accept system calls or to dispatch messages.
  97. These callbacks add the relevant fd to the application's poll system. When the
  98. application poll system triggers the callback registered by the user defined
  99. poll adding functions, they then call either coroipc_handler_accept(3) or
  100. coroipc_handler_dispatch(3).
  101. .SH Initializing the coroipcc library
  102. No initialization is required in the coroipcc library.
  103. .SH Lifecycle of an IPC connection.
  104. An IPC connection is made to the server with coroipcc_service_connect(3). This
  105. function connects to the server and requests channels be created for
  106. communication. To disconnect, the client either exits or executes the
  107. function coroipcc_service_disconnect(3).
  108. .SH Synchronous communication
  109. There are two functions for sending a request and receiving a response. The
  110. first function coroipcc_msg_send_reply_receive(3) sends an iovector request
  111. and receives a response. This function copies the response into the response
  112. buffer. the second function coroipcc_msg_end_reply_receive_in_buf(3) does not
  113. copy the response buffer and allows for zero-copy reading of the response
  114. when the lifetime of the response buffer is known.
  115. .SH Asynchronous communication
  116. The coroipcc_dispatch_recv(3) function receives an out-of-band asyncronous
  117. message. Unlike the synchronous communication channel, the asynchronous
  118. messages are queued and can provide very high out-of-band performance.
  119. To determine when to call coroipcc_dispatch_recv(3) the corosync_fd_get(3) call
  120. is used to obtain a file descriptor used in the poll(2) or select(2) system
  121. calls.
  122. Finally the current dispatch flow control state can be obtained with
  123. coroipcc_flow_control_get(3).
  124. .SH Performance
  125. The ipc system is tuned for very high performance while also being comletely
  126. abstracted from the underlying poll mechanism and any internalisms required
  127. by the server. The ipc system achieves such high performance by using shared
  128. memory as oppossed to slower techniques such as UNIX_PF sockets.
  129. We intend to do further development to allow syncronous requests to return
  130. messages in an asyncronous way to avoid blocking involved in the syncronous
  131. request/response model used today for higher throughput in some use cases.
  132. .SH Security
  133. The ipc system uses default operating system security mechanics to ensure
  134. ipc connections are validated. A callback used with coroipcs_init(3) is called
  135. for every new ipc connection with the parameters of UID and GID. The callback
  136. then determines if the UID and GID are authenticated for communication. More
  137. about this topic can be viewed in the coroipcs_init(3) man page.
  138. .SH "SEE ALSO"
  139. .BR coroipcs_ipc_init (3),
  140. .BR coroipcs_ipc_exit (3),
  141. .BR coroipcs_private_data_get (3),
  142. .BR coroipcs_respone_send (3),
  143. .BR coroipcs_response_iov_send (3),
  144. .BR coroipcs_dispatch_send (3),
  145. .BR coroipcs_dispatch_iov_send (3),
  146. .BR coroipcs_refcount_inc (3),
  147. .BR coroipcs_refcount_dec (3),
  148. .BR coroipcs_handler_accept (3),
  149. .BR coroipcs_handler_dispatch (3),
  150. .BR cooripcc_service_connect (3),
  151. .BR coroipcc_service_disconnect (3),
  152. .BR coroipcc_msg_send_reply_receive (3),
  153. .BR coroipcc_msg_send_reply_receive_in_buf (3),
  154. .BR coroipcc_dispatch_recv (3),
  155. .BR coroipcc_fd_get(3),
  156. .BR coroipcc_dispatch_flow_control_get (3)