ipc.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
  1. /*
  2. * Copyright (c) 2002-2006 MontaVista Software, Inc.
  3. * Copyright (c) 2006 Red Hat, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@mvista.com)
  8. *
  9. * This software licensed under BSD license, the text of which follows:
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. * - Redistributions in binary form must reproduce the above copyright notice,
  17. * this list of conditions and the following disclaimer in the documentation
  18. * and/or other materials provided with the distribution.
  19. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  33. * THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #include <pthread.h>
  36. #include <assert.h>
  37. #include <pwd.h>
  38. #include <grp.h>
  39. #include <sys/types.h>
  40. #include <sys/poll.h>
  41. #include <sys/uio.h>
  42. #include <sys/mman.h>
  43. #include <sys/socket.h>
  44. #include <sys/un.h>
  45. #include <sys/time.h>
  46. #include <sys/resource.h>
  47. #include <netinet/in.h>
  48. #include <arpa/inet.h>
  49. #include <unistd.h>
  50. #include <fcntl.h>
  51. #include <stdlib.h>
  52. #include <stdio.h>
  53. #include <errno.h>
  54. #include <signal.h>
  55. #include <sched.h>
  56. #include <time.h>
  57. #include "../include/saAis.h"
  58. #include "../include/list.h"
  59. #include "../include/queue.h"
  60. #include "../lcr/lcr_ifact.h"
  61. #include "poll.h"
  62. #include "totempg.h"
  63. #include "totemsrp.h"
  64. #include "mempool.h"
  65. #include "mainconfig.h"
  66. #include "totemconfig.h"
  67. #include "main.h"
  68. #include "ipc.h"
  69. #include "flow.h"
  70. #include "service.h"
  71. #include "sync.h"
  72. #include "swab.h"
  73. #include "objdb.h"
  74. #include "config.h"
  75. #include "tlist.h"
  76. #define LOG_SERVICE LOG_SERVICE_IPC
  77. #include "print.h"
  78. #include "util.h"
  79. #define SERVER_BACKLOG 5
  80. /*
  81. * When there are this many entries left in a queue, turn on flow control
  82. */
  83. #define FLOW_CONTROL_ENTRIES_ENABLE 400
  84. /*
  85. * When there are this many entries in a queue, turn off flow control
  86. */
  87. #define FLOW_CONTROL_ENTRIES_DISABLE 64
  88. static unsigned int g_gid_valid = 0;
  89. static struct totem_ip_address *my_ip;
  90. static totempg_groups_handle ipc_handle;
  91. DECLARE_LIST_INIT (conn_info_list_head);
  92. static void (*ipc_serialize_lock_fn) (void);
  93. static void (*ipc_serialize_unlock_fn) (void);
  94. struct outq_item {
  95. void *msg;
  96. size_t mlen;
  97. };
  98. enum conn_state {
  99. CONN_STATE_ACTIVE,
  100. CONN_STATE_SECURITY,
  101. CONN_STATE_REQUESTED,
  102. CONN_STATE_CLOSED,
  103. CONN_STATE_DISCONNECTED
  104. };
  105. struct conn_info {
  106. int fd; /* File descriptor */
  107. unsigned int events; /* events polled for by file descriptor */
  108. enum conn_state state; /* State of this connection */
  109. pthread_t thread; /* thread identifier */
  110. pthread_attr_t thread_attr; /* thread attribute */
  111. char *inb; /* Input buffer for non-blocking reads */
  112. int inb_nextheader; /* Next message header starts here */
  113. int inb_start; /* Start location of input buffer */
  114. int inb_inuse; /* Bytes currently stored in input buffer */
  115. struct queue outq; /* Circular queue for outgoing requests */
  116. int byte_start; /* Byte to start sending from in head of queue */
  117. enum service_types service;/* Type of service so dispatch knows how to route message */
  118. int authenticated; /* Is this connection authenticated? */
  119. void *private_data; /* library connection private data */
  120. struct conn_info *conn_info_partner; /* partner connection dispatch<->response */
  121. unsigned int flow_control_handle; /* flow control identifier */
  122. unsigned int flow_control_enabled; /* flow control enabled bit */
  123. unsigned int flow_control_local_count; /* flow control local count */
  124. enum openais_flow_control flow_control; /* Does this service use IPC flow control */
  125. pthread_mutex_t flow_control_mutex;
  126. int (*lib_exit_fn) (void *conn);
  127. struct timerlist timerlist;
  128. pthread_mutex_t mutex;
  129. pthread_mutex_t *shared_mutex;
  130. struct list_head list;
  131. };
  132. static void *prioritized_poll_thread (void *conn);
  133. static int conn_info_outq_flush (struct conn_info *conn_info);
  134. static void libais_deliver (struct conn_info *conn_info);
  135. static void ipc_flow_control (struct conn_info *conn_info);
  136. /*
  137. * IPC Initializers
  138. */
  139. static int response_init_send_response (
  140. struct conn_info *conn_info,
  141. void *message);
  142. static int dispatch_init_send_response (
  143. struct conn_info *conn_info,
  144. void *message);
  145. static int (*ais_init_service[]) (struct conn_info *conn_info, void *message) = {
  146. response_init_send_response,
  147. dispatch_init_send_response
  148. };
  149. static void libais_disconnect_security (struct conn_info *conn_info)
  150. {
  151. conn_info->state = CONN_STATE_SECURITY;
  152. close (conn_info->fd);
  153. }
  154. static int response_init_send_response (
  155. struct conn_info *conn_info,
  156. void *message)
  157. {
  158. SaAisErrorT error = SA_AIS_ERR_ACCESS;
  159. uintptr_t cinfo = (uintptr_t)conn_info;
  160. mar_req_lib_response_init_t *req_lib_response_init = (mar_req_lib_response_init_t *)message;
  161. mar_res_lib_response_init_t res_lib_response_init;
  162. if (conn_info->authenticated) {
  163. conn_info->service = req_lib_response_init->resdis_header.service;
  164. error = SA_AIS_OK;
  165. }
  166. res_lib_response_init.header.size = sizeof (mar_res_lib_response_init_t);
  167. res_lib_response_init.header.id = MESSAGE_RES_INIT;
  168. res_lib_response_init.header.error = error;
  169. res_lib_response_init.conn_info = (mar_uint64_t)cinfo;
  170. openais_conn_send_response (
  171. conn_info,
  172. &res_lib_response_init,
  173. sizeof (res_lib_response_init));
  174. if (error == SA_AIS_ERR_ACCESS) {
  175. libais_disconnect_security (conn_info);
  176. return (-1);
  177. }
  178. return (0);
  179. }
  180. static int dispatch_init_send_response (
  181. struct conn_info *conn_info,
  182. void *message)
  183. {
  184. SaAisErrorT error = SA_AIS_ERR_ACCESS;
  185. uintptr_t cinfo;
  186. mar_req_lib_dispatch_init_t *req_lib_dispatch_init = (mar_req_lib_dispatch_init_t *)message;
  187. mar_res_lib_dispatch_init_t res_lib_dispatch_init;
  188. struct conn_info *msg_conn_info;
  189. if (conn_info->authenticated) {
  190. conn_info->service = req_lib_dispatch_init->resdis_header.service;
  191. if (!ais_service[req_lib_dispatch_init->resdis_header.service])
  192. error = SA_AIS_ERR_NOT_SUPPORTED;
  193. else
  194. error = SA_AIS_OK;
  195. cinfo = (uintptr_t)req_lib_dispatch_init->conn_info;
  196. conn_info->conn_info_partner = (struct conn_info *)cinfo;
  197. /* temporary fix for memory leak
  198. */
  199. pthread_mutex_destroy (conn_info->conn_info_partner->shared_mutex);
  200. free (conn_info->conn_info_partner->shared_mutex);
  201. conn_info->conn_info_partner->shared_mutex = conn_info->shared_mutex;
  202. list_add (&conn_info_list_head, &conn_info->list);
  203. list_add (&conn_info_list_head, &conn_info->conn_info_partner->list);
  204. msg_conn_info = (struct conn_info *)cinfo;
  205. msg_conn_info->conn_info_partner = conn_info;
  206. if (error == SA_AIS_OK) {
  207. int private_data_size;
  208. private_data_size = ais_service[req_lib_dispatch_init->resdis_header.service]->private_data_size;
  209. if (private_data_size) {
  210. conn_info->private_data = malloc (private_data_size);
  211. conn_info->conn_info_partner->private_data = conn_info->private_data;
  212. if (conn_info->private_data == NULL) {
  213. error = SA_AIS_ERR_NO_MEMORY;
  214. } else {
  215. memset (conn_info->private_data, 0, private_data_size);
  216. }
  217. } else {
  218. conn_info->private_data = NULL;
  219. conn_info->conn_info_partner->private_data = NULL;
  220. }
  221. }
  222. }
  223. res_lib_dispatch_init.header.size = sizeof (mar_res_lib_dispatch_init_t);
  224. res_lib_dispatch_init.header.id = MESSAGE_RES_INIT;
  225. res_lib_dispatch_init.header.error = error;
  226. openais_conn_send_response (
  227. conn_info,
  228. &res_lib_dispatch_init,
  229. sizeof (res_lib_dispatch_init));
  230. if (error == SA_AIS_ERR_ACCESS) {
  231. libais_disconnect_security (conn_info);
  232. return (-1);
  233. }
  234. if (error != SA_AIS_OK) {
  235. return (-1);
  236. }
  237. conn_info->state = CONN_STATE_ACTIVE;
  238. conn_info->conn_info_partner->state = CONN_STATE_ACTIVE;
  239. conn_info->lib_exit_fn = ais_service[conn_info->service]->lib_exit_fn;
  240. ais_service[conn_info->service]->lib_init_fn (conn_info);
  241. conn_info->flow_control = ais_service[conn_info->service]->flow_control;
  242. conn_info->conn_info_partner->flow_control = ais_service[conn_info->service]->flow_control;
  243. if (ais_service[conn_info->service]->flow_control == OPENAIS_FLOW_CONTROL_REQUIRED) {
  244. openais_flow_control_ipc_init (
  245. &conn_info->flow_control_handle,
  246. conn_info->service);
  247. }
  248. return (0);
  249. }
  250. /*
  251. * Create a connection data structure
  252. */
  253. static inline unsigned int conn_info_create (int fd) {
  254. struct conn_info *conn_info;
  255. int res;
  256. conn_info = malloc (sizeof (struct conn_info));
  257. if (conn_info == 0) {
  258. return (ENOMEM);
  259. }
  260. memset (conn_info, 0, sizeof (struct conn_info));
  261. res = queue_init (&conn_info->outq, SIZEQUEUE,
  262. sizeof (struct outq_item));
  263. if (res != 0) {
  264. free (conn_info);
  265. return (ENOMEM);
  266. }
  267. conn_info->inb = malloc (sizeof (char) * SIZEINB);
  268. if (conn_info->inb == NULL) {
  269. queue_free (&conn_info->outq);
  270. free (conn_info);
  271. return (ENOMEM);
  272. }
  273. conn_info->shared_mutex = malloc (sizeof (pthread_mutex_t));
  274. if (conn_info->shared_mutex == NULL) {
  275. free (conn_info->inb);
  276. queue_free (&conn_info->outq);
  277. free (conn_info);
  278. return (ENOMEM);
  279. }
  280. pthread_mutex_init (&conn_info->mutex, NULL);
  281. pthread_mutex_init (&conn_info->flow_control_mutex, NULL);
  282. pthread_mutex_init (conn_info->shared_mutex, NULL);
  283. list_init (&conn_info->list);
  284. conn_info->state = CONN_STATE_ACTIVE;
  285. conn_info->fd = fd;
  286. conn_info->events = POLLIN|POLLNVAL;
  287. conn_info->service = SOCKET_SERVICE_INIT;
  288. pthread_attr_init (&conn_info->thread_attr);
  289. /*
  290. * IA64 needs more stack space then other arches
  291. */
  292. #if defined(__ia64__)
  293. pthread_attr_setstacksize (&conn_info->thread_attr, 400000);
  294. #else
  295. pthread_attr_setstacksize (&conn_info->thread_attr, 200000);
  296. #endif
  297. pthread_attr_setdetachstate (&conn_info->thread_attr, PTHREAD_CREATE_DETACHED);
  298. res = pthread_create (&conn_info->thread, &conn_info->thread_attr,
  299. prioritized_poll_thread, conn_info);
  300. return (res);
  301. }
  302. static void conn_info_destroy (struct conn_info *conn_info)
  303. {
  304. struct outq_item *outq_item;
  305. /*
  306. * Free the outq queued items
  307. */
  308. while (!queue_is_empty (&conn_info->outq)) {
  309. outq_item = queue_item_get (&conn_info->outq);
  310. free (outq_item->msg);
  311. queue_item_remove (&conn_info->outq);
  312. }
  313. queue_free (&conn_info->outq);
  314. free (conn_info->inb);
  315. if (conn_info->conn_info_partner) {
  316. conn_info->conn_info_partner->conn_info_partner = NULL;
  317. }
  318. pthread_attr_destroy (&conn_info->thread_attr);
  319. pthread_mutex_destroy (&conn_info->mutex);
  320. list_del (&conn_info->list);
  321. free (conn_info);
  322. }
  323. static int libais_connection_active (struct conn_info *conn_info)
  324. {
  325. return (conn_info->state == CONN_STATE_ACTIVE);
  326. }
  327. static void libais_disconnect_request (struct conn_info *conn_info)
  328. {
  329. if (conn_info->state == CONN_STATE_ACTIVE) {
  330. conn_info->state = CONN_STATE_REQUESTED;
  331. conn_info->conn_info_partner->state = CONN_STATE_REQUESTED;
  332. }
  333. }
  334. static int libais_disconnect (struct conn_info *conn_info)
  335. {
  336. int res = 0;
  337. assert (conn_info->state != CONN_STATE_ACTIVE);
  338. if (conn_info->state == CONN_STATE_DISCONNECTED) {
  339. assert (0);
  340. }
  341. /*
  342. * Close active connections
  343. */
  344. if (conn_info->state == CONN_STATE_ACTIVE || conn_info->state == CONN_STATE_REQUESTED) {
  345. close (conn_info->fd);
  346. conn_info->state = CONN_STATE_CLOSED;
  347. close (conn_info->conn_info_partner->fd);
  348. conn_info->conn_info_partner->state = CONN_STATE_CLOSED;
  349. }
  350. /*
  351. * Note we will only call the close operation once on the first time
  352. * one of the connections is closed
  353. */
  354. if (conn_info->state == CONN_STATE_CLOSED) {
  355. if (conn_info->lib_exit_fn) {
  356. res = conn_info->lib_exit_fn (conn_info);
  357. }
  358. if (res == -1) {
  359. return (-1);
  360. }
  361. if (conn_info->conn_info_partner->lib_exit_fn) {
  362. res = conn_info->conn_info_partner->lib_exit_fn (conn_info);
  363. }
  364. if (res == -1) {
  365. return (-1);
  366. }
  367. }
  368. conn_info->state = CONN_STATE_DISCONNECTED;
  369. conn_info->conn_info_partner->state = CONN_STATE_DISCONNECTED;
  370. if (conn_info->flow_control_enabled == 1) {
  371. openais_flow_control_disable (conn_info->flow_control_handle);
  372. }
  373. return (0);
  374. }
  375. static inline void conn_info_mutex_lock (
  376. struct conn_info *conn_info,
  377. unsigned int service)
  378. {
  379. if (service == SOCKET_SERVICE_INIT) {
  380. pthread_mutex_lock (&conn_info->mutex);
  381. } else {
  382. pthread_mutex_lock (conn_info->shared_mutex);
  383. }
  384. }
  385. static inline void conn_info_mutex_unlock (
  386. struct conn_info *conn_info,
  387. unsigned int service)
  388. {
  389. if (service == SOCKET_SERVICE_INIT) {
  390. pthread_mutex_unlock (&conn_info->mutex);
  391. } else {
  392. pthread_mutex_unlock (conn_info->shared_mutex);
  393. }
  394. }
  395. /*
  396. * This thread runs in a specific thread priority mode to handle
  397. * I/O requests from the library
  398. */
  399. static void *prioritized_poll_thread (void *conn)
  400. {
  401. struct conn_info *conn_info = (struct conn_info *)conn;
  402. struct pollfd ufd;
  403. int fds;
  404. struct sched_param sched_param;
  405. int res;
  406. pthread_mutex_t *rel_mutex;
  407. unsigned int service;
  408. struct conn_info *cinfo_partner;
  409. void *private_data;
  410. sched_param.sched_priority = 1;
  411. res = pthread_setschedparam (conn_info->thread, SCHED_RR, &sched_param);
  412. ufd.fd = conn_info->fd;
  413. for (;;) {
  414. retry_poll:
  415. service = conn_info->service;
  416. ufd.events = conn_info->events;
  417. ufd.revents = 0;
  418. fds = poll (&ufd, 1, -1);
  419. conn_info_mutex_lock (conn_info, service);
  420. switch (conn_info->state) {
  421. case CONN_STATE_SECURITY:
  422. conn_info_mutex_unlock (conn_info, service);
  423. pthread_mutex_destroy (conn_info->shared_mutex);
  424. free (conn_info->shared_mutex);
  425. conn_info_destroy (conn);
  426. pthread_exit (0);
  427. break;
  428. case CONN_STATE_REQUESTED:
  429. case CONN_STATE_CLOSED:
  430. res = libais_disconnect (conn);
  431. if (res != 0) {
  432. conn_info_mutex_unlock (conn_info, service);
  433. goto retry_poll;
  434. }
  435. break;
  436. case CONN_STATE_DISCONNECTED:
  437. rel_mutex = conn_info->shared_mutex;
  438. private_data = conn_info->private_data;
  439. cinfo_partner = conn_info->conn_info_partner;
  440. conn_info_destroy (conn);
  441. if (service == SOCKET_SERVICE_INIT) {
  442. pthread_mutex_unlock (&conn_info->mutex);
  443. } else {
  444. pthread_mutex_unlock (rel_mutex);
  445. }
  446. if (cinfo_partner == NULL) {
  447. pthread_mutex_destroy (rel_mutex);
  448. free (rel_mutex);
  449. free (private_data);
  450. }
  451. pthread_exit (0);
  452. /*
  453. * !! NOTE !! this is the exit point for this thread
  454. */
  455. break;
  456. default:
  457. break;
  458. }
  459. if (fds == -1) {
  460. conn_info_mutex_unlock (conn_info, service);
  461. goto retry_poll;
  462. }
  463. ipc_serialize_lock_fn ();
  464. if (fds == 1 && ufd.revents) {
  465. if (ufd.revents & (POLLERR|POLLHUP)) {
  466. libais_disconnect_request (conn_info);
  467. conn_info_mutex_unlock (conn_info, service);
  468. ipc_serialize_unlock_fn ();
  469. continue;
  470. }
  471. if (ufd.revents & POLLOUT) {
  472. conn_info_outq_flush (conn_info);
  473. }
  474. if ((ufd.revents & POLLIN) == POLLIN) {
  475. libais_deliver (conn_info);
  476. }
  477. ipc_flow_control (conn_info);
  478. }
  479. ipc_serialize_unlock_fn ();
  480. conn_info_mutex_unlock (conn_info, service);
  481. }
  482. /*
  483. * This code never reached
  484. */
  485. return (0);
  486. }
  487. #if defined(OPENAIS_LINUX)
  488. /* SUN_LEN is broken for abstract namespace
  489. */
  490. #define AIS_SUN_LEN(a) sizeof(*(a))
  491. char *socketname = "libais.socket";
  492. #else
  493. #define AIS_SUN_LEN(a) SUN_LEN(a)
  494. char *socketname = "/var/run/libais.socket";
  495. #endif
  496. static void ipc_flow_control (struct conn_info *conn_info)
  497. {
  498. unsigned int entries_used;
  499. unsigned int entries_usedhw;
  500. unsigned int flow_control_local_count;
  501. unsigned int fcc;
  502. /*
  503. * Determine FCC variable and printing variables
  504. */
  505. entries_used = queue_used (&conn_info->outq);
  506. if (conn_info->conn_info_partner &&
  507. queue_used (&conn_info->conn_info_partner->outq) > entries_used) {
  508. entries_used = queue_used (&conn_info->conn_info_partner->outq);
  509. }
  510. entries_usedhw = queue_usedhw (&conn_info->outq);
  511. if (conn_info->conn_info_partner &&
  512. queue_usedhw (&conn_info->conn_info_partner->outq) > entries_used) {
  513. entries_usedhw = queue_usedhw (&conn_info->conn_info_partner->outq);
  514. }
  515. flow_control_local_count = conn_info->flow_control_local_count;
  516. if (conn_info->conn_info_partner &&
  517. conn_info->conn_info_partner->flow_control_local_count > flow_control_local_count) {
  518. flow_control_local_count = conn_info->conn_info_partner->flow_control_local_count;
  519. }
  520. fcc = entries_used;
  521. if (flow_control_local_count > fcc) {
  522. fcc = flow_control_local_count;
  523. }
  524. /*
  525. * IPC group-wide flow control
  526. */
  527. if (conn_info->flow_control == OPENAIS_FLOW_CONTROL_REQUIRED) {
  528. if (conn_info->flow_control_enabled == 0 &&
  529. ((fcc + FLOW_CONTROL_ENTRIES_ENABLE) > SIZEQUEUE)) {
  530. log_printf (LOG_LEVEL_NOTICE, "Enabling flow control [%d/%d] - [%d].\n",
  531. entries_usedhw, SIZEQUEUE,
  532. flow_control_local_count);
  533. openais_flow_control_enable (conn_info->flow_control_handle);
  534. conn_info->flow_control_enabled = 1;
  535. conn_info->conn_info_partner->flow_control_enabled = 1;
  536. }
  537. if (conn_info->flow_control_enabled == 1 &&
  538. fcc <= FLOW_CONTROL_ENTRIES_DISABLE) {
  539. log_printf (LOG_LEVEL_NOTICE, "Disabling flow control [%d/%d] - [%d].\n",
  540. entries_usedhw, SIZEQUEUE,
  541. flow_control_local_count);
  542. openais_flow_control_disable (conn_info->flow_control_handle);
  543. conn_info->flow_control_enabled = 0;
  544. conn_info->conn_info_partner->flow_control_enabled = 0;
  545. }
  546. }
  547. }
  548. static int conn_info_outq_flush (struct conn_info *conn_info) {
  549. struct queue *outq;
  550. int res = 0;
  551. struct outq_item *queue_item;
  552. struct msghdr msg_send;
  553. struct iovec iov_send;
  554. char *msg_addr;
  555. if (!libais_connection_active (conn_info)) {
  556. return (-1);
  557. }
  558. outq = &conn_info->outq;
  559. msg_send.msg_iov = &iov_send;
  560. msg_send.msg_name = 0;
  561. msg_send.msg_namelen = 0;
  562. msg_send.msg_iovlen = 1;
  563. msg_send.msg_control = 0;
  564. msg_send.msg_controllen = 0;
  565. msg_send.msg_flags = 0;
  566. while (!queue_is_empty (outq)) {
  567. queue_item = queue_item_get (outq);
  568. msg_addr = (char *)queue_item->msg;
  569. msg_addr = &msg_addr[conn_info->byte_start];
  570. iov_send.iov_base = msg_addr;
  571. iov_send.iov_len = queue_item->mlen - conn_info->byte_start;
  572. retry_sendmsg:
  573. res = sendmsg (conn_info->fd, &msg_send, MSG_NOSIGNAL);
  574. if (res == -1 && errno == EINTR) {
  575. goto retry_sendmsg;
  576. }
  577. if (res == -1 && errno == EAGAIN) {
  578. return (0);
  579. }
  580. if (res == -1 && errno == EPIPE) {
  581. libais_disconnect_request (conn_info);
  582. return (0);
  583. }
  584. if (res == -1) {
  585. printf ("ERRNO is %d\n", errno);
  586. assert (0); /* some other unhandled error here */
  587. }
  588. if (res + conn_info->byte_start != queue_item->mlen) {
  589. conn_info->byte_start += res;
  590. return (0);
  591. }
  592. /*
  593. * Message sent, try sending another message
  594. */
  595. queue_item_remove (outq);
  596. conn_info->byte_start = 0;
  597. free (queue_item->msg);
  598. } /* while queue not empty */
  599. if (queue_is_empty (outq)) {
  600. conn_info->events = POLLIN|POLLNVAL;
  601. }
  602. return (0);
  603. }
  604. struct res_overlay {
  605. mar_res_header_t header __attribute((aligned(8)));
  606. char buf[4096];
  607. };
  608. static void libais_deliver (struct conn_info *conn_info)
  609. {
  610. int res;
  611. mar_req_header_t *header;
  612. int service;
  613. struct msghdr msg_recv;
  614. struct iovec iov_recv;
  615. #ifdef OPENAIS_LINUX
  616. struct cmsghdr *cmsg;
  617. char cmsg_cred[CMSG_SPACE (sizeof (struct ucred))];
  618. struct ucred *cred;
  619. int on = 0;
  620. #else
  621. uid_t euid;
  622. gid_t egid;
  623. #endif
  624. int send_ok = 0;
  625. int send_ok_joined = 0;
  626. struct iovec send_ok_joined_iovec;
  627. struct res_overlay res_overlay;
  628. msg_recv.msg_iov = &iov_recv;
  629. msg_recv.msg_iovlen = 1;
  630. msg_recv.msg_name = 0;
  631. msg_recv.msg_namelen = 0;
  632. msg_recv.msg_flags = 0;
  633. if (conn_info->authenticated) {
  634. msg_recv.msg_control = 0;
  635. msg_recv.msg_controllen = 0;
  636. } else {
  637. #ifdef OPENAIS_LINUX
  638. msg_recv.msg_control = (void *)cmsg_cred;
  639. msg_recv.msg_controllen = sizeof (cmsg_cred);
  640. #else
  641. euid = -1; egid = -1;
  642. if (getpeereid(conn_info->fd, &euid, &egid) != -1 &&
  643. (euid == 0 || egid == g_gid_valid)) {
  644. conn_info->authenticated = 1;
  645. }
  646. if (conn_info->authenticated == 0) {
  647. log_printf (LOG_LEVEL_SECURITY, "Connection not authenticated because gid is %d, expecting %d\n", egid, g_gid_valid);
  648. }
  649. #endif
  650. }
  651. iov_recv.iov_base = &conn_info->inb[conn_info->inb_start];
  652. iov_recv.iov_len = (SIZEINB) - conn_info->inb_start;
  653. if (conn_info->inb_inuse == SIZEINB) {
  654. return;
  655. }
  656. retry_recv:
  657. res = recvmsg (conn_info->fd, &msg_recv, MSG_NOSIGNAL);
  658. if (res == -1 && errno == EINTR) {
  659. goto retry_recv;
  660. } else
  661. if (res == -1 && errno != EAGAIN) {
  662. return;
  663. } else
  664. if (res == 0) {
  665. return;
  666. }
  667. /*
  668. * Authenticate if this connection has not been authenticated
  669. */
  670. #ifdef OPENAIS_LINUX
  671. if (conn_info->authenticated == 0) {
  672. cmsg = CMSG_FIRSTHDR (&msg_recv);
  673. assert (cmsg);
  674. cred = (struct ucred *)CMSG_DATA (cmsg);
  675. if (cred) {
  676. if (cred->uid == 0 || cred->gid == g_gid_valid) {
  677. setsockopt(conn_info->fd, SOL_SOCKET, SO_PASSCRED, &on, sizeof (on));
  678. conn_info->authenticated = 1;
  679. }
  680. }
  681. if (conn_info->authenticated == 0) {
  682. log_printf (LOG_LEVEL_SECURITY, "Connection not authenticated because gid is %d, expecting %d\n", cred->gid, g_gid_valid);
  683. }
  684. }
  685. #endif
  686. /*
  687. * Dispatch all messages received in recvmsg that can be dispatched
  688. * sizeof (mar_req_header_t) needed at minimum to do any processing
  689. */
  690. conn_info->inb_inuse += res;
  691. conn_info->inb_start += res;
  692. while (conn_info->inb_inuse >= sizeof (mar_req_header_t) && res != -1) {
  693. header = (mar_req_header_t *)&conn_info->inb[conn_info->inb_start - conn_info->inb_inuse];
  694. if (header->size > conn_info->inb_inuse) {
  695. break;
  696. }
  697. service = conn_info->service;
  698. /*
  699. * If this service is in init phase, initialize service
  700. * else handle message using service service
  701. */
  702. if (service == SOCKET_SERVICE_INIT) {
  703. res = ais_init_service[header->id] (conn_info, header);
  704. } else {
  705. /*
  706. * Not an init service, but a standard service
  707. */
  708. if (header->id < 0 || header->id > ais_service[service]->lib_service_count) {
  709. log_printf (LOG_LEVEL_SECURITY, "Invalid header id is %d min 0 max %d\n",
  710. header->id, ais_service[service]->lib_service_count);
  711. return ;
  712. }
  713. /*
  714. * If flow control is required of the library handle, determine that
  715. * openais is not in synchronization and that totempg has room available
  716. * to queue a message, otherwise tell the library we are busy and to
  717. * try again later
  718. */
  719. send_ok_joined_iovec.iov_base = header;
  720. send_ok_joined_iovec.iov_len = header->size;
  721. send_ok_joined = totempg_groups_send_ok_joined (openais_group_handle,
  722. &send_ok_joined_iovec, 1);
  723. send_ok =
  724. (sync_primary_designated() == 1) && (
  725. (ais_service[service]->lib_service[header->id].flow_control == OPENAIS_FLOW_CONTROL_NOT_REQUIRED) ||
  726. ((ais_service[service]->lib_service[header->id].flow_control == OPENAIS_FLOW_CONTROL_REQUIRED) &&
  727. (send_ok_joined) &&
  728. (sync_in_process() == 0)));
  729. if (send_ok) {
  730. ais_service[service]->lib_service[header->id].lib_handler_fn(conn_info, header);
  731. } else {
  732. /*
  733. * Overload, tell library to retry
  734. */
  735. res_overlay.header.size =
  736. ais_service[service]->lib_service[header->id].response_size;
  737. res_overlay.header.id =
  738. ais_service[service]->lib_service[header->id].response_id;
  739. res_overlay.header.error = SA_AIS_ERR_TRY_AGAIN;
  740. openais_conn_send_response (
  741. conn_info,
  742. &res_overlay,
  743. res_overlay.header.size);
  744. }
  745. }
  746. conn_info->inb_inuse -= header->size;
  747. } /* while */
  748. if (conn_info->inb_inuse == 0) {
  749. conn_info->inb_start = 0;
  750. } else
  751. // BUG if (connections[conn_info->fd].inb_start + connections[conn_info->fd].inb_inuse >= SIZEINB) {
  752. if (conn_info->inb_start >= SIZEINB) {
  753. /*
  754. * If in buffer is full, move it back to start
  755. */
  756. memmove (conn_info->inb,
  757. &conn_info->inb[conn_info->inb_start - conn_info->inb_inuse],
  758. sizeof (char) * conn_info->inb_inuse);
  759. conn_info->inb_start = conn_info->inb_inuse;
  760. }
  761. return;
  762. }
  763. static int poll_handler_libais_accept (
  764. poll_handle handle,
  765. int fd,
  766. int revent,
  767. void *data)
  768. {
  769. socklen_t addrlen;
  770. struct sockaddr_un un_addr;
  771. int new_fd;
  772. #ifdef OPENAIS_LINUX
  773. int on = 1;
  774. #endif
  775. int res;
  776. addrlen = sizeof (struct sockaddr_un);
  777. retry_accept:
  778. new_fd = accept (fd, (struct sockaddr *)&un_addr, &addrlen);
  779. if (new_fd == -1 && errno == EINTR) {
  780. goto retry_accept;
  781. }
  782. if (new_fd == -1) {
  783. log_printf (LOG_LEVEL_ERROR, "ERROR: Could not accept Library connection: %s\n", strerror (errno));
  784. return (0); /* This is an error, but -1 would indicate disconnect from poll loop */
  785. }
  786. totemip_nosigpipe(new_fd);
  787. res = fcntl (new_fd, F_SETFL, O_NONBLOCK);
  788. if (res == -1) {
  789. log_printf (LOG_LEVEL_ERROR, "Could not set non-blocking operation on library connection: %s\n", strerror (errno));
  790. close (new_fd);
  791. return (0); /* This is an error, but -1 would indicate disconnect from poll loop */
  792. }
  793. /*
  794. * Valid accept
  795. */
  796. /*
  797. * Request credentials of sender provided by kernel
  798. */
  799. #ifdef OPENAIS_LINUX
  800. setsockopt(new_fd, SOL_SOCKET, SO_PASSCRED, &on, sizeof (on));
  801. #endif
  802. log_printf (LOG_LEVEL_DEBUG, "connection received from libais client %d.\n", new_fd);
  803. res = conn_info_create (new_fd);
  804. if (res != 0) {
  805. close (new_fd);
  806. }
  807. return (0);
  808. }
  809. /*
  810. * Exported functions
  811. */
  812. int message_source_is_local(mar_message_source_t *source)
  813. {
  814. int ret = 0;
  815. assert (source != NULL);
  816. if (source->nodeid == my_ip->nodeid) {
  817. ret = 1;
  818. }
  819. return ret;
  820. }
  821. void message_source_set (
  822. mar_message_source_t *source,
  823. void *conn)
  824. {
  825. assert ((source != NULL) && (conn != NULL));
  826. source->nodeid = my_ip->nodeid;
  827. source->conn = conn;
  828. }
  829. static void ipc_confchg_fn (
  830. enum totem_configuration_type configuration_type,
  831. unsigned int *member_list, int member_list_entries,
  832. unsigned int *left_list, int left_list_entries,
  833. unsigned int *joined_list, int joined_list_entries,
  834. struct memb_ring_id *ring_id)
  835. {
  836. }
  837. void openais_ipc_init (
  838. void (*serialize_lock_fn) (void),
  839. void (*serialize_unlock_fn) (void),
  840. unsigned int gid_valid,
  841. struct totem_ip_address *my_ip_in)
  842. {
  843. int libais_server_fd;
  844. struct sockaddr_un un_addr;
  845. int res;
  846. log_init ("IPC");
  847. ipc_serialize_lock_fn = serialize_lock_fn;
  848. ipc_serialize_unlock_fn = serialize_unlock_fn;
  849. /*
  850. * Create socket for libais clients, name socket, listen for connections
  851. */
  852. libais_server_fd = socket (PF_UNIX, SOCK_STREAM, 0);
  853. if (libais_server_fd == -1) {
  854. log_printf (LOG_LEVEL_ERROR ,"Cannot create libais client connections socket.\n");
  855. openais_exit_error (AIS_DONE_LIBAIS_SOCKET);
  856. };
  857. totemip_nosigpipe(libais_server_fd);
  858. res = fcntl (libais_server_fd, F_SETFL, O_NONBLOCK);
  859. if (res == -1) {
  860. log_printf (LOG_LEVEL_ERROR, "Could not set non-blocking operation on server socket: %s\n", strerror (errno));
  861. openais_exit_error (AIS_DONE_LIBAIS_SOCKET);
  862. }
  863. #if !defined(OPENAIS_LINUX)
  864. unlink(socketname);
  865. #endif
  866. memset (&un_addr, 0, sizeof (struct sockaddr_un));
  867. un_addr.sun_family = AF_UNIX;
  868. #if defined(OPENAIS_BSD) || defined(OPENAIS_DARWIN)
  869. un_addr.sun_len = sizeof(struct sockaddr_un);
  870. #endif
  871. #if defined(OPENAIS_LINUX)
  872. strcpy (un_addr.sun_path + 1, socketname);
  873. #else
  874. strcpy (un_addr.sun_path, socketname);
  875. #endif
  876. res = bind (libais_server_fd, (struct sockaddr *)&un_addr, AIS_SUN_LEN(&un_addr));
  877. if (res) {
  878. log_printf (LOG_LEVEL_ERROR, "ERROR: Could not bind AF_UNIX: %s.\n", strerror (errno));
  879. openais_exit_error (AIS_DONE_LIBAIS_BIND);
  880. }
  881. listen (libais_server_fd, SERVER_BACKLOG);
  882. /*
  883. * Setup libais connection dispatch routine
  884. */
  885. poll_dispatch_add (aisexec_poll_handle, libais_server_fd,
  886. POLLIN, 0, poll_handler_libais_accept);
  887. g_gid_valid = gid_valid;
  888. my_ip = my_ip_in;
  889. /*
  890. * Reset internal state of flow control when
  891. * configuration change occurs
  892. */
  893. res = totempg_groups_initialize (
  894. &ipc_handle,
  895. NULL,
  896. ipc_confchg_fn);
  897. }
  898. /*
  899. * Get the conn info private data
  900. */
  901. void *openais_conn_private_data_get (void *conn)
  902. {
  903. struct conn_info *conn_info = (struct conn_info *)conn;
  904. if (conn != NULL) {
  905. return ((void *)conn_info->private_data);
  906. } else {
  907. return NULL;
  908. }
  909. }
  910. /*
  911. * Get the conn info partner connection
  912. */
  913. void *openais_conn_partner_get (void *conn)
  914. {
  915. struct conn_info *conn_info = (struct conn_info *)conn;
  916. if (conn != NULL) {
  917. return ((void *)conn_info->conn_info_partner);
  918. } else {
  919. return NULL;
  920. }
  921. }
  922. int openais_conn_send_response (
  923. void *conn,
  924. void *msg,
  925. int mlen)
  926. {
  927. struct queue *outq;
  928. char *cmsg;
  929. int res = 0;
  930. int queue_empty;
  931. struct outq_item *queue_item;
  932. struct outq_item queue_item_out;
  933. struct msghdr msg_send;
  934. struct iovec iov_send;
  935. char *msg_addr;
  936. struct conn_info *conn_info = (struct conn_info *)conn;
  937. if (conn_info == NULL) {
  938. return -1;
  939. }
  940. if (!libais_connection_active (conn_info)) {
  941. return (-1);
  942. }
  943. ipc_flow_control (conn_info);
  944. outq = &conn_info->outq;
  945. msg_send.msg_iov = &iov_send;
  946. msg_send.msg_name = 0;
  947. msg_send.msg_namelen = 0;
  948. msg_send.msg_iovlen = 1;
  949. msg_send.msg_control = 0;
  950. msg_send.msg_controllen = 0;
  951. msg_send.msg_flags = 0;
  952. if (queue_is_full (outq)) {
  953. /*
  954. * Start a disconnect if we have not already started one
  955. * and report that the outgoing queue is full
  956. */
  957. log_printf (LOG_LEVEL_ERROR, "Library queue is full, disconnecting library connection.\n");
  958. libais_disconnect_request (conn_info);
  959. return (-1);
  960. }
  961. while (!queue_is_empty (outq)) {
  962. queue_item = queue_item_get (outq);
  963. msg_addr = (char *)queue_item->msg;
  964. msg_addr = &msg_addr[conn_info->byte_start];
  965. iov_send.iov_base = msg_addr;
  966. iov_send.iov_len = queue_item->mlen - conn_info->byte_start;
  967. retry_sendmsg:
  968. res = sendmsg (conn_info->fd, &msg_send, MSG_NOSIGNAL);
  969. if (res == -1 && errno == EINTR) {
  970. goto retry_sendmsg;
  971. }
  972. if (res == -1 && errno == EAGAIN) {
  973. break; /* outgoing kernel queue full */
  974. }
  975. if (res == -1 && errno == EPIPE) {
  976. libais_disconnect_request (conn_info);
  977. return (0);
  978. }
  979. if (res == -1) {
  980. assert (0);
  981. break; /* some other error, stop trying to send message */
  982. }
  983. if (res + conn_info->byte_start != queue_item->mlen) {
  984. conn_info->byte_start += res;
  985. break;
  986. }
  987. /*
  988. * Message sent, try sending another message
  989. */
  990. queue_item_remove (outq);
  991. conn_info->byte_start = 0;
  992. free (queue_item->msg);
  993. } /* while queue not empty */
  994. res = -1;
  995. queue_empty = queue_is_empty (outq);
  996. /*
  997. * Send request message
  998. */
  999. if (queue_empty) {
  1000. iov_send.iov_base = msg;
  1001. iov_send.iov_len = mlen;
  1002. retry_sendmsg_two:
  1003. res = sendmsg (conn_info->fd, &msg_send, MSG_NOSIGNAL);
  1004. if (res == -1 && errno == EINTR) {
  1005. goto retry_sendmsg_two;
  1006. }
  1007. if (res == -1 && errno == EAGAIN) {
  1008. conn_info->byte_start = 0;
  1009. conn_info->events = POLLIN|POLLNVAL;
  1010. }
  1011. if (res != -1) {
  1012. if (res + conn_info->byte_start != mlen) {
  1013. conn_info->byte_start += res;
  1014. res = -1;
  1015. } else {
  1016. conn_info->byte_start = 0;
  1017. conn_info->events = POLLIN|POLLNVAL;
  1018. }
  1019. }
  1020. }
  1021. /*
  1022. * If res == -1 , errrno == EAGAIN which means kernel queue full
  1023. */
  1024. if (res == -1) {
  1025. cmsg = malloc (mlen);
  1026. if (cmsg == 0) {
  1027. log_printf (LOG_LEVEL_ERROR, "Library queue couldn't allocate a message, disconnecting library connection.\n");
  1028. libais_disconnect_request (conn_info);
  1029. return (-1);
  1030. }
  1031. queue_item_out.msg = cmsg;
  1032. queue_item_out.mlen = mlen;
  1033. memcpy (cmsg, msg, mlen);
  1034. queue_item_add (outq, &queue_item_out);
  1035. /*
  1036. * Send a pthread_kill to interrupt the poll syscall
  1037. * and start a new poll operation in the thread
  1038. */
  1039. conn_info->events = POLLIN|POLLOUT|POLLNVAL;
  1040. pthread_kill (conn_info->thread, SIGUSR1);
  1041. }
  1042. return (0);
  1043. }
  1044. int openais_ipc_timer_add (
  1045. void *conn,
  1046. void (*timer_fn) (void *data),
  1047. void *data,
  1048. unsigned int msec_in_future,
  1049. timer_handle *handle)
  1050. {
  1051. struct conn_info *conn_info = (struct conn_info *)conn;
  1052. int res;
  1053. res = timerlist_add_future (
  1054. &conn_info->timerlist,
  1055. timer_fn,
  1056. data,
  1057. msec_in_future,
  1058. handle);
  1059. return (res);
  1060. }
  1061. void openais_ipc_timer_del (
  1062. void *conn,
  1063. timer_handle timer_handle)
  1064. {
  1065. struct conn_info *conn_info = (struct conn_info *)conn;
  1066. timerlist_del (&conn_info->timerlist, timer_handle);
  1067. }
  1068. void openais_ipc_timer_del_data (
  1069. void *conn,
  1070. timer_handle timer_handle)
  1071. {
  1072. struct conn_info *conn_info = (struct conn_info *)conn;
  1073. timerlist_del (&conn_info->timerlist, timer_handle);
  1074. }
  1075. void openais_ipc_flow_control_create (
  1076. void *conn,
  1077. unsigned int service,
  1078. char *id,
  1079. int id_len,
  1080. void (*flow_control_state_set_fn) (void *conn, enum openais_flow_control_state),
  1081. void *context)
  1082. {
  1083. struct conn_info *conn_info = (struct conn_info *)conn;
  1084. openais_flow_control_create (
  1085. conn_info->flow_control_handle,
  1086. service,
  1087. id,
  1088. id_len,
  1089. flow_control_state_set_fn,
  1090. context);
  1091. conn_info->conn_info_partner->flow_control_handle = conn_info->flow_control_handle;
  1092. }
  1093. void openais_ipc_flow_control_destroy (
  1094. void *conn,
  1095. unsigned int service,
  1096. unsigned char *id,
  1097. int id_len)
  1098. {
  1099. struct conn_info *conn_info = (struct conn_info *)conn;
  1100. openais_flow_control_destroy (
  1101. conn_info->flow_control_handle,
  1102. service,
  1103. id,
  1104. id_len);
  1105. }
  1106. void openais_ipc_flow_control_local_increment (
  1107. void *conn)
  1108. {
  1109. struct conn_info *conn_info = (struct conn_info *)conn;
  1110. pthread_mutex_lock (&conn_info->flow_control_mutex);
  1111. conn_info->flow_control_local_count++;
  1112. pthread_mutex_unlock (&conn_info->flow_control_mutex);
  1113. }
  1114. void openais_ipc_flow_control_local_decrement (
  1115. void *conn)
  1116. {
  1117. struct conn_info *conn_info = (struct conn_info *)conn;
  1118. pthread_mutex_lock (&conn_info->flow_control_mutex);
  1119. conn_info->flow_control_local_count--;
  1120. pthread_mutex_unlock (&conn_info->flow_control_mutex);
  1121. }