msg.c 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850
  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 <ipc_gen.h>
  49. #include <ipc_msg.h>
  50. #include <ais_util.h>
  51. #include <list.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. }