msg.c 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851
  1. /*
  2. * Copyright (c) 2005 MontaVista Software, 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. #include <stdio.h>
  35. #include <string.h>
  36. #include <stdlib.h>
  37. #include <assert.h>
  38. #include <unistd.h>
  39. #include <errno.h>
  40. #include <pthread.h>
  41. #include <sys/types.h>
  42. #include <sys/uio.h>
  43. #include <sys/socket.h>
  44. #include <sys/select.h>
  45. #include <sys/un.h>
  46. #include <saAis.h>
  47. #include <saMsg.h>
  48. #include <corosync/engine/list.h>
  49. #include <corosync/ipc_gen.h>
  50. #include "../include/ipc_msg.h"
  51. #include "util.h"
  52. struct message_overlay {
  53. mar_res_header_t header __attribute__((aligned(8)));
  54. char data[4096];
  55. };
  56. /*
  57. * Data structure for instance data
  58. */
  59. struct msgInstance {
  60. int response_fd;
  61. int dispatch_fd;
  62. SaMsgCallbacksT callbacks;
  63. int finalize;
  64. SaMsgHandleT msgHandle;
  65. pthread_mutex_t response_mutex;
  66. pthread_mutex_t dispatch_mutex;
  67. struct list_head queue_list;
  68. };
  69. struct msgQueueInstance {
  70. int response_fd;
  71. SaMsgHandleT msgHandle;
  72. SaMsgQueueHandleT queueHandle;
  73. SaMsgQueueOpenFlagsT openFlags;
  74. SaNameT queueName;
  75. struct list_head list;
  76. struct list_head section_iteration_list_head;
  77. pthread_mutex_t *response_mutex;
  78. };
  79. void msgHandleInstanceDestructor (void *instance);
  80. void queueHandleInstanceDestructor (void *instance);
  81. /*
  82. * All MSG instances in this database
  83. */
  84. static struct saHandleDatabase msgHandleDatabase = {
  85. .handleCount = 0,
  86. .handles = 0,
  87. .mutex = PTHREAD_MUTEX_INITIALIZER,
  88. .handleInstanceDestructor = msgHandleInstanceDestructor
  89. };
  90. /*
  91. * All Queue instances in this database
  92. */
  93. static struct saHandleDatabase queueHandleDatabase = {
  94. .handleCount = 0,
  95. .handles = 0,
  96. .mutex = PTHREAD_MUTEX_INITIALIZER,
  97. .handleInstanceDestructor = queueHandleInstanceDestructor
  98. };
  99. /*
  100. * Versions supported
  101. */
  102. static SaVersionT msgVersionsSupported[] = {
  103. { 'B', 1, 1 }
  104. };
  105. static struct saVersionDatabase msgVersionDatabase = {
  106. sizeof (msgVersionsSupported) / sizeof (SaVersionT),
  107. msgVersionsSupported
  108. };
  109. struct iteratorSectionIdListEntry {
  110. struct list_head list;
  111. unsigned char data[0];
  112. };
  113. /*
  114. * Implementation
  115. */
  116. void msgHandleInstanceDestructor (void *instance)
  117. {
  118. struct msgInstance *msgInstance = instance;
  119. pthread_mutex_destroy (&msgInstance->response_mutex);
  120. pthread_mutex_destroy (&msgInstance->dispatch_mutex);
  121. }
  122. void queueHandleInstanceDestructor (void *instance)
  123. {
  124. return;
  125. }
  126. #ifdef COMPILE_OUT
  127. static void msgQueueInstanceFinalize (struct msgQueueInstance *msgQueueInstance)
  128. {
  129. struct msgSectionIterationInstance *sectionIterationInstance;
  130. struct list_head *sectionIterationList;
  131. struct list_head *sectionIterationListNext;
  132. for (sectionIterationList = msgQueueInstance->section_iteration_list_head.next,
  133. sectionIterationListNext = sectionIterationList->next;
  134. sectionIterationList != &msgQueueInstance->section_iteration_list_head;
  135. sectionIterationList = sectionIterationListNext,
  136. sectionIterationListNext = sectionIterationList->next) {
  137. sectionIterationInstance = list_entry (sectionIterationList,
  138. struct msgSectionIterationInstance, list);
  139. msgSectionIterationInstanceFinalize (sectionIterationInstance);
  140. }
  141. list_del (&msgQueueInstance->list);
  142. saHandleDestroy (&queueHandleDatabase, msgQueueInstance->queueHandle);
  143. }
  144. static void msgInstanceFinalize (struct msgInstance *msgInstance)
  145. {
  146. struct msgQueueInstance *msgQueueInstance;
  147. struct list_head *queueInstanceList;
  148. struct list_head *queueInstanceListNext;
  149. for (queueInstanceList = msgInstance->queue_list.next,
  150. queueInstanceListNext = queueInstanceList->next;
  151. queueInstanceList != &msgInstance->queue_list;
  152. queueInstanceList = queueInstanceListNext,
  153. queueInstanceListNext = queueInstanceList->next) {
  154. msgQueueInstance = list_entry (queueInstanceList,
  155. struct msgQueueInstance, list);
  156. msgQueueInstanceFinalize (msgQueueInstance);
  157. }
  158. saHandleDestroy (&msgHandleDatabase, msgInstance->msgHandle);
  159. }
  160. #endif /* COMPILE_OUT */
  161. SaAisErrorT
  162. saMsgInitialize (
  163. SaMsgHandleT *msgHandle,
  164. const SaMsgCallbacksT *callbacks,
  165. SaVersionT *version)
  166. {
  167. SaAisErrorT error;
  168. struct msgInstance *msgInstance;
  169. if (msgHandle == NULL) {
  170. return (SA_AIS_ERR_INVALID_PARAM);
  171. }
  172. error = saVersionVerify (&msgVersionDatabase, version);
  173. if (error != SA_AIS_OK) {
  174. goto error_no_destroy;
  175. }
  176. error = saHandleCreate (&msgHandleDatabase, sizeof (struct msgInstance),
  177. msgHandle);
  178. if (error != SA_AIS_OK) {
  179. goto error_no_destroy;
  180. }
  181. error = saHandleInstanceGet (&msgHandleDatabase, *msgHandle,
  182. (void *)&msgInstance);
  183. if (error != SA_AIS_OK) {
  184. goto error_destroy;
  185. }
  186. /* DEBUG */
  187. printf ("[DEBUG]: saMsgInitialize { msgHandle = %llx }\n",
  188. (unsigned long long) *msgHandle);
  189. msgInstance->response_fd = -1;
  190. error = saServiceConnect (&msgInstance->response_fd,
  191. &msgInstance->dispatch_fd, MSG_SERVICE);
  192. if (error != SA_AIS_OK) {
  193. goto error_put_destroy;
  194. }
  195. if (callbacks) {
  196. memcpy (&msgInstance->callbacks, callbacks, sizeof (SaMsgCallbacksT));
  197. } else {
  198. memset (&msgInstance->callbacks, 0, sizeof (SaMsgCallbacksT));
  199. }
  200. list_init (&msgInstance->queue_list);
  201. msgInstance->msgHandle = *msgHandle;
  202. pthread_mutex_init (&msgInstance->response_mutex, NULL);
  203. saHandleInstancePut (&msgHandleDatabase, *msgHandle);
  204. return (SA_AIS_OK);
  205. error_put_destroy:
  206. saHandleInstancePut (&msgHandleDatabase, *msgHandle);
  207. error_destroy:
  208. saHandleDestroy (&msgHandleDatabase, *msgHandle);
  209. error_no_destroy:
  210. return (error);
  211. }
  212. SaAisErrorT
  213. saMsgSelectionObjectGet (
  214. const SaMsgHandleT msgHandle,
  215. SaSelectionObjectT *selectionObject)
  216. {
  217. struct msgInstance *msgInstance;
  218. SaAisErrorT error;
  219. /* DEBUG */
  220. printf ("[DEBUG]: saMsgSelectionObjectGet { msgHandle = %llx }\n",
  221. (unsigned long long) msgHandle);
  222. if (selectionObject == NULL) {
  223. return (SA_AIS_ERR_INVALID_PARAM);
  224. }
  225. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  226. (void *)&msgInstance);
  227. if (error != SA_AIS_OK) {
  228. return (error);
  229. }
  230. *selectionObject = msgInstance->dispatch_fd;
  231. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  232. return (SA_AIS_OK);
  233. }
  234. SaAisErrorT
  235. saMsgDispatch (
  236. const SaMsgHandleT msgHandle,
  237. SaDispatchFlagsT dispatchFlags)
  238. {
  239. struct pollfd ufds;
  240. int poll_fd;
  241. int timeout = 1;
  242. SaMsgCallbacksT callbacks;
  243. SaAisErrorT error;
  244. int dispatch_avail;
  245. struct msgInstance *msgInstance;
  246. struct msgQueueInstance *msgQueueInstance;
  247. int cont = 1; /* always continue do loop except when set to 0 */
  248. struct message_overlay dispatch_data;
  249. struct res_lib_msg_queueopenasync *res_lib_msg_queueopenasync;
  250. struct res_lib_msg_messagesendasync *res_lib_msg_messagesendasync;
  251. struct res_lib_msg_queuegrouptrack *res_lib_msg_queuegrouptrack;
  252. if (dispatchFlags != SA_DISPATCH_ONE &&
  253. dispatchFlags != SA_DISPATCH_ALL &&
  254. dispatchFlags != SA_DISPATCH_BLOCKING)
  255. {
  256. return (SA_AIS_ERR_INVALID_PARAM);
  257. }
  258. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  259. (void *)&msgInstance);
  260. if (error != SA_AIS_OK) {
  261. goto error_exit;
  262. }
  263. /*
  264. * Timeout instantly for SA_DISPATCH_ALL
  265. */
  266. if (dispatchFlags == SA_DISPATCH_ALL) {
  267. timeout = 0;
  268. }
  269. do {
  270. /*
  271. * Read data directly from socket
  272. */
  273. poll_fd = msgInstance->dispatch_fd;
  274. ufds.fd = poll_fd;
  275. ufds.events = POLLIN;
  276. ufds.revents = 0;
  277. error = saPollRetry(&ufds, 1, timeout);
  278. if (error != SA_AIS_OK) {
  279. goto error_put;
  280. }
  281. pthread_mutex_lock(&msgInstance->dispatch_mutex);
  282. if (msgInstance->finalize == 1) {
  283. error = SA_AIS_OK;
  284. goto error_unlock;
  285. }
  286. if ((ufds.revents & (POLLERR|POLLHUP|POLLNVAL)) != 0) {
  287. error = SA_AIS_ERR_BAD_HANDLE;
  288. goto error_unlock;
  289. }
  290. dispatch_avail = (ufds.revents & POLLIN);
  291. if (dispatch_avail == 0 && dispatchFlags == SA_DISPATCH_ALL) {
  292. pthread_mutex_unlock(&msgInstance->dispatch_mutex);
  293. break; /* exit do while cont is 1 loop */
  294. } else
  295. if (dispatch_avail == 0) {
  296. pthread_mutex_unlock(&msgInstance->dispatch_mutex);
  297. continue;
  298. }
  299. memset(&dispatch_data, 0, sizeof(struct message_overlay));
  300. error = saRecvRetry (msgInstance->dispatch_fd, &dispatch_data.header,
  301. sizeof (mar_res_header_t));
  302. if (error != SA_AIS_OK) {
  303. goto error_unlock;
  304. }
  305. if (dispatch_data.header.size > sizeof (mar_res_header_t)) {
  306. error = saRecvRetry (msgInstance->dispatch_fd, &dispatch_data.data,
  307. dispatch_data.header.size - sizeof (mar_res_header_t));
  308. if (error != SA_AIS_OK) {
  309. goto error_unlock;
  310. }
  311. }
  312. /*
  313. * Make copy of callbacks, message data, unlock instance,
  314. * and call callback. A risk of this dispatch method is that
  315. * the callback routines may operate at the same time that
  316. * MsgFinalize has been called in another thread.
  317. */
  318. memcpy(&callbacks, &msgInstance->callbacks,
  319. sizeof(msgInstance->callbacks));
  320. pthread_mutex_unlock(&msgInstance->dispatch_mutex);
  321. /* DEBUG */
  322. printf ("[DEBUG]: saMsgDispatch { id = %d }\n",
  323. dispatch_data.header.id);
  324. /*
  325. * Dispatch incoming response
  326. */
  327. switch (dispatch_data.header.id)
  328. {
  329. case MESSAGE_RES_MSG_QUEUEOPENASYNC:
  330. if (callbacks.saMsgQueueOpenCallback == NULL) {
  331. continue;
  332. }
  333. res_lib_msg_queueopenasync =
  334. (struct res_lib_msg_queueopenasync *) &dispatch_data;
  335. /*
  336. * This instance get/listadd/put required so that close
  337. * later has the proper list of queues
  338. */
  339. if (res_lib_msg_queueopenasync->header.error == SA_AIS_OK) {
  340. error = saHandleInstanceGet (&queueHandleDatabase,
  341. res_lib_msg_queueopenasync->queueHandle,
  342. (void *)&msgQueueInstance);
  343. assert (error == SA_AIS_OK);
  344. /*
  345. * open succeeded without error
  346. */
  347. list_init (&msgQueueInstance->list);
  348. list_init (&msgQueueInstance->section_iteration_list_head);
  349. list_add (&msgQueueInstance->list,
  350. &msgInstance->queue_list);
  351. callbacks.saMsgQueueOpenCallback(
  352. res_lib_msg_queueopenasync->invocation,
  353. res_lib_msg_queueopenasync->queueHandle,
  354. res_lib_msg_queueopenasync->header.error);
  355. saHandleInstancePut (&queueHandleDatabase,
  356. res_lib_msg_queueopenasync->queueHandle);
  357. } else {
  358. /*
  359. * open failed with error
  360. */
  361. callbacks.saMsgQueueOpenCallback(
  362. res_lib_msg_queueopenasync->invocation,
  363. -1,
  364. res_lib_msg_queueopenasync->header.error);
  365. }
  366. break;
  367. case MESSAGE_RES_MSG_MESSAGESENDASYNC:
  368. if (callbacks.saMsgMessageDeliveredCallback == NULL) {
  369. continue;
  370. }
  371. res_lib_msg_messagesendasync =
  372. (struct res_lib_msg_messagesendasync *) &dispatch_data;
  373. callbacks.saMsgMessageDeliveredCallback (
  374. res_lib_msg_messagesendasync->invocation,
  375. res_lib_msg_messagesendasync->header.error);
  376. break;
  377. case MESSAGE_RES_MSG_QUEUEGROUPTRACK:
  378. if (callbacks.saMsgQueueGroupTrackCallback == NULL) {
  379. continue;
  380. }
  381. res_lib_msg_queuegrouptrack =
  382. (struct res_lib_msg_queuegrouptrack *) &dispatch_data;
  383. res_lib_msg_queuegrouptrack->notificationBuffer.notification =
  384. (SaMsgQueueGroupNotificationT *)
  385. (((char *) &dispatch_data) + sizeof (struct res_lib_msg_queuegrouptrack));
  386. callbacks.saMsgQueueGroupTrackCallback (
  387. &res_lib_msg_queuegrouptrack->queueGroupName,
  388. &res_lib_msg_queuegrouptrack->notificationBuffer,
  389. res_lib_msg_queuegrouptrack->numberOfMembers,
  390. res_lib_msg_queuegrouptrack->header.error);
  391. break;
  392. default:
  393. /* TODO */
  394. break;
  395. }
  396. /*
  397. * Determine if more messages should be processed
  398. */
  399. switch (dispatchFlags)
  400. {
  401. case SA_DISPATCH_ONE:
  402. cont = 0;
  403. break;
  404. case SA_DISPATCH_ALL:
  405. break;
  406. case SA_DISPATCH_BLOCKING:
  407. break;
  408. }
  409. } while (cont);
  410. error_unlock:
  411. pthread_mutex_unlock(&msgInstance->dispatch_mutex);
  412. error_put:
  413. saHandleInstancePut(&msgHandleDatabase, msgHandle);
  414. error_exit:
  415. return (error);
  416. }
  417. SaAisErrorT
  418. saMsgFinalize (
  419. const SaMsgHandleT msgHandle)
  420. {
  421. SaAisErrorT error;
  422. struct msgInstance *msgInstance;
  423. /* DEBUG */
  424. printf ("[DEBUG]: saMsgFinalize { msgHandle = %llx }\n",
  425. (unsigned long long) msgHandle);
  426. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  427. (void *)&msgInstance);
  428. if (error != SA_AIS_OK) {
  429. return (error);
  430. }
  431. pthread_mutex_lock (&msgInstance->response_mutex);
  432. /*
  433. * Another thread has already started finalizing
  434. */
  435. if (msgInstance->finalize) {
  436. pthread_mutex_unlock (&msgInstance->response_mutex);
  437. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  438. return (SA_AIS_ERR_BAD_HANDLE);
  439. }
  440. msgInstance->finalize = 1;
  441. pthread_mutex_unlock (&msgInstance->response_mutex);
  442. /* TODO */
  443. /* msgInstanceFinalize (msgInstance); */
  444. if (msgInstance->response_fd != -1) {
  445. shutdown (msgInstance->response_fd, 0);
  446. close (msgInstance->response_fd);
  447. }
  448. if (msgInstance->dispatch_fd != -1) {
  449. shutdown (msgInstance->dispatch_fd, 0);
  450. close (msgInstance->dispatch_fd);
  451. }
  452. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  453. return (SA_AIS_OK);
  454. }
  455. SaAisErrorT
  456. saMsgQueueOpen (
  457. SaMsgHandleT msgHandle,
  458. const SaNameT *queueName,
  459. const SaMsgQueueCreationAttributesT *creationAttributes,
  460. SaMsgQueueOpenFlagsT openFlags,
  461. SaTimeT timeout,
  462. SaMsgQueueHandleT *queueHandle)
  463. {
  464. SaAisErrorT error;
  465. struct msgInstance *msgInstance;
  466. struct msgQueueInstance *msgQueueInstance;
  467. struct req_lib_msg_queueopen req_lib_msg_queueopen;
  468. struct res_lib_msg_queueopen res_lib_msg_queueopen;
  469. /* DEBUG */
  470. printf ("[DEBUG]: saMsgQueueOpen { queueName = %s }\n",
  471. (char *) queueName->value);
  472. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  473. (void *)&msgInstance);
  474. if (error != SA_AIS_OK) {
  475. goto error_exit;
  476. }
  477. error = saHandleCreate (&queueHandleDatabase,
  478. sizeof (struct msgQueueInstance), queueHandle);
  479. if (error != SA_AIS_OK) {
  480. goto error_put_msg;
  481. }
  482. error = saHandleInstanceGet (&queueHandleDatabase,
  483. *queueHandle, (void *)&msgQueueInstance);
  484. if (error != SA_AIS_OK) {
  485. goto error_destroy;
  486. }
  487. msgQueueInstance->response_fd = msgInstance->response_fd;
  488. msgQueueInstance->response_mutex = &msgInstance->response_mutex;
  489. msgQueueInstance->msgHandle = msgHandle;
  490. msgQueueInstance->queueHandle = *queueHandle;
  491. msgQueueInstance->openFlags = openFlags;
  492. req_lib_msg_queueopen.header.size =
  493. sizeof (struct req_lib_msg_queueopen);
  494. req_lib_msg_queueopen.header.id =
  495. MESSAGE_REQ_MSG_QUEUEOPEN;
  496. memcpy (&req_lib_msg_queueopen.queueName, queueName,
  497. sizeof (SaNameT));
  498. memcpy (&msgQueueInstance->queueName, queueName,
  499. sizeof (SaNameT));
  500. req_lib_msg_queueopen.invocation = 0;
  501. req_lib_msg_queueopen.creationAttributesSet = 0;
  502. if (creationAttributes) {
  503. memcpy (&req_lib_msg_queueopen.creationAttributes,
  504. creationAttributes,
  505. sizeof (SaMsgQueueCreationAttributesT));
  506. req_lib_msg_queueopen.creationAttributesSet = 1;
  507. }
  508. req_lib_msg_queueopen.openFlags = openFlags; /* ? */
  509. req_lib_msg_queueopen.queueHandle = *queueHandle; /* ? */
  510. req_lib_msg_queueopen.timeout = timeout; /* ? */
  511. pthread_mutex_lock (msgQueueInstance->response_mutex);
  512. error = saSendReceiveReply (msgQueueInstance->response_fd,
  513. &req_lib_msg_queueopen,
  514. sizeof (struct req_lib_msg_queueopen),
  515. &res_lib_msg_queueopen,
  516. sizeof (struct res_lib_msg_queueopen));
  517. pthread_mutex_unlock (msgQueueInstance->response_mutex);
  518. if (res_lib_msg_queueopen.header.error != SA_AIS_OK) {
  519. error = res_lib_msg_queueopen.header.error;
  520. goto error_put_destroy;
  521. }
  522. saHandleInstancePut (&queueHandleDatabase, *queueHandle);
  523. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  524. return (error);
  525. error_put_destroy:
  526. saHandleInstancePut (&queueHandleDatabase, *queueHandle);
  527. error_destroy:
  528. saHandleDestroy (&queueHandleDatabase, *queueHandle);
  529. error_put_msg:
  530. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  531. error_exit:
  532. return (error);
  533. }
  534. SaAisErrorT
  535. saMsgQueueOpenAsync (
  536. SaMsgHandleT msgHandle,
  537. SaInvocationT invocation,
  538. const SaNameT *queueName,
  539. const SaMsgQueueCreationAttributesT *creationAttributes,
  540. SaMsgQueueOpenFlagsT openFlags)
  541. {
  542. SaAisErrorT error;
  543. SaMsgQueueHandleT queueHandle;
  544. struct msgInstance *msgInstance;
  545. struct msgQueueInstance *msgQueueInstance;
  546. struct req_lib_msg_queueopen req_lib_msg_queueopen;
  547. struct res_lib_msg_queueopenasync res_lib_msg_queueopenasync;
  548. /* DEBUG */
  549. printf ("[DEBUG]: saMsgQueueOpenAsync { queueName = %s }\n",
  550. (char *) queueName->value);
  551. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  552. (void *)&msgInstance);
  553. if (error != SA_AIS_OK) {
  554. goto error_exit;
  555. }
  556. if (msgInstance->callbacks.saMsgQueueOpenCallback == NULL) {
  557. error = SA_AIS_ERR_INIT;
  558. goto error_put_msg;
  559. }
  560. error = saHandleCreate (&queueHandleDatabase,
  561. sizeof (struct msgQueueInstance), &queueHandle);
  562. if (error != SA_AIS_OK) {
  563. goto error_put_msg;
  564. }
  565. error = saHandleInstanceGet (&queueHandleDatabase, queueHandle,
  566. (void *)&msgQueueInstance);
  567. if (error != SA_AIS_OK) {
  568. goto error_destroy;
  569. }
  570. msgQueueInstance->response_fd = msgInstance->response_fd;
  571. msgQueueInstance->response_mutex = &msgInstance->response_mutex;
  572. msgQueueInstance->msgHandle = msgHandle;
  573. msgQueueInstance->queueHandle = queueHandle;
  574. msgQueueInstance->openFlags = openFlags;
  575. req_lib_msg_queueopen.header.size =
  576. sizeof (struct req_lib_msg_queueopen);
  577. req_lib_msg_queueopen.header.id =
  578. MESSAGE_REQ_MSG_QUEUEOPENASYNC;
  579. memcpy (&req_lib_msg_queueopen.queueName, queueName,
  580. sizeof (SaNameT));
  581. memcpy (&msgQueueInstance->queueName, queueName,
  582. sizeof (SaNameT));
  583. req_lib_msg_queueopen.invocation = invocation;
  584. req_lib_msg_queueopen.creationAttributesSet = 0;
  585. if (creationAttributes) {
  586. memcpy (&req_lib_msg_queueopen.creationAttributes,
  587. creationAttributes,
  588. sizeof (SaMsgQueueCreationAttributesT));
  589. req_lib_msg_queueopen.creationAttributesSet = 1;
  590. }
  591. req_lib_msg_queueopen.openFlags = openFlags; /* ? */
  592. req_lib_msg_queueopen.queueHandle = queueHandle; /* ? */
  593. req_lib_msg_queueopen.timeout = 0; /* ? */
  594. pthread_mutex_lock (msgQueueInstance->response_mutex);
  595. error = saSendReceiveReply (msgQueueInstance->response_fd,
  596. &req_lib_msg_queueopen,
  597. sizeof (struct req_lib_msg_queueopen),
  598. &res_lib_msg_queueopenasync,
  599. sizeof (struct res_lib_msg_queueopenasync));
  600. pthread_mutex_unlock (msgQueueInstance->response_mutex);
  601. if (res_lib_msg_queueopenasync.header.error != SA_AIS_OK) {
  602. error = res_lib_msg_queueopenasync.header.error;
  603. goto error_put_destroy;
  604. }
  605. saHandleInstancePut (&queueHandleDatabase, queueHandle);
  606. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  607. return (error);
  608. error_put_destroy:
  609. saHandleInstancePut (&queueHandleDatabase, queueHandle);
  610. error_destroy:
  611. saHandleDestroy (&queueHandleDatabase, queueHandle);
  612. error_put_msg:
  613. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  614. error_exit:
  615. return (error);
  616. }
  617. SaAisErrorT
  618. saMsgQueueClose (
  619. SaMsgQueueHandleT queueHandle)
  620. {
  621. SaAisErrorT error;
  622. struct msgQueueInstance *msgQueueInstance;
  623. struct req_lib_msg_queueclose req_lib_msg_queueclose;
  624. struct res_lib_msg_queueclose res_lib_msg_queueclose;
  625. error = saHandleInstanceGet (&queueHandleDatabase, queueHandle,
  626. (void *)&msgQueueInstance);
  627. if (error != SA_AIS_OK) {
  628. return (error);
  629. }
  630. req_lib_msg_queueclose.header.size =
  631. sizeof (struct req_lib_msg_queueclose);
  632. req_lib_msg_queueclose.header.id =
  633. MESSAGE_REQ_MSG_QUEUECLOSE;
  634. memcpy (&req_lib_msg_queueclose.queueName, &msgQueueInstance->queueName,
  635. sizeof (SaNameT));
  636. pthread_mutex_lock (msgQueueInstance->response_mutex);
  637. error = saSendReceiveReply (msgQueueInstance->response_fd,
  638. &req_lib_msg_queueclose,
  639. sizeof (struct req_lib_msg_queueclose),
  640. &res_lib_msg_queueclose,
  641. sizeof (struct res_lib_msg_queueclose));
  642. pthread_mutex_unlock (msgQueueInstance->response_mutex);
  643. if (error == SA_AIS_OK) {
  644. error = res_lib_msg_queueclose.header.error;
  645. }
  646. if (error == SA_AIS_OK) {
  647. /* TODO */
  648. /* msgQueueInstanceFinalize (msgQueueInstance); */
  649. }
  650. saHandleInstancePut (&queueHandleDatabase, queueHandle);
  651. return (error);
  652. }
  653. SaAisErrorT
  654. saMsgQueueStatusGet (
  655. SaMsgHandleT msgHandle,
  656. const SaNameT *queueName,
  657. SaMsgQueueStatusT *queueStatus)
  658. {
  659. SaAisErrorT error;
  660. struct msgInstance *msgInstance;
  661. struct req_lib_msg_queuestatusget req_lib_msg_queuestatusget;
  662. struct res_lib_msg_queuestatusget res_lib_msg_queuestatusget;
  663. if (queueName == NULL) {
  664. return (SA_AIS_ERR_INVALID_PARAM);
  665. }
  666. /* DEBUG */
  667. printf ("[DEBUG]: saMsgQueueStatusGet { queueName = %s }\n",
  668. (char *) queueName->value);
  669. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  670. (void *)&msgInstance);
  671. if (error != SA_AIS_OK) {
  672. return (error);
  673. }
  674. req_lib_msg_queuestatusget.header.size =
  675. sizeof (struct req_lib_msg_queuestatusget);
  676. req_lib_msg_queuestatusget.header.id =
  677. MESSAGE_REQ_MSG_QUEUESTATUSGET;
  678. memcpy (&req_lib_msg_queuestatusget.queueName, queueName,
  679. sizeof (SaNameT));
  680. pthread_mutex_lock (&msgInstance->response_mutex);
  681. error = saSendReceiveReply (msgInstance->response_fd,
  682. &req_lib_msg_queuestatusget,
  683. sizeof (struct req_lib_msg_queuestatusget),
  684. &res_lib_msg_queuestatusget,
  685. sizeof (struct res_lib_msg_queuestatusget));
  686. pthread_mutex_unlock (&msgInstance->response_mutex);
  687. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  688. if (error == SA_AIS_OK)
  689. error = res_lib_msg_queuestatusget.header.error;
  690. if (error == SA_AIS_OK) {
  691. memcpy (queueStatus, &res_lib_msg_queuestatusget.queueStatus,
  692. sizeof (SaMsgQueueStatusT));
  693. }
  694. return (error);
  695. }
  696. SaAisErrorT
  697. saMsgQueueRetentionTimeSet (
  698. SaMsgQueueHandleT queueHandle,
  699. SaTimeT *retentionTime)
  700. {
  701. SaAisErrorT error;
  702. struct msgQueueInstance *msgQueueInstance;
  703. error = saHandleInstanceGet (&queueHandleDatabase, queueHandle,
  704. (void *)&msgQueueInstance);
  705. if (error != SA_AIS_OK) {
  706. return (error);
  707. }
  708. /* TODO */
  709. saHandleInstancePut (&queueHandleDatabase, queueHandle);
  710. return (error);
  711. }
  712. SaAisErrorT
  713. saMsgQueueUnlink (
  714. SaMsgHandleT msgHandle,
  715. const SaNameT *queueName)
  716. {
  717. SaAisErrorT error;
  718. struct msgInstance *msgInstance;
  719. struct req_lib_msg_queueunlink req_lib_msg_queueunlink;
  720. struct res_lib_msg_queueunlink res_lib_msg_queueunlink;
  721. if (queueName == NULL) {
  722. return (SA_AIS_ERR_INVALID_PARAM);
  723. }
  724. /* DEBUG */
  725. printf ("[DEBUG]: saMsgQueueUnlink { queueName = %s }\n",
  726. (char *) queueName->value);
  727. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  728. (void *)&msgInstance);
  729. if (error != SA_AIS_OK) {
  730. return (error);
  731. }
  732. req_lib_msg_queueunlink.header.size =
  733. sizeof (struct req_lib_msg_queueunlink);
  734. req_lib_msg_queueunlink.header.id =
  735. MESSAGE_REQ_MSG_QUEUEUNLINK;
  736. memcpy (&req_lib_msg_queueunlink.queueName, queueName,
  737. sizeof (SaNameT));
  738. pthread_mutex_lock (&msgInstance->response_mutex);
  739. error = saSendReceiveReply (msgInstance->response_fd,
  740. &req_lib_msg_queueunlink,
  741. sizeof (struct req_lib_msg_queueunlink),
  742. &res_lib_msg_queueunlink,
  743. sizeof (struct res_lib_msg_queueunlink));
  744. pthread_mutex_unlock (&msgInstance->response_mutex);
  745. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  746. return (error == SA_AIS_OK ? res_lib_msg_queueunlink.header.error : error);
  747. }
  748. SaAisErrorT
  749. saMsgQueueGroupCreate (
  750. SaMsgHandleT msgHandle,
  751. const SaNameT *queueGroupName,
  752. SaMsgQueueGroupPolicyT queueGroupPolicy)
  753. {
  754. SaAisErrorT error;
  755. struct msgInstance *msgInstance;
  756. struct req_lib_msg_queuegroupcreate req_lib_msg_queuegroupcreate;
  757. struct res_lib_msg_queuegroupcreate res_lib_msg_queuegroupcreate;
  758. if (queueGroupName == NULL) {
  759. return (SA_AIS_ERR_INVALID_PARAM);
  760. }
  761. /* DEBUG */
  762. printf ("[DEBUG]: saMsgQueueGroupCreate { queueGroupName = %s }\n",
  763. (char *) queueGroupName->value);
  764. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  765. (void *)&msgInstance);
  766. if (error != SA_AIS_OK) {
  767. return (error);
  768. }
  769. req_lib_msg_queuegroupcreate.header.size =
  770. sizeof (struct req_lib_msg_queuegroupcreate);
  771. req_lib_msg_queuegroupcreate.header.id =
  772. MESSAGE_REQ_MSG_QUEUEGROUPCREATE;
  773. memcpy (&req_lib_msg_queuegroupcreate.queueGroupName, queueGroupName,
  774. sizeof (SaNameT));
  775. req_lib_msg_queuegroupcreate.queueGroupPolicy = queueGroupPolicy;
  776. pthread_mutex_lock (&msgInstance->response_mutex);
  777. error = saSendReceiveReply (msgInstance->response_fd,
  778. &req_lib_msg_queuegroupcreate,
  779. sizeof (struct req_lib_msg_queuegroupcreate),
  780. &res_lib_msg_queuegroupcreate,
  781. sizeof (struct res_lib_msg_queuegroupcreate));
  782. pthread_mutex_unlock (&msgInstance->response_mutex);
  783. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  784. return (error == SA_AIS_OK ? res_lib_msg_queuegroupcreate.header.error : error);
  785. }
  786. SaAisErrorT
  787. saMsgQueueGroupInsert (
  788. SaMsgHandleT msgHandle,
  789. const SaNameT *queueGroupName,
  790. const SaNameT *queueName)
  791. {
  792. SaAisErrorT error;
  793. struct msgInstance *msgInstance;
  794. struct req_lib_msg_queuegroupinsert req_lib_msg_queuegroupinsert;
  795. struct res_lib_msg_queuegroupinsert res_lib_msg_queuegroupinsert;
  796. if (queueName == NULL) {
  797. return (SA_AIS_ERR_INVALID_PARAM);
  798. }
  799. /* DEBUG */
  800. printf ("[DEBUG]: saMsgQueueGroupInsert { queueGroupName = %s }\n",
  801. (char *) queueGroupName->value);
  802. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  803. (void *)&msgInstance);
  804. if (error != SA_AIS_OK) {
  805. return (error);
  806. }
  807. req_lib_msg_queuegroupinsert.header.size =
  808. sizeof (struct req_lib_msg_queuegroupinsert);
  809. req_lib_msg_queuegroupinsert.header.id =
  810. MESSAGE_REQ_MSG_QUEUEGROUPINSERT;
  811. memcpy (&req_lib_msg_queuegroupinsert.queueName, queueName,
  812. sizeof (SaNameT));
  813. memcpy (&req_lib_msg_queuegroupinsert.queueGroupName, queueGroupName,
  814. sizeof (SaNameT));
  815. pthread_mutex_lock (&msgInstance->response_mutex);
  816. error = saSendReceiveReply (msgInstance->response_fd,
  817. &req_lib_msg_queuegroupinsert,
  818. sizeof (struct req_lib_msg_queuegroupinsert),
  819. &res_lib_msg_queuegroupinsert,
  820. sizeof (struct res_lib_msg_queuegroupinsert));
  821. pthread_mutex_unlock (&msgInstance->response_mutex);
  822. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  823. return (error == SA_AIS_OK ? res_lib_msg_queuegroupinsert.header.error : error);
  824. }
  825. SaAisErrorT
  826. saMsgQueueGroupRemove (
  827. SaMsgHandleT msgHandle,
  828. const SaNameT *queueGroupName,
  829. const SaNameT *queueName)
  830. {
  831. SaAisErrorT error;
  832. struct msgInstance *msgInstance;
  833. struct req_lib_msg_queuegroupremove req_lib_msg_queuegroupremove;
  834. struct res_lib_msg_queuegroupremove res_lib_msg_queuegroupremove;
  835. if (queueName == NULL) {
  836. return (SA_AIS_ERR_INVALID_PARAM);
  837. }
  838. /* DEBUG */
  839. printf ("[DEBUG]: saMsgQueueGroupRemove { queueGroupName = %s }\n",
  840. (char *) queueGroupName->value);
  841. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  842. (void *)&msgInstance);
  843. if (error != SA_AIS_OK) {
  844. return (error);
  845. }
  846. req_lib_msg_queuegroupremove.header.size =
  847. sizeof (struct req_lib_msg_queuegroupremove);
  848. req_lib_msg_queuegroupremove.header.id =
  849. MESSAGE_REQ_MSG_QUEUEGROUPREMOVE;
  850. memcpy (&req_lib_msg_queuegroupremove.queueName, queueName,
  851. sizeof (SaNameT));
  852. memcpy (&req_lib_msg_queuegroupremove.queueGroupName, queueGroupName,
  853. sizeof (SaNameT));
  854. pthread_mutex_lock (&msgInstance->response_mutex);
  855. error = saSendReceiveReply (msgInstance->response_fd,
  856. &req_lib_msg_queuegroupremove,
  857. sizeof (struct req_lib_msg_queuegroupremove),
  858. &res_lib_msg_queuegroupremove,
  859. sizeof (struct res_lib_msg_queuegroupremove));
  860. pthread_mutex_unlock (&msgInstance->response_mutex);
  861. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  862. return (error == SA_AIS_OK ? res_lib_msg_queuegroupremove.header.error : error);
  863. }
  864. SaAisErrorT
  865. saMsgQueueGroupDelete (
  866. SaMsgHandleT msgHandle,
  867. const SaNameT *queueGroupName)
  868. {
  869. SaAisErrorT error;
  870. struct msgInstance *msgInstance;
  871. struct req_lib_msg_queuegroupdelete req_lib_msg_queuegroupdelete;
  872. struct res_lib_msg_queuegroupdelete res_lib_msg_queuegroupdelete;
  873. if (queueGroupName == NULL) {
  874. return (SA_AIS_ERR_INVALID_PARAM);
  875. }
  876. /* DEBUG */
  877. printf ("[DEBUG]: saMsgQueueGroupDelete { queueGroupName = %s }\n",
  878. (char *) queueGroupName->value);
  879. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  880. (void *)&msgInstance);
  881. if (error != SA_AIS_OK) {
  882. return (error);
  883. }
  884. req_lib_msg_queuegroupdelete.header.size =
  885. sizeof (struct req_lib_msg_queuegroupdelete);
  886. req_lib_msg_queuegroupdelete.header.id =
  887. MESSAGE_REQ_MSG_QUEUEGROUPDELETE;
  888. memcpy (&req_lib_msg_queuegroupdelete.queueGroupName, queueGroupName,
  889. sizeof (SaNameT));
  890. pthread_mutex_lock (&msgInstance->response_mutex);
  891. error = saSendReceiveReply (msgInstance->response_fd,
  892. &req_lib_msg_queuegroupdelete,
  893. sizeof (struct req_lib_msg_queuegroupdelete),
  894. &res_lib_msg_queuegroupdelete,
  895. sizeof (struct res_lib_msg_queuegroupdelete));
  896. pthread_mutex_unlock (&msgInstance->response_mutex);
  897. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  898. return (error == SA_AIS_OK ? res_lib_msg_queuegroupdelete.header.error : error);
  899. }
  900. SaAisErrorT
  901. saMsgQueueGroupTrack (
  902. SaMsgHandleT msgHandle,
  903. const SaNameT *queueGroupName,
  904. SaUint8T trackFlags,
  905. SaMsgQueueGroupNotificationBufferT *notificationBuffer)
  906. {
  907. SaAisErrorT error;
  908. struct msgInstance *msgInstance;
  909. struct req_lib_msg_queuegrouptrack req_lib_msg_queuegrouptrack;
  910. struct res_lib_msg_queuegrouptrack res_lib_msg_queuegrouptrack;
  911. if (queueGroupName == NULL) {
  912. return (SA_AIS_ERR_INVALID_PARAM);
  913. }
  914. if ((notificationBuffer != NULL) &&
  915. (notificationBuffer->notification != NULL) &&
  916. (notificationBuffer->numberOfItems == 0)) {
  917. return (SA_AIS_ERR_INVALID_PARAM);
  918. }
  919. if ((notificationBuffer != NULL) &&
  920. (notificationBuffer->notification == NULL)) {
  921. notificationBuffer->numberOfItems = 0;
  922. }
  923. if ((trackFlags & SA_TRACK_CHANGES) &&
  924. (trackFlags & SA_TRACK_CHANGES_ONLY)) {
  925. return (SA_AIS_ERR_BAD_FLAGS);
  926. }
  927. /* DEBUG */
  928. printf ("[DEBUG]: saMsgQueueGroupTrack { queueGroupName = %s }\n",
  929. (char *) queueGroupName->value);
  930. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  931. (void *)&msgInstance);
  932. if (error != SA_AIS_OK) {
  933. return (error);
  934. }
  935. req_lib_msg_queuegrouptrack.header.size =
  936. sizeof (struct req_lib_msg_queuegrouptrack);
  937. req_lib_msg_queuegrouptrack.header.id =
  938. MESSAGE_REQ_MSG_QUEUEGROUPTRACK;
  939. req_lib_msg_queuegrouptrack.trackFlags = trackFlags;
  940. req_lib_msg_queuegrouptrack.bufferFlag = (notificationBuffer != NULL);
  941. /* DEBUG */
  942. printf ("[DEBUG]: saMsgQueueGroupTrack { bufferFlag = %d }\n",
  943. (int)(req_lib_msg_queuegrouptrack.bufferFlag));
  944. memcpy (&req_lib_msg_queuegrouptrack.queueGroupName, queueGroupName,
  945. sizeof (SaNameT));
  946. pthread_mutex_lock (&msgInstance->response_mutex);
  947. /*
  948. error = saSendReceiveReply (msgInstance->response_fd,
  949. &req_lib_msg_queuegrouptrack,
  950. sizeof (struct req_lib_msg_queuegrouptrack),
  951. &res_lib_msg_queuegrouptrack,
  952. sizeof (struct res_lib_msg_queuegrouptrack));
  953. */
  954. error = saSendRetry (msgInstance->response_fd, &req_lib_msg_queuegrouptrack,
  955. sizeof (struct req_lib_msg_queuegrouptrack));
  956. if (error != SA_AIS_OK) {
  957. goto error_exit;
  958. }
  959. error = saRecvRetry (msgInstance->response_fd, &res_lib_msg_queuegrouptrack,
  960. sizeof (struct res_lib_msg_queuegrouptrack));
  961. if (error != SA_AIS_OK) {
  962. goto error_exit;
  963. }
  964. if ((trackFlags & SA_TRACK_CURRENT) && (notificationBuffer != NULL)) {
  965. if (notificationBuffer->notification != NULL) {
  966. if (notificationBuffer->numberOfItems < res_lib_msg_queuegrouptrack.numberOfMembers) {
  967. error = SA_AIS_ERR_NO_SPACE;
  968. goto error_exit;
  969. }
  970. } else {
  971. notificationBuffer->notification =
  972. malloc (sizeof (SaMsgQueueGroupNotificationT) *
  973. res_lib_msg_queuegrouptrack.numberOfMembers);
  974. if (notificationBuffer->notification == NULL) {
  975. error = SA_AIS_ERR_NO_MEMORY;
  976. goto error_exit;
  977. }
  978. memset (notificationBuffer->notification, 0,
  979. (sizeof (SaMsgQueueGroupNotificationT) *
  980. res_lib_msg_queuegrouptrack.numberOfMembers));
  981. }
  982. error = saRecvRetry (msgInstance->response_fd,
  983. notificationBuffer->notification,
  984. (sizeof (SaMsgQueueGroupNotificationT) *
  985. res_lib_msg_queuegrouptrack.numberOfMembers));
  986. }
  987. error_exit:
  988. pthread_mutex_unlock (&msgInstance->response_mutex);
  989. error_put_msg:
  990. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  991. return (error == SA_AIS_OK ? res_lib_msg_queuegrouptrack.header.error : error);
  992. }
  993. SaAisErrorT
  994. saMsgQueueGroupTrackStop (
  995. SaMsgHandleT msgHandle,
  996. const SaNameT *queueGroupName)
  997. {
  998. SaAisErrorT error;
  999. struct msgInstance *msgInstance;
  1000. struct req_lib_msg_queuegrouptrackstop req_lib_msg_queuegrouptrackstop;
  1001. struct res_lib_msg_queuegrouptrackstop res_lib_msg_queuegrouptrackstop;
  1002. if (queueGroupName == NULL) {
  1003. return (SA_AIS_ERR_INVALID_PARAM);
  1004. }
  1005. /* DEBUG */
  1006. printf ("[DEBUG]: saMsgQueueGroupTrackStop { queueGroupName = %s }\n",
  1007. (char *) queueGroupName->value);
  1008. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  1009. (void *)&msgInstance);
  1010. if (error != SA_AIS_OK) {
  1011. return (error);
  1012. }
  1013. req_lib_msg_queuegrouptrackstop.header.size =
  1014. sizeof (struct req_lib_msg_queuegrouptrackstop);
  1015. req_lib_msg_queuegrouptrackstop.header.id =
  1016. MESSAGE_REQ_MSG_QUEUEGROUPTRACKSTOP;
  1017. memcpy (&req_lib_msg_queuegrouptrackstop.queueGroupName, queueGroupName,
  1018. sizeof (SaNameT));
  1019. pthread_mutex_lock (&msgInstance->response_mutex);
  1020. error = saSendReceiveReply (msgInstance->response_fd,
  1021. &req_lib_msg_queuegrouptrackstop,
  1022. sizeof (struct req_lib_msg_queuegrouptrackstop),
  1023. &res_lib_msg_queuegrouptrackstop,
  1024. sizeof (struct res_lib_msg_queuegrouptrackstop));
  1025. pthread_mutex_unlock (&msgInstance->response_mutex);
  1026. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  1027. return (error == SA_AIS_OK ? res_lib_msg_queuegrouptrackstop.header.error : error);
  1028. }
  1029. SaAisErrorT
  1030. saMsgQueueGroupNotificationFree (
  1031. SaMsgHandleT msgHandle,
  1032. SaMsgQueueGroupNotificationT *notification)
  1033. {
  1034. SaAisErrorT error;
  1035. struct msgInstance *msgInstance;
  1036. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  1037. (void *)&msgInstance);
  1038. if (error != SA_AIS_OK) {
  1039. return (error);
  1040. }
  1041. /* TODO */
  1042. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  1043. return (error);
  1044. }
  1045. SaAisErrorT
  1046. saMsgMessageSend (
  1047. SaMsgHandleT msgHandle,
  1048. const SaNameT *destination,
  1049. const SaMsgMessageT *message,
  1050. SaTimeT timeout)
  1051. {
  1052. SaAisErrorT error;
  1053. struct msgInstance *msgInstance;
  1054. struct req_lib_msg_messagesend req_lib_msg_messagesend;
  1055. struct res_lib_msg_messagesend res_lib_msg_messagesend;
  1056. /* DEBUG */
  1057. printf ("[DEBUG]: saMsgMessageSend { msgHandle = %llx }\n",
  1058. (unsigned long long) msgHandle);
  1059. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  1060. (void *)&msgInstance);
  1061. if (error != SA_AIS_OK) {
  1062. return (error);
  1063. }
  1064. req_lib_msg_messagesend.header.size =
  1065. sizeof (struct req_lib_msg_messagesend) + message->size;
  1066. req_lib_msg_messagesend.header.id =
  1067. MESSAGE_REQ_MSG_MESSAGESEND;
  1068. memcpy (&req_lib_msg_messagesend.destination, destination,
  1069. sizeof (SaNameT));
  1070. memcpy (&req_lib_msg_messagesend.message, message,
  1071. sizeof (SaMsgMessageT));
  1072. req_lib_msg_messagesend.invocation = 0;
  1073. req_lib_msg_messagesend.ackFlags = 0;
  1074. req_lib_msg_messagesend.async_call = 0;
  1075. req_lib_msg_messagesend.timeout = timeout;
  1076. pthread_mutex_lock (&msgInstance->response_mutex);
  1077. /*
  1078. error = saSendReceiveReply (msgInstance->response_fd,
  1079. &req_lib_msg_messagesend,
  1080. sizeof (struct req_lib_msg_messagesend),
  1081. &res_lib_msg_messagesend,
  1082. sizeof (struct res_lib_msg_messagesend));
  1083. */
  1084. error = saSendRetry (msgInstance->response_fd, &req_lib_msg_messagesend,
  1085. sizeof (struct req_lib_msg_messagesend));
  1086. if (error != SA_AIS_OK) {
  1087. goto error_exit;
  1088. }
  1089. error = saSendRetry (msgInstance->response_fd,
  1090. message->data, message->size);
  1091. if (error != SA_AIS_OK) {
  1092. goto error_exit;
  1093. }
  1094. error = saRecvRetry (msgInstance->response_fd, &res_lib_msg_messagesend,
  1095. sizeof (struct res_lib_msg_messagesend));
  1096. error_exit:
  1097. pthread_mutex_unlock (&msgInstance->response_mutex);
  1098. error_put_msg:
  1099. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  1100. return (error == SA_AIS_OK ? res_lib_msg_messagesend.header.error : error);
  1101. }
  1102. SaAisErrorT
  1103. saMsgMessageSendAsync (
  1104. SaMsgHandleT msgHandle,
  1105. SaInvocationT invocation,
  1106. const SaNameT *destination,
  1107. const SaMsgMessageT *message,
  1108. SaMsgAckFlagsT ackFlags)
  1109. {
  1110. SaAisErrorT error;
  1111. struct msgInstance *msgInstance;
  1112. struct req_lib_msg_messagesend req_lib_msg_messagesend;
  1113. struct res_lib_msg_messagesendasync res_lib_msg_messagesendasync;
  1114. /* DEBUG */
  1115. printf ("[DEBUG]: saMsgMessageSendAsync { msgHandle = %llx }\n",
  1116. (unsigned long long) msgHandle);
  1117. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  1118. (void *)&msgInstance);
  1119. if (error != SA_AIS_OK) {
  1120. return (error);
  1121. }
  1122. req_lib_msg_messagesend.header.size =
  1123. sizeof (struct req_lib_msg_messagesend) + message->size;
  1124. req_lib_msg_messagesend.header.id =
  1125. MESSAGE_REQ_MSG_MESSAGESENDASYNC;
  1126. memcpy (&req_lib_msg_messagesend.destination, destination,
  1127. sizeof (SaNameT));
  1128. memcpy (&req_lib_msg_messagesend.message, message,
  1129. sizeof (SaMsgMessageT));
  1130. req_lib_msg_messagesend.invocation = invocation;
  1131. req_lib_msg_messagesend.ackFlags = ackFlags;
  1132. req_lib_msg_messagesend.async_call = 1;
  1133. req_lib_msg_messagesend.timeout = 0;
  1134. pthread_mutex_lock (&msgInstance->response_mutex);
  1135. /*
  1136. error = saSendReceiveReply (msgInstance->response_fd,
  1137. &req_lib_msg_messagesend,
  1138. sizeof (struct req_lib_msg_messagesend),
  1139. &res_lib_msg_messagesendasync,
  1140. sizeof (struct res_lib_msg_messagesendasync));
  1141. */
  1142. error = saSendRetry (msgInstance->response_fd, &req_lib_msg_messagesend,
  1143. sizeof (struct req_lib_msg_messagesend));
  1144. if (error != SA_AIS_OK) {
  1145. goto error_exit;
  1146. }
  1147. error = saSendRetry (msgInstance->response_fd,
  1148. message->data, message->size);
  1149. if (error != SA_AIS_OK) {
  1150. goto error_exit;
  1151. }
  1152. error = saRecvRetry (msgInstance->response_fd, &res_lib_msg_messagesendasync,
  1153. sizeof (struct res_lib_msg_messagesendasync));
  1154. error_exit:
  1155. pthread_mutex_unlock (&msgInstance->response_mutex);
  1156. error_put_msg:
  1157. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  1158. return (error == SA_AIS_OK ? res_lib_msg_messagesendasync.header.error : error);
  1159. }
  1160. SaAisErrorT
  1161. saMsgMessageGet (
  1162. SaMsgQueueHandleT queueHandle,
  1163. SaMsgMessageT *message,
  1164. SaTimeT *sendTime,
  1165. SaMsgSenderIdT *senderId,
  1166. SaTimeT timeout)
  1167. {
  1168. SaAisErrorT error;
  1169. struct msgQueueInstance *msgQueueInstance;
  1170. struct req_lib_msg_messageget req_lib_msg_messageget;
  1171. struct res_lib_msg_messageget res_lib_msg_messageget;
  1172. /* DEBUG */
  1173. printf ("[DEBUG]: saMsgMessageGet { queueHandle = %llx }\n",
  1174. (unsigned long long) queueHandle);
  1175. error = saHandleInstanceGet (&queueHandleDatabase, queueHandle,
  1176. (void *)&msgQueueInstance);
  1177. if (error != SA_AIS_OK) {
  1178. return (error);
  1179. }
  1180. req_lib_msg_messageget.header.size =
  1181. sizeof (struct req_lib_msg_messageget);
  1182. req_lib_msg_messageget.header.id =
  1183. MESSAGE_REQ_MSG_MESSAGEGET;
  1184. memcpy (&req_lib_msg_messageget.queueName, &msgQueueInstance->queueName,
  1185. sizeof (SaNameT));
  1186. req_lib_msg_messageget.timeout = timeout;
  1187. pthread_mutex_lock (msgQueueInstance->response_mutex);
  1188. /*
  1189. error = saSendReceiveReply (msgQueueInstance->response_fd,
  1190. &req_lib_msg_messageget,
  1191. sizeof (struct req_lib_msg_messageget),
  1192. &res_lib_msg_messageget,
  1193. sizeof (struct res_lib_msg_messageget));
  1194. */
  1195. error = saSendRetry (msgQueueInstance->response_fd, &req_lib_msg_messageget,
  1196. sizeof (struct req_lib_msg_messageget));
  1197. if (error != SA_AIS_OK) {
  1198. goto error_exit;
  1199. }
  1200. error = saRecvRetry (msgQueueInstance->response_fd, &res_lib_msg_messageget,
  1201. sizeof (struct res_lib_msg_messageget));
  1202. if (error != SA_AIS_OK) {
  1203. goto error_exit;
  1204. }
  1205. if (message->data == NULL) {
  1206. message->size = res_lib_msg_messageget.message.size;
  1207. message->data = malloc (message->size);
  1208. if (message->data == NULL) {
  1209. error = SA_AIS_ERR_NO_MEMORY;
  1210. goto error_exit;
  1211. }
  1212. } else {
  1213. if (res_lib_msg_messageget.message.size > message->size) {
  1214. error = SA_AIS_ERR_NO_SPACE;
  1215. goto error_exit;
  1216. }
  1217. }
  1218. error = saRecvRetry (msgQueueInstance->response_fd,
  1219. message->data, message->size);
  1220. error_exit:
  1221. pthread_mutex_unlock (msgQueueInstance->response_mutex);
  1222. error_put_msg:
  1223. saHandleInstancePut (&queueHandleDatabase, queueHandle);
  1224. if (error == SA_AIS_OK)
  1225. error = res_lib_msg_messageget.header.error;
  1226. if (error == SA_AIS_OK) {
  1227. *sendTime = res_lib_msg_messageget.sendTime;
  1228. memcpy (senderId, &res_lib_msg_messageget.senderId,
  1229. sizeof (SaMsgSenderIdT));
  1230. }
  1231. return (error);
  1232. }
  1233. SaAisErrorT
  1234. saMsgMessageDataFree (
  1235. SaMsgHandleT msgHandle,
  1236. void *data)
  1237. {
  1238. SaAisErrorT error;
  1239. struct msgInstance *msgInstance;
  1240. if (data == NULL) {
  1241. return (SA_AIS_ERR_INVALID_PARAM);
  1242. }
  1243. /* DEBUG */
  1244. printf ("[DEBUG]: saMsgMessageDataFree { msgHandle = %llx }\n",
  1245. (unsigned long long) msgHandle);
  1246. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  1247. (void *)&msgInstance);
  1248. if (error != SA_AIS_OK) {
  1249. return (error);
  1250. }
  1251. free (data);
  1252. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  1253. return (error);
  1254. }
  1255. SaAisErrorT
  1256. saMsgMessageCancel (
  1257. SaMsgQueueHandleT queueHandle)
  1258. {
  1259. SaAisErrorT error;
  1260. struct msgQueueInstance *msgQueueInstance;
  1261. struct req_lib_msg_messagecancel req_lib_msg_messagecancel;
  1262. struct res_lib_msg_messagecancel res_lib_msg_messagecancel;
  1263. /* DEBUG */
  1264. printf ("[DEBUG]: saMsgMessageCancel { queueHandle = %llx }\n",
  1265. (unsigned long long) queueHandle);
  1266. error = saHandleInstanceGet (&msgHandleDatabase, queueHandle,
  1267. (void *)&msgQueueInstance);
  1268. if (error != SA_AIS_OK) {
  1269. return (error);
  1270. }
  1271. req_lib_msg_messagecancel.header.size =
  1272. sizeof (struct req_lib_msg_messagecancel);
  1273. req_lib_msg_messagecancel.header.id =
  1274. MESSAGE_REQ_MSG_MESSAGECANCEL;
  1275. pthread_mutex_lock (msgQueueInstance->response_mutex);
  1276. error = saSendReceiveReply (msgQueueInstance->response_fd,
  1277. &req_lib_msg_messagecancel,
  1278. sizeof (struct req_lib_msg_messagecancel),
  1279. &res_lib_msg_messagecancel,
  1280. sizeof (struct res_lib_msg_messagecancel));
  1281. pthread_mutex_unlock (msgQueueInstance->response_mutex);
  1282. saHandleInstancePut (&queueHandleDatabase, queueHandle);
  1283. return (error == SA_AIS_OK ? res_lib_msg_messagecancel.header.error : error);
  1284. }
  1285. SaAisErrorT
  1286. saMsgMessageSendReceive (
  1287. SaMsgHandleT msgHandle,
  1288. const SaNameT *destination,
  1289. const SaMsgMessageT *sendMessage,
  1290. SaMsgMessageT *receiveMessage,
  1291. SaTimeT *replySendTime,
  1292. SaTimeT timeout)
  1293. {
  1294. SaAisErrorT error;
  1295. struct msgInstance *msgInstance;
  1296. struct req_lib_msg_messagesendreceive req_lib_msg_messagesendreceive;
  1297. struct res_lib_msg_messagesendreceive res_lib_msg_messagesendreceive;
  1298. /* DEBUG */
  1299. printf ("[DEBUG]: saMsgMessageSendReceive { msgHandle = %llx }\n",
  1300. (unsigned long long) msgHandle);
  1301. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  1302. (void *)&msgInstance);
  1303. if (error != SA_AIS_OK) {
  1304. return (error);
  1305. }
  1306. req_lib_msg_messagesendreceive.header.size =
  1307. sizeof (struct req_lib_msg_messagesendreceive);
  1308. req_lib_msg_messagesendreceive.header.id =
  1309. MESSAGE_REQ_MSG_MESSAGEREPLY;
  1310. memcpy (&req_lib_msg_messagesendreceive.destination, destination,
  1311. sizeof (SaNameT));
  1312. req_lib_msg_messagesendreceive.timeout = timeout;
  1313. pthread_mutex_lock (&msgInstance->response_mutex);
  1314. error = saSendReceiveReply (msgInstance->response_fd,
  1315. &req_lib_msg_messagesendreceive,
  1316. sizeof (struct req_lib_msg_messagesendreceive),
  1317. &res_lib_msg_messagesendreceive,
  1318. sizeof (struct res_lib_msg_messagesendreceive));
  1319. pthread_mutex_unlock (&msgInstance->response_mutex);
  1320. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  1321. if (error == SA_AIS_OK)
  1322. error = res_lib_msg_messagesendreceive.header.error;
  1323. if (error == SA_AIS_OK) {
  1324. *replySendTime = res_lib_msg_messagesendreceive.replySendTime;
  1325. }
  1326. return (error);
  1327. }
  1328. SaAisErrorT
  1329. saMsgMessageReply (
  1330. SaMsgHandleT msgHandle,
  1331. const SaMsgMessageT *replyMessage,
  1332. const SaMsgSenderIdT *senderId,
  1333. SaTimeT timeout)
  1334. {
  1335. SaAisErrorT error;
  1336. struct msgInstance *msgInstance;
  1337. struct req_lib_msg_messagereply req_lib_msg_messagereply;
  1338. struct res_lib_msg_messagereply res_lib_msg_messagereply;
  1339. /* DEBUG */
  1340. printf ("[DEBUG]: saMsgMessageReply { msgHandle = %llx }\n",
  1341. (unsigned long long) msgHandle);
  1342. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  1343. (void *)&msgInstance);
  1344. if (error != SA_AIS_OK) {
  1345. return (error);
  1346. }
  1347. req_lib_msg_messagereply.header.size =
  1348. sizeof (struct req_lib_msg_messagereply);
  1349. req_lib_msg_messagereply.header.id =
  1350. MESSAGE_REQ_MSG_MESSAGEREPLY;
  1351. memcpy (&req_lib_msg_messagereply.senderId, senderId,
  1352. sizeof (SaMsgSenderIdT));
  1353. pthread_mutex_lock (&msgInstance->response_mutex);
  1354. error = saSendReceiveReply (msgInstance->response_fd,
  1355. &req_lib_msg_messagereply,
  1356. sizeof (struct req_lib_msg_messagereply),
  1357. &res_lib_msg_messagereply,
  1358. sizeof (struct res_lib_msg_messagereply));
  1359. pthread_mutex_unlock (&msgInstance->response_mutex);
  1360. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  1361. return (error == SA_AIS_OK ? res_lib_msg_messagereply.header.error : error);
  1362. }
  1363. SaAisErrorT
  1364. saMsgMessageReplyAsync (
  1365. SaMsgHandleT msgHandle,
  1366. SaInvocationT invocation,
  1367. const SaMsgMessageT *replyMessage,
  1368. const SaMsgSenderIdT *senderId,
  1369. SaMsgAckFlagsT ackFlags)
  1370. {
  1371. SaAisErrorT error;
  1372. struct msgInstance *msgInstance;
  1373. struct req_lib_msg_messagereply req_lib_msg_messagereply;
  1374. struct res_lib_msg_messagereplyasync res_lib_msg_messagereplyasync;
  1375. /* DEBUG */
  1376. printf ("[DEBUG]: saMsgMessageReplyAsync { msgHandle = %llx }\n",
  1377. (unsigned long long) msgHandle);
  1378. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  1379. (void *)&msgInstance);
  1380. if (error != SA_AIS_OK) {
  1381. return (error);
  1382. }
  1383. req_lib_msg_messagereply.header.size =
  1384. sizeof (struct req_lib_msg_messagereply);
  1385. req_lib_msg_messagereply.header.id =
  1386. MESSAGE_REQ_MSG_MESSAGEREPLY;
  1387. memcpy (&req_lib_msg_messagereply.senderId, senderId,
  1388. sizeof (SaMsgSenderIdT));
  1389. pthread_mutex_lock (&msgInstance->response_mutex);
  1390. error = saSendReceiveReply (msgInstance->response_fd,
  1391. &req_lib_msg_messagereply,
  1392. sizeof (struct req_lib_msg_messagereply),
  1393. &res_lib_msg_messagereplyasync,
  1394. sizeof (struct res_lib_msg_messagereplyasync));
  1395. pthread_mutex_unlock (&msgInstance->response_mutex);
  1396. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  1397. return (error == SA_AIS_OK ? res_lib_msg_messagereplyasync.header.error : error);
  1398. }
  1399. SaAisErrorT
  1400. saMsgQueueCapacityThresholdSet (
  1401. SaMsgQueueHandleT queueHandle,
  1402. const SaMsgQueueThresholdsT *thresholds)
  1403. {
  1404. SaAisErrorT error;
  1405. struct msgQueueInstance *msgQueueInstance;
  1406. /* DEBUG */
  1407. printf ("[DEBUG]: saMsgQueueCapacityThresholdsSet { queueHandle = %llx }\n",
  1408. (unsigned long long) queueHandle);
  1409. error = saHandleInstanceGet (&queueHandleDatabase, queueHandle,
  1410. (void *)&msgQueueInstance);
  1411. if (error != SA_AIS_OK) {
  1412. return (error);
  1413. }
  1414. /* TODO */
  1415. saHandleInstancePut (&queueHandleDatabase, queueHandle);
  1416. return (error);
  1417. }
  1418. SaAisErrorT
  1419. saMsgQueueCapacityThresholdGet (
  1420. SaMsgQueueHandleT queueHandle,
  1421. SaMsgQueueThresholdsT *thresholds)
  1422. {
  1423. SaAisErrorT error;
  1424. struct msgQueueInstance *msgQueueInstance;
  1425. /* DEBUG */
  1426. printf ("[DEBUG]: saMsgQueueCapacityThresholdGet { queueHandle = %llx }\n",
  1427. (unsigned long long) queueHandle);
  1428. error = saHandleInstanceGet (&queueHandleDatabase, queueHandle,
  1429. (void *)&msgQueueInstance);
  1430. if (error != SA_AIS_OK) {
  1431. return (error);
  1432. }
  1433. /* TODO */
  1434. saHandleInstancePut (&queueHandleDatabase, queueHandle);
  1435. return (error);
  1436. }
  1437. SaAisErrorT
  1438. saMsgMetadataSizeGet (
  1439. SaMsgHandleT msgHandle,
  1440. SaUint32T *metadataSize)
  1441. {
  1442. SaAisErrorT error;
  1443. struct msgInstance *msgInstance;
  1444. /* DEBUG */
  1445. printf ("[DEBUG]: saMsgMetadataSizeGet { msgHandle = %llx }\n",
  1446. (unsigned long long) msgHandle);
  1447. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  1448. (void *)&msgInstance);
  1449. if (error != SA_AIS_OK) {
  1450. return (error);
  1451. }
  1452. /* TODO */
  1453. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  1454. return (error);
  1455. }
  1456. SaAisErrorT
  1457. saMsgLimitGet (
  1458. SaMsgHandleT msgHandle,
  1459. SaMsgLimitIdT limitId,
  1460. SaLimitValueT *limitValue)
  1461. {
  1462. SaAisErrorT error;
  1463. struct msgInstance *msgInstance;
  1464. /* DEBUG */
  1465. printf ("[DEBUG]: saMsgLimitGet { msgHandle = %llx }\n",
  1466. (unsigned long long) msgHandle);
  1467. error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
  1468. (void *)&msgInstance);
  1469. if (error != SA_AIS_OK) {
  1470. return (error);
  1471. }
  1472. /* TODO */
  1473. saHandleInstancePut (&msgHandleDatabase, msgHandle);
  1474. return (error);
  1475. }