msg.c 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937
  1. /*
  2. * Copyright (c) 2005-2006 MontaVista Software, Inc.
  3. * Copyright (c) 2006 Red Hat, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@redhat.com)
  8. *
  9. * This software licensed under BSD license, the text of which follows:
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. * - Redistributions in binary form must reproduce the above copyright notice,
  17. * this list of conditions and the following disclaimer in the documentation
  18. * and/or other materials provided with the distribution.
  19. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  33. * THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #include <sys/types.h>
  36. #include <sys/uio.h>
  37. #include <sys/socket.h>
  38. #include <sys/un.h>
  39. #include <sys/time.h>
  40. #include <netinet/in.h>
  41. #include <unistd.h>
  42. #include <fcntl.h>
  43. #include <stdlib.h>
  44. #include <stdio.h>
  45. #include <errno.h>
  46. #include <signal.h>
  47. #include <arpa/inet.h>
  48. #include "../include/saAis.h"
  49. #include "../include/saMsg.h"
  50. #include "../include/ipc_msg.h"
  51. #include "../include/list.h"
  52. #include "../include/queue.h"
  53. #include "../lcr/lcr_comp.h"
  54. #include "objdb.h"
  55. #include "totem.h"
  56. #include "service.h"
  57. #include "mempool.h"
  58. #include "util.h"
  59. #include "main.h"
  60. #include "flow.h"
  61. #include "tlist.h"
  62. #include "ipc.h"
  63. #include "totempg.h"
  64. #include "logsys.h"
  65. LOGSYS_DECLARE_SUBSYS ("MSG", LOG_INFO);
  66. enum msg_exec_message_req_types {
  67. MESSAGE_REQ_EXEC_MSG_QUEUEOPEN = 0,
  68. MESSAGE_REQ_EXEC_MSG_QUEUECLOSE = 1,
  69. MESSAGE_REQ_EXEC_MSG_QUEUESTATUSGET = 2,
  70. MESSAGE_REQ_EXEC_MSG_QUEUEUNLINK = 3,
  71. MESSAGE_REQ_EXEC_MSG_QUEUEGROUPCREATE = 4,
  72. MESSAGE_REQ_EXEC_MSG_QUEUEGROUPINSERT = 5,
  73. MESSAGE_REQ_EXEC_MSG_QUEUEGROUPREMOVE = 6,
  74. MESSAGE_REQ_EXEC_MSG_QUEUEGROUPDELETE = 7,
  75. MESSAGE_REQ_EXEC_MSG_QUEUEGROUPTRACK = 8,
  76. MESSAGE_REQ_EXEC_MSG_QUEUEGROUPTRACKSTOP = 9,
  77. MESSAGE_REQ_EXEC_MSG_MESSAGESEND = 10,
  78. MESSAGE_REQ_EXEC_MSG_MESSAGEGET = 11,
  79. MESSAGE_REQ_EXEC_MSG_MESSAGECANCEL = 12,
  80. MESSAGE_REQ_EXEC_MSG_MESSAGESENDRECEIVE = 13,
  81. MESSAGE_REQ_EXEC_MSG_MESSAGEREPLY = 14
  82. };
  83. struct message_entry {
  84. SaTimeT time;
  85. SaMsgMessageT message;
  86. struct list_head list;
  87. };
  88. struct message_queue {
  89. SaNameT name;
  90. int refcount;
  91. struct list_head list;
  92. struct list_head message_list_head;
  93. };
  94. struct queue_group {
  95. SaNameT name;
  96. struct list_head list;
  97. struct list_head message_queue_head;
  98. };
  99. struct queue_group_entry {
  100. struct message_queue *message_queue;
  101. struct list_head list;
  102. };
  103. /*
  104. struct queue_cleanup {
  105. struct message_queue *queue;
  106. SaMsgResourceHandleT queue_handle;
  107. struct list_head queue_lock_list_head;
  108. struct list_head list;
  109. };
  110. */
  111. DECLARE_LIST_INIT(queue_list_head);
  112. DECLARE_LIST_INIT(queue_group_list_head);
  113. static int msg_exec_init_fn (struct objdb_iface_ver0 *objdb);
  114. static int msg_lib_exit_fn (void *conn);
  115. static int msg_lib_init_fn (void *conn);
  116. static void message_handler_req_exec_msg_queueopen (
  117. void *message,
  118. unsigned int nodeid);
  119. static void message_handler_req_exec_msg_queueclose (
  120. void *message,
  121. unsigned int nodeid);
  122. static void message_handler_req_exec_msg_queuestatusget (
  123. void *message,
  124. unsigned int nodeid);
  125. static void message_handler_req_exec_msg_queueunlink (
  126. void *message,
  127. unsigned int nodeid);
  128. static void message_handler_req_exec_msg_queuegroupcreate (
  129. void *message,
  130. unsigned int nodeid);
  131. static void message_handler_req_exec_msg_queuegroupinsert (
  132. void *message,
  133. unsigned int nodeid);
  134. static void message_handler_req_exec_msg_queuegroupremove (
  135. void *message,
  136. unsigned int nodeid);
  137. static void message_handler_req_exec_msg_queuegroupdelete (
  138. void *message,
  139. unsigned int nodeid);
  140. static void message_handler_req_exec_msg_queuegrouptrack (
  141. void *message,
  142. unsigned int nodeid);
  143. static void message_handler_req_exec_msg_queuegrouptrackstop (
  144. void *message,
  145. unsigned int nodeid);
  146. static void message_handler_req_exec_msg_messagesend (
  147. void *message,
  148. unsigned int nodeid);
  149. static void message_handler_req_exec_msg_messageget (
  150. void *message,
  151. unsigned int nodeid);
  152. static void message_handler_req_exec_msg_messagecancel (
  153. void *message,
  154. unsigned int nodeid);
  155. static void message_handler_req_exec_msg_messagesendreceive (
  156. void *message,
  157. unsigned int nodeid);
  158. static void message_handler_req_exec_msg_messagereply (
  159. void *message,
  160. unsigned int nodeid);
  161. static void message_handler_req_lib_msg_queueopen (
  162. void *conn,
  163. void *msg);
  164. static void message_handler_req_lib_msg_queueopenasync (
  165. void *conn,
  166. void *msg);
  167. static void message_handler_req_lib_msg_queueclose (
  168. void *conn,
  169. void *msg);
  170. static void message_handler_req_lib_msg_queuestatusget (
  171. void *conn,
  172. void *msg);
  173. static void message_handler_req_lib_msg_queueunlink (
  174. void *conn,
  175. void *msg);
  176. static void message_handler_req_lib_msg_queuegroupcreate (
  177. void *conn,
  178. void *msg);
  179. static void message_handler_req_lib_msg_queuegroupinsert (
  180. void *conn,
  181. void *msg);
  182. static void message_handler_req_lib_msg_queuegroupremove (
  183. void *conn,
  184. void *msg);
  185. static void message_handler_req_lib_msg_queuegroupdelete (
  186. void *conn,
  187. void *msg);
  188. static void message_handler_req_lib_msg_queuegrouptrack (
  189. void *conn,
  190. void *msg);
  191. static void message_handler_req_lib_msg_queuegrouptrackstop (
  192. void *conn,
  193. void *msg);
  194. static void message_handler_req_lib_msg_messagesend (
  195. void *conn,
  196. void *msg);
  197. static void message_handler_req_lib_msg_messagesendasync (
  198. void *conn,
  199. void *msg);
  200. static void message_handler_req_lib_msg_messageget (
  201. void *conn,
  202. void *msg);
  203. static void message_handler_req_lib_msg_messagecancel (
  204. void *conn,
  205. void *msg);
  206. static void message_handler_req_lib_msg_messagesendreceive (
  207. void *conn,
  208. void *msg);
  209. static void message_handler_req_lib_msg_messagereply (
  210. void *conn,
  211. void *msg);
  212. static void message_handler_req_lib_msg_messagereplyasync (
  213. void *conn,
  214. void *msg);
  215. #ifdef TODO
  216. static void msg_sync_init (void);
  217. #endif /* TODO */
  218. static void msg_sync_activate (void);
  219. static int msg_sync_process (void);
  220. static void msg_sync_abort(void);
  221. void queue_release (struct message_queue *queue);
  222. static void msg_confchg_fn (
  223. enum totem_configuration_type configuration_type,
  224. unsigned int *member_list, int member_list_entries,
  225. unsigned int *left_list, int left_list_entries,
  226. unsigned int *joined_list, int joined_list_entries,
  227. struct memb_ring_id *ring_id);
  228. struct msg_pd {
  229. struct list_head queue_list;
  230. struct list_head queue_cleanup_list;
  231. };
  232. /*
  233. * Executive Handler Definition
  234. */
  235. struct openais_lib_handler msg_lib_service[] =
  236. {
  237. { /* 0 */
  238. .lib_handler_fn = message_handler_req_lib_msg_queueopen,
  239. .response_size = sizeof (struct res_lib_msg_queueopen),
  240. .response_id = MESSAGE_RES_MSG_QUEUEOPEN,
  241. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  242. },
  243. { /* 1 */
  244. .lib_handler_fn = message_handler_req_lib_msg_queueopenasync,
  245. .response_size = sizeof (struct res_lib_msg_queueopenasync),
  246. .response_id = MESSAGE_RES_MSG_QUEUEOPENASYNC,
  247. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  248. },
  249. { /* 2 */
  250. .lib_handler_fn = message_handler_req_lib_msg_queueclose,
  251. .response_size = sizeof (struct res_lib_msg_queueclose),
  252. .response_id = MESSAGE_RES_MSG_QUEUECLOSE,
  253. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  254. },
  255. { /* 3 */
  256. .lib_handler_fn = message_handler_req_lib_msg_queuestatusget,
  257. .response_size = sizeof (struct res_lib_msg_queuestatusget),
  258. .response_id = MESSAGE_RES_MSG_QUEUESTATUSGET,
  259. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  260. },
  261. { /* 4 */
  262. .lib_handler_fn = message_handler_req_lib_msg_queueunlink,
  263. .response_size = sizeof (struct res_lib_msg_queueunlink),
  264. .response_id = MESSAGE_RES_MSG_QUEUEUNLINK,
  265. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  266. },
  267. { /* 5 */
  268. .lib_handler_fn = message_handler_req_lib_msg_queuegroupcreate,
  269. .response_size = sizeof (struct res_lib_msg_queuegroupcreate),
  270. .response_id = MESSAGE_RES_MSG_QUEUEGROUPCREATE,
  271. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  272. },
  273. { /* 6 */
  274. .lib_handler_fn = message_handler_req_lib_msg_queuegroupinsert,
  275. .response_size = sizeof (struct res_lib_msg_queuegroupinsert),
  276. .response_id = MESSAGE_RES_MSG_QUEUEGROUPINSERT,
  277. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  278. },
  279. { /* 7 */
  280. .lib_handler_fn = message_handler_req_lib_msg_queuegroupremove,
  281. .response_size = sizeof (struct res_lib_msg_queuegroupremove),
  282. .response_id = MESSAGE_RES_MSG_QUEUEGROUPREMOVE,
  283. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  284. },
  285. { /* 8 */
  286. .lib_handler_fn = message_handler_req_lib_msg_queuegroupdelete,
  287. .response_size = sizeof (struct res_lib_msg_queuegroupdelete),
  288. .response_id = MESSAGE_RES_MSG_QUEUEGROUPDELETE,
  289. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  290. },
  291. { /* 9 */
  292. .lib_handler_fn = message_handler_req_lib_msg_queuegrouptrack,
  293. .response_size = sizeof (struct res_lib_msg_queuegrouptrack),
  294. .response_id = MESSAGE_RES_MSG_QUEUEGROUPTRACK,
  295. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  296. },
  297. { /* 10 */
  298. .lib_handler_fn = message_handler_req_lib_msg_queuegrouptrackstop,
  299. .response_size = sizeof (struct res_lib_msg_queuegrouptrackstop),
  300. .response_id = MESSAGE_RES_MSG_QUEUEGROUPTRACKSTOP,
  301. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  302. },
  303. { /* 11 */
  304. .lib_handler_fn = message_handler_req_lib_msg_messagesend,
  305. .response_size = sizeof (struct res_lib_msg_messagesend),
  306. .response_id = MESSAGE_RES_MSG_MESSAGESEND,
  307. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  308. },
  309. { /* 12 */
  310. .lib_handler_fn = message_handler_req_lib_msg_messagesendasync,
  311. .response_size = sizeof (struct res_lib_msg_messagesendasync),
  312. .response_id = MESSAGE_RES_MSG_MESSAGESENDASYNC,
  313. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  314. },
  315. { /* 13 */
  316. .lib_handler_fn = message_handler_req_lib_msg_messageget,
  317. .response_size = sizeof (struct res_lib_msg_messageget),
  318. .response_id = MESSAGE_RES_MSG_MESSAGEGET,
  319. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  320. },
  321. { /* 14 */
  322. .lib_handler_fn = message_handler_req_lib_msg_messagecancel,
  323. .response_size = sizeof (struct res_lib_msg_messagecancel),
  324. .response_id = MESSAGE_RES_MSG_MESSAGECANCEL,
  325. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  326. },
  327. { /* 15 */
  328. .lib_handler_fn = message_handler_req_lib_msg_messagesendreceive,
  329. .response_size = sizeof (struct res_lib_msg_messagesendreceive),
  330. .response_id = MESSAGE_RES_MSG_MESSAGESENDRECEIVE,
  331. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  332. },
  333. { /* 16 */
  334. .lib_handler_fn = message_handler_req_lib_msg_messagereply,
  335. .response_size = sizeof (struct res_lib_msg_messagereply),
  336. .response_id = MESSAGE_RES_MSG_MESSAGEREPLY,
  337. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  338. },
  339. { /* 17 */
  340. .lib_handler_fn = message_handler_req_lib_msg_messagereplyasync,
  341. .response_size = sizeof (struct res_lib_msg_messagereplyasync),
  342. .response_id = MESSAGE_RES_MSG_MESSAGEREPLYASYNC,
  343. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  344. },
  345. };
  346. static struct openais_exec_handler msg_exec_service[] = {
  347. {
  348. .exec_handler_fn = message_handler_req_exec_msg_queueopen,
  349. },
  350. {
  351. .exec_handler_fn = message_handler_req_exec_msg_queueclose,
  352. },
  353. {
  354. .exec_handler_fn = message_handler_req_exec_msg_queuestatusget,
  355. },
  356. {
  357. .exec_handler_fn = message_handler_req_exec_msg_queueunlink,
  358. },
  359. {
  360. .exec_handler_fn = message_handler_req_exec_msg_queuegroupcreate,
  361. },
  362. {
  363. .exec_handler_fn = message_handler_req_exec_msg_queuegroupinsert,
  364. },
  365. {
  366. .exec_handler_fn = message_handler_req_exec_msg_queuegroupremove,
  367. },
  368. {
  369. .exec_handler_fn = message_handler_req_exec_msg_queuegroupdelete,
  370. },
  371. {
  372. .exec_handler_fn = message_handler_req_exec_msg_queuegrouptrack,
  373. },
  374. {
  375. .exec_handler_fn = message_handler_req_exec_msg_queuegrouptrackstop,
  376. },
  377. {
  378. .exec_handler_fn = message_handler_req_exec_msg_messagesend,
  379. },
  380. {
  381. .exec_handler_fn = message_handler_req_exec_msg_messageget,
  382. },
  383. {
  384. .exec_handler_fn = message_handler_req_exec_msg_messagecancel,
  385. },
  386. {
  387. .exec_handler_fn = message_handler_req_exec_msg_messagesendreceive,
  388. },
  389. {
  390. .exec_handler_fn = message_handler_req_exec_msg_messagereply
  391. }
  392. };
  393. struct openais_service_handler msg_service_handler = {
  394. .name = "openais message service B.01.01",
  395. .id = MSG_SERVICE,
  396. .private_data_size = sizeof (struct msg_pd),
  397. .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED,
  398. .lib_init_fn = msg_lib_init_fn,
  399. .lib_exit_fn = msg_lib_exit_fn,
  400. .lib_service = msg_lib_service,
  401. .lib_service_count = sizeof (msg_lib_service) / sizeof (struct openais_lib_handler),
  402. .exec_init_fn = msg_exec_init_fn,
  403. .exec_service = msg_exec_service,
  404. .exec_service_count = sizeof (msg_exec_service) / sizeof (struct openais_exec_handler),
  405. .confchg_fn = msg_confchg_fn,
  406. .exec_dump_fn = NULL,
  407. .sync_init = NULL, // TODO msg_sync_init,
  408. .sync_process = msg_sync_process,
  409. .sync_activate = msg_sync_activate,
  410. .sync_abort = msg_sync_abort
  411. };
  412. static struct openais_service_handler *msg_get_handler_ver0 (void);
  413. static struct openais_service_handler_iface_ver0 msg_service_handler_iface = {
  414. .openais_get_service_handler_ver0 = msg_get_handler_ver0
  415. };
  416. static struct lcr_iface openais_msg_ver0[1] = {
  417. {
  418. .name = "openais_msg",
  419. .version = 0,
  420. .versions_replace = 0,
  421. .versions_replace_count = 0,
  422. .dependencies = 0,
  423. .dependency_count = 0,
  424. .constructor = NULL,
  425. .destructor = NULL,
  426. .interfaces = NULL
  427. }
  428. };
  429. static struct lcr_comp msg_comp_ver0 = {
  430. .iface_count = 1,
  431. .ifaces = openais_msg_ver0
  432. };
  433. static struct openais_service_handler *msg_get_handler_ver0 (void)
  434. {
  435. return (&msg_service_handler);
  436. }
  437. __attribute__ ((constructor)) static void register_this_component (void) {
  438. lcr_interfaces_set (&openais_msg_ver0[0], &msg_service_handler_iface);
  439. lcr_component_register (&msg_comp_ver0);
  440. }
  441. /*
  442. * All data types used for executive messages
  443. */
  444. struct req_exec_msg_queueopen {
  445. mar_req_header_t header;
  446. mar_message_source_t source;
  447. int async_call;
  448. SaNameT queue_name;
  449. SaInvocationT invocation;
  450. SaMsgQueueHandleT queue_handle;
  451. SaMsgQueueCreationAttributesT creation_attributes;
  452. SaMsgQueueOpenFlagsT openFlags;
  453. SaTimeT timeout;
  454. };
  455. struct req_exec_msg_queueclose {
  456. mar_req_header_t header;
  457. mar_message_source_t source;
  458. SaNameT queue_name;
  459. };
  460. struct req_exec_msg_queuestatusget {
  461. mar_req_header_t header;
  462. mar_message_source_t source;
  463. SaNameT queue_name;
  464. };
  465. struct req_exec_msg_queueunlink {
  466. mar_req_header_t header;
  467. mar_message_source_t source;
  468. SaNameT queue_name;
  469. };
  470. struct req_exec_msg_queuegroupcreate {
  471. mar_req_header_t header;
  472. mar_message_source_t source;
  473. SaNameT queue_group_name;
  474. };
  475. struct req_exec_msg_queuegroupinsert {
  476. mar_req_header_t header;
  477. mar_message_source_t source;
  478. SaNameT queue_name;
  479. SaNameT queue_group_name;
  480. };
  481. struct req_exec_msg_queuegroupremove {
  482. mar_req_header_t header;
  483. mar_message_source_t source;
  484. SaNameT queue_name;
  485. SaNameT queue_group_name;
  486. };
  487. struct req_exec_msg_queuegroupdelete {
  488. mar_req_header_t header;
  489. mar_message_source_t source;
  490. SaNameT queue_group_name;
  491. };
  492. struct req_exec_msg_queuegrouptrack {
  493. mar_req_header_t header;
  494. mar_message_source_t source;
  495. SaNameT queue_group_name;
  496. };
  497. struct req_exec_msg_queuegrouptrackstop {
  498. mar_req_header_t header;
  499. mar_message_source_t source;
  500. SaNameT queue_group_name;
  501. };
  502. struct req_exec_msg_messagesend {
  503. mar_req_header_t header;
  504. mar_message_source_t source;
  505. SaNameT destination;
  506. SaTimeT timeout;
  507. SaMsgMessageT message;
  508. SaInvocationT invocation;
  509. SaMsgAckFlagsT ack_flags;
  510. int async_call;
  511. };
  512. struct req_exec_msg_messageget {
  513. mar_req_header_t header;
  514. mar_message_source_t source;
  515. SaNameT queue_name;
  516. };
  517. struct req_exec_msg_messagecancel {
  518. mar_req_header_t header;
  519. mar_message_source_t source;
  520. SaNameT queue_name;
  521. };
  522. struct req_exec_msg_messagesendreceive {
  523. mar_req_header_t header;
  524. mar_message_source_t source;
  525. SaNameT queue_name;
  526. };
  527. struct req_exec_msg_messagereply {
  528. mar_req_header_t header;
  529. mar_message_source_t source;
  530. SaNameT queue_name;
  531. int async_call;
  532. };
  533. #ifdef TODO
  534. static void msg_sync_init (void)
  535. {
  536. return;
  537. }
  538. #endif /* TODO */
  539. static int msg_sync_process (void)
  540. {
  541. return (0);
  542. }
  543. static void msg_sync_activate (void)
  544. {
  545. return;
  546. }
  547. static void msg_sync_abort (void)
  548. {
  549. return;
  550. }
  551. static void msg_confchg_fn (
  552. enum totem_configuration_type configuration_type,
  553. unsigned int *member_list, int member_list_entries,
  554. unsigned int *left_list, int left_list_entries,
  555. unsigned int *joined_list, int joined_list_entries,
  556. struct memb_ring_id *ring_id)
  557. {
  558. return;
  559. }
  560. static void print_message_list (struct message_queue *queue)
  561. {
  562. struct list_head *list;
  563. struct message_entry *entry;
  564. for (list = queue->message_list_head.next;
  565. list != &queue->message_list_head;
  566. list = list->next)
  567. {
  568. entry = list_entry (list, struct message_entry, list);
  569. log_printf (LOG_LEVEL_NOTICE, "[DEBUG]: print_message_list (%s) (%llu)\n",
  570. (char *)(entry->message.data), (unsigned long long)(entry->time));
  571. }
  572. }
  573. static struct message_queue *queue_find (SaNameT *name)
  574. {
  575. struct list_head *list;
  576. struct message_queue *queue;
  577. for (list = queue_list_head.next;
  578. list != &queue_list_head;
  579. list = list->next)
  580. {
  581. queue = list_entry (list, struct message_queue, list);
  582. if (name_match (name, &queue->name)) {
  583. return (queue);
  584. }
  585. }
  586. return (0);
  587. }
  588. static struct queue_group *queue_group_find (SaNameT *name)
  589. {
  590. struct list_head *list;
  591. struct queue_group *queue_group;
  592. for (list = queue_group_list_head.next;
  593. list != &queue_group_list_head;
  594. list = list->next)
  595. {
  596. queue_group = list_entry (list, struct queue_group, list);
  597. if (name_match (name, &queue_group->name)) {
  598. return (queue_group);
  599. }
  600. }
  601. return (0);
  602. }
  603. static struct queue_group_entry *queue_group_entry_find (
  604. struct queue_group *queue_group,
  605. struct message_queue *queue)
  606. {
  607. struct list_head *list;
  608. struct queue_group_entry *queue_group_entry;
  609. for (list = queue_group->message_queue_head.next;
  610. list != &queue_group->message_queue_head;
  611. list = list->next)
  612. {
  613. queue_group_entry = list_entry (list, struct queue_group_entry, list);
  614. if (queue_group_entry->message_queue == queue) {
  615. return (queue_group_entry);
  616. }
  617. }
  618. return (0);
  619. }
  620. static int msg_exec_init_fn (struct objdb_iface_ver0 *objdb)
  621. {
  622. /*
  623. * Initialize the saved ring ID.
  624. */
  625. /* saved_ring_id.seq = 0; */
  626. /* saved_ring_id.rep.s_addr = this_ip->sin_addr.s_addr; */
  627. return (0);
  628. }
  629. static int msg_lib_exit_fn (void *conn)
  630. {
  631. /*
  632. * struct msg_pd *msg_pd = (struct msg_pd *)openais_conn_private_data_get (conn);
  633. */
  634. #ifdef COMPILE_OUT
  635. struct queue_cleanup *queue_cleanup;
  636. struct list_head *list;
  637. /*
  638. * close all queues opened on this fd
  639. */
  640. list = conn_info->conn_info_partner->ais_ci.u.libmsg_ci.queue_cleanup_list.next;
  641. while (!list_empty(&conn_info->conn_info_partner->ais_ci.u.libmsg_ci.queue_cleanup_list)) {
  642. queue_cleanup = list_entry (list, struct queue_cleanup, list);
  643. if (queue_cleanup->queue->name.length > 0) {
  644. msg_queue_cleanup_lock_remove (queue_cleanup);
  645. msg_queue_close (queue_cleanup->queue);
  646. }
  647. list_del (&queue_cleanup->list);
  648. free (queue_cleanup);
  649. list = conn_info->conn_info_partner->ais_ci.u.libmsg_ci.queue_cleanup_list.next;
  650. }
  651. #endif /* COMPILE_OUT */
  652. return (0);
  653. }
  654. static int msg_lib_init_fn (void *conn)
  655. {
  656. struct msg_pd *msg_pd = (struct msg_pd *)openais_conn_private_data_get (conn);
  657. list_init (&msg_pd->queue_list);
  658. list_init (&msg_pd->queue_cleanup_list);
  659. return (0);
  660. }
  661. static void message_handler_req_exec_msg_queueopen (
  662. void *message,
  663. unsigned int nodeid)
  664. {
  665. struct req_exec_msg_queueopen *req_exec_msg_queueopen =
  666. (struct req_exec_msg_queueopen *)message;
  667. struct res_lib_msg_queueopen res_lib_msg_queueopen;
  668. struct res_lib_msg_queueopenasync res_lib_msg_queueopenasync;
  669. struct message_queue *queue;
  670. /* struct queue_cleanup *queue_cleanup; */
  671. SaAisErrorT error = SA_AIS_OK;
  672. log_printf (LOG_LEVEL_NOTICE, "EXEC request: saMsgQueueOpen %s\n",
  673. getSaNameT (&req_exec_msg_queueopen->queue_name));
  674. queue = queue_find (&req_exec_msg_queueopen->queue_name);
  675. /*
  676. * If queue doesn't exist, create one
  677. */
  678. if (queue == 0) {
  679. if ((req_exec_msg_queueopen->openFlags & SA_MSG_QUEUE_CREATE) == 0) {
  680. error = SA_AIS_ERR_NOT_EXIST;
  681. goto error_exit;
  682. }
  683. queue = malloc (sizeof (struct message_queue));
  684. if (queue == 0) {
  685. error = SA_AIS_ERR_NO_MEMORY;
  686. goto error_exit;
  687. }
  688. memset (queue, 0, sizeof (struct message_queue));
  689. memcpy (&queue->name,
  690. &req_exec_msg_queueopen->queue_name,
  691. sizeof (SaNameT));
  692. list_init (&queue->list);
  693. list_init (&queue->message_list_head);
  694. list_add (&queue->list, &queue_list_head);
  695. queue->refcount = 0;
  696. }
  697. queue->refcount += 1;
  698. #ifdef COMPILE_OUT
  699. /*
  700. * Setup connection information and mark queue as referenced
  701. */
  702. queue_cleanup = malloc (sizeof (struct queue_cleanup));
  703. if (queue_cleanup == 0) {
  704. free (queue);
  705. error = SA_AIS_ERR_NO_MEMORY;
  706. } else {
  707. list_init (&queue_cleanup->list);
  708. list_init (&queue_cleanup->queue_lock_list_head);
  709. queue_cleanup->queue = queue;
  710. queue_cleanup->queue_handle = req_exec_msg_queueopen->queue_handle;
  711. list_add (
  712. &queue_cleanup->list,
  713. &req_exec_msg_queueopen->source.conn_info->ais_ci.u.libmsg_ci.queue_cleanup_list);
  714. }
  715. queue->refcount += 1;
  716. #endif /* COMPILE_OUT */
  717. /*
  718. * Send error result to MSG library
  719. */
  720. error_exit:
  721. /*
  722. * If this node was the source of the message, respond to this node
  723. */
  724. if (message_source_is_local (&req_exec_msg_queueopen->source)) {
  725. /*
  726. * If its an async call respond with the invocation and handle
  727. */
  728. if (req_exec_msg_queueopen->async_call)
  729. {
  730. res_lib_msg_queueopenasync.header.size =
  731. sizeof (struct res_lib_msg_queueopenasync);
  732. res_lib_msg_queueopenasync.header.id =
  733. MESSAGE_RES_MSG_QUEUEOPENASYNC;
  734. res_lib_msg_queueopenasync.header.error = error;
  735. res_lib_msg_queueopenasync.invocation =
  736. req_exec_msg_queueopen->invocation;
  737. res_lib_msg_queueopenasync.queueHandle =
  738. req_exec_msg_queueopen->queue_handle;
  739. memcpy (&res_lib_msg_queueopenasync.source,
  740. &req_exec_msg_queueopen->source,
  741. sizeof (mar_message_source_t));
  742. openais_conn_send_response (
  743. req_exec_msg_queueopen->source.conn,
  744. &res_lib_msg_queueopenasync,
  745. sizeof (struct res_lib_msg_queueopenasync));
  746. openais_conn_send_response (
  747. openais_conn_partner_get (req_exec_msg_queueopen->source.conn),
  748. &res_lib_msg_queueopenasync,
  749. sizeof (struct res_lib_msg_queueopenasync));
  750. } else {
  751. /*
  752. * otherwise respond with the normal queueopen response
  753. */
  754. res_lib_msg_queueopen.header.size =
  755. sizeof (struct res_lib_msg_queueopen);
  756. res_lib_msg_queueopen.header.id =
  757. MESSAGE_RES_MSG_QUEUEOPEN;
  758. res_lib_msg_queueopen.header.error = error;
  759. res_lib_msg_queueopen.queueHandle =
  760. req_exec_msg_queueopen->queue_handle;
  761. memcpy (&res_lib_msg_queueopen.source,
  762. &req_exec_msg_queueopen->source,
  763. sizeof (mar_message_source_t));
  764. openais_conn_send_response (
  765. req_exec_msg_queueopen->source.conn,
  766. &res_lib_msg_queueopen,
  767. sizeof (struct res_lib_msg_queueopen));
  768. }
  769. }
  770. }
  771. static void message_handler_req_exec_msg_queueclose (
  772. void *message,
  773. unsigned int nodeid)
  774. {
  775. struct req_exec_msg_queueclose *req_exec_msg_queueclose =
  776. (struct req_exec_msg_queueclose *)message;
  777. struct res_lib_msg_queueclose res_lib_msg_queueclose;
  778. struct message_queue *queue = 0;
  779. SaAisErrorT error = SA_AIS_OK;
  780. log_printf (LOG_LEVEL_NOTICE, "EXEC request: saMsgQueueClose %s\n",
  781. getSaNameT (&req_exec_msg_queueclose->queue_name));
  782. queue = queue_find (&req_exec_msg_queueclose->queue_name);
  783. if (queue == 0) {
  784. goto error_exit;
  785. }
  786. queue->refcount -= 1;
  787. if (queue->refcount == 0) {
  788. /* free queue */
  789. }
  790. error_exit:
  791. if (message_source_is_local(&req_exec_msg_queueclose->source))
  792. {
  793. /* TODO */
  794. /*
  795. * msg_queue_cleanup_remove (
  796. * req_exec_msg_queueclose->source.conn_info,
  797. * req_exec_msg_queueclose->queue_handle);
  798. */
  799. res_lib_msg_queueclose.header.size =
  800. sizeof (struct res_lib_msg_queueclose);
  801. res_lib_msg_queueclose.header.id =
  802. MESSAGE_RES_MSG_QUEUECLOSE;
  803. res_lib_msg_queueclose.header.error = error;
  804. openais_conn_send_response (
  805. req_exec_msg_queueclose->source.conn,
  806. &res_lib_msg_queueclose,
  807. sizeof (struct res_lib_msg_queueclose));
  808. }
  809. }
  810. static void message_handler_req_exec_msg_queuestatusget (
  811. void *message,
  812. unsigned int nodeid)
  813. {
  814. #if 0
  815. struct req_exec_msg_queuestatusget *req_exec_msg_queuestatusget =
  816. (struct req_exec_msg_queuestatusget *)message;
  817. struct res_lib_msg_queuestatusget res_lib_msg_queuestatusget;
  818. #endif
  819. }
  820. static void message_handler_req_exec_msg_queueunlink (
  821. void *message,
  822. unsigned int nodeid)
  823. {
  824. #if 0
  825. struct req_exec_msg_queueunlink *req_exec_msg_queueunlink =
  826. (struct req_exec_msg_queueunlink *)message;
  827. struct res_lib_msg_queueunlink res_lib_msg_queueunlink;
  828. #endif
  829. }
  830. static void message_handler_req_exec_msg_queuegroupcreate (
  831. void *message,
  832. unsigned int nodeid)
  833. {
  834. struct req_exec_msg_queuegroupcreate *req_exec_msg_queuegroupcreate =
  835. (struct req_exec_msg_queuegroupcreate *)message;
  836. struct res_lib_msg_queuegroupcreate res_lib_msg_queuegroupcreate;
  837. struct queue_group *queue_group;
  838. SaAisErrorT error = SA_AIS_OK;
  839. queue_group = queue_group_find (&req_exec_msg_queuegroupcreate->queue_group_name);
  840. if (queue_group == 0) {
  841. queue_group = malloc (sizeof (struct queue_group));
  842. if (queue_group == 0) {
  843. error = SA_AIS_ERR_NO_MEMORY;
  844. goto error_exit;
  845. }
  846. memset (queue_group, 0, sizeof (struct queue_group));
  847. memcpy (&queue_group->name,
  848. &req_exec_msg_queuegroupcreate->queue_group_name,
  849. sizeof (SaNameT));
  850. list_init (&queue_group->list);
  851. list_init (&queue_group->message_queue_head);
  852. list_add (&queue_group->list, &queue_group_list_head);
  853. } else {
  854. error = SA_AIS_ERR_EXIST;
  855. }
  856. error_exit:
  857. if (message_source_is_local(&req_exec_msg_queuegroupcreate->source)) {
  858. res_lib_msg_queuegroupcreate.header.size =
  859. sizeof (struct res_lib_msg_queuegroupcreate);
  860. res_lib_msg_queuegroupcreate.header.id =
  861. MESSAGE_RES_MSG_QUEUEGROUPCREATE;
  862. res_lib_msg_queuegroupcreate.header.error = error;
  863. openais_conn_send_response (
  864. req_exec_msg_queuegroupcreate->source.conn,
  865. &res_lib_msg_queuegroupcreate,
  866. sizeof (struct res_lib_msg_queuegroupcreate));
  867. }
  868. }
  869. static void message_handler_req_exec_msg_queuegroupinsert (
  870. void *message,
  871. unsigned int nodeid)
  872. {
  873. struct req_exec_msg_queuegroupinsert *req_exec_msg_queuegroupinsert =
  874. (struct req_exec_msg_queuegroupinsert *)message;
  875. struct res_lib_msg_queuegroupinsert res_lib_msg_queuegroupinsert;
  876. struct message_queue *queue;
  877. struct queue_group *queue_group;
  878. struct queue_group_entry *queue_group_entry;
  879. SaAisErrorT error = SA_AIS_OK;
  880. queue_group = queue_group_find (&req_exec_msg_queuegroupinsert->queue_group_name);
  881. if (queue_group == 0) {
  882. error = SA_AIS_ERR_NOT_EXIST;
  883. goto error_exit;
  884. }
  885. queue = queue_find (&req_exec_msg_queuegroupinsert->queue_name);
  886. if (queue == 0) {
  887. error = SA_AIS_ERR_NOT_EXIST;
  888. goto error_exit;
  889. }
  890. queue_group_entry = malloc (sizeof (struct queue_group_entry));
  891. if (queue_group_entry == 0) {
  892. error = SA_AIS_ERR_NO_MEMORY;
  893. goto error_exit;
  894. }
  895. list_init (&queue_group_entry->list);
  896. list_add (&queue_group_entry->list, &queue_group->message_queue_head);
  897. list_add (&queue->list, &queue_list_head);
  898. queue_group_entry->message_queue = queue;
  899. error_exit:
  900. if (message_source_is_local(&req_exec_msg_queuegroupinsert->source)) {
  901. res_lib_msg_queuegroupinsert.header.size =
  902. sizeof (struct res_lib_msg_queuegroupinsert);
  903. res_lib_msg_queuegroupinsert.header.id =
  904. MESSAGE_RES_MSG_QUEUEGROUPINSERT;
  905. res_lib_msg_queuegroupinsert.header.error = error;
  906. openais_conn_send_response (
  907. req_exec_msg_queuegroupinsert->source.conn,
  908. &res_lib_msg_queuegroupinsert,
  909. sizeof (struct res_lib_msg_queuegroupinsert));
  910. }
  911. }
  912. static void message_handler_req_exec_msg_queuegroupremove (
  913. void *message,
  914. unsigned int nodeid)
  915. {
  916. struct req_exec_msg_queuegroupremove *req_exec_msg_queuegroupremove =
  917. (struct req_exec_msg_queuegroupremove *)message;
  918. struct res_lib_msg_queuegroupremove res_lib_msg_queuegroupremove;
  919. struct queue_group *queue_group;
  920. struct message_queue *queue;
  921. struct queue_group_entry *queue_group_entry;
  922. SaAisErrorT error = SA_AIS_OK;
  923. queue_group = queue_group_find (&req_exec_msg_queuegroupremove->queue_group_name);
  924. if (queue_group == 0) {
  925. error = SA_AIS_ERR_NOT_EXIST;
  926. goto error_exit;
  927. }
  928. queue = queue_find (&req_exec_msg_queuegroupremove->queue_name);
  929. if (queue == 0) {
  930. error = SA_AIS_ERR_NOT_EXIST;
  931. goto error_exit;
  932. }
  933. queue_group_entry = queue_group_entry_find (queue_group, queue);
  934. if (queue_group_entry == 0) {
  935. error = SA_AIS_ERR_NOT_EXIST;
  936. goto error_exit;
  937. }
  938. list_del (&queue_group_entry->list);
  939. error_exit:
  940. if (message_source_is_local(&req_exec_msg_queuegroupremove->source)) {
  941. res_lib_msg_queuegroupremove.header.size =
  942. sizeof (struct res_lib_msg_queuegroupremove);
  943. res_lib_msg_queuegroupremove.header.id =
  944. MESSAGE_RES_MSG_QUEUEGROUPREMOVE;
  945. res_lib_msg_queuegroupremove.header.error = error;
  946. openais_conn_send_response (
  947. req_exec_msg_queuegroupremove->source.conn,
  948. &res_lib_msg_queuegroupremove,
  949. sizeof (struct res_lib_msg_queuegroupremove));
  950. }
  951. }
  952. static void message_handler_req_exec_msg_queuegroupdelete (
  953. void *message,
  954. unsigned int nodeid)
  955. {
  956. struct req_exec_msg_queuegroupdelete *req_exec_msg_queuegroupdelete =
  957. (struct req_exec_msg_queuegroupdelete *)message;
  958. struct res_lib_msg_queuegroupdelete res_lib_msg_queuegroupdelete;
  959. struct queue_group *queue_group;
  960. SaAisErrorT error = SA_AIS_OK;
  961. queue_group = queue_group_find (&req_exec_msg_queuegroupdelete->queue_group_name);
  962. if (queue_group) {
  963. list_del (&queue_group->list);
  964. free (queue_group);
  965. } else {
  966. error = SA_AIS_ERR_NOT_EXIST;
  967. }
  968. if (message_source_is_local(&req_exec_msg_queuegroupdelete->source)) {
  969. res_lib_msg_queuegroupdelete.header.size =
  970. sizeof (struct res_lib_msg_queuegroupdelete);
  971. res_lib_msg_queuegroupdelete.header.id =
  972. MESSAGE_RES_MSG_QUEUEGROUPDELETE;
  973. res_lib_msg_queuegroupdelete.header.error = error;
  974. openais_conn_send_response (
  975. req_exec_msg_queuegroupdelete->source.conn,
  976. &res_lib_msg_queuegroupdelete,
  977. sizeof (struct res_lib_msg_queuegroupdelete));
  978. }
  979. }
  980. static void message_handler_req_exec_msg_queuegrouptrack (
  981. void *message,
  982. unsigned int nodeid)
  983. {
  984. #if 0
  985. struct req_exec_msg_queuegrouptrack *req_exec_msg_queuegrouptrack =
  986. (struct req_exec_msg_queuegrouptrack *)message;
  987. struct res_lib_msg_queuegrouptrack res_lib_msg_queuegrouptrack;
  988. #endif
  989. }
  990. static void message_handler_req_exec_msg_queuegrouptrackstop (
  991. void *message,
  992. unsigned int nodeid)
  993. {
  994. #if 0
  995. struct req_exec_msg_queuegrouptrackstop *req_exec_msg_queuegrouptrackstop =
  996. (struct req_exec_msg_queuegrouptrackstop *)message;
  997. struct res_lib_msg_queuegrouptrackstop res_lib_msg_queuegrouptrackstop;
  998. #endif
  999. }
  1000. static void message_handler_req_exec_msg_messagesend (
  1001. void *message,
  1002. unsigned int nodeid)
  1003. {
  1004. struct req_exec_msg_messagesend *req_exec_msg_messagesend =
  1005. (struct req_exec_msg_messagesend *)message;
  1006. struct res_lib_msg_messagesend res_lib_msg_messagesend;
  1007. struct res_lib_msg_messagesendasync res_lib_msg_messagesendasync;
  1008. struct message_queue *queue;
  1009. struct message_entry *entry;
  1010. SaAisErrorT error = SA_AIS_OK;
  1011. char *data = ((char *)(req_exec_msg_messagesend) +
  1012. sizeof (struct req_exec_msg_messagesend));
  1013. log_printf (LOG_LEVEL_NOTICE, "EXEC request: saMsgMessageSend %s\n",
  1014. getSaNameT (&req_exec_msg_messagesend->destination));
  1015. queue = queue_find (&req_exec_msg_messagesend->destination);
  1016. if (queue == NULL) {
  1017. error = SA_AIS_ERR_NOT_EXIST;
  1018. goto error_exit;
  1019. }
  1020. entry = malloc (sizeof (struct message_entry));
  1021. if (entry == NULL) {
  1022. error = SA_AIS_ERR_NO_MEMORY;
  1023. goto error_exit;
  1024. }
  1025. memset (entry, 0, sizeof (struct message_entry));
  1026. memcpy (&entry->message, &req_exec_msg_messagesend->message,
  1027. sizeof (SaMsgMessageT));
  1028. entry->message.data = malloc (entry->message.size);
  1029. if (entry->message.data == NULL) {
  1030. error = SA_AIS_ERR_NO_MEMORY;
  1031. goto error_exit;
  1032. }
  1033. memset (entry->message.data, 0, entry->message.size);
  1034. memcpy (entry->message.data, (void *)(data), entry->message.size);
  1035. entry->time = clust_time_now();
  1036. list_add_tail (&entry->list, &queue->message_list_head);
  1037. /* DEBUG */
  1038. print_message_list (queue);
  1039. error_exit:
  1040. if (message_source_is_local(&req_exec_msg_messagesend->source)) {
  1041. if (req_exec_msg_messagesend->async_call) {
  1042. res_lib_msg_messagesendasync.header.size =
  1043. sizeof (struct res_lib_msg_messagesendasync);
  1044. res_lib_msg_messagesendasync.header.id =
  1045. MESSAGE_RES_MSG_MESSAGESENDASYNC;
  1046. res_lib_msg_messagesendasync.header.error = error;
  1047. res_lib_msg_messagesendasync.invocation =
  1048. req_exec_msg_messagesend->invocation;
  1049. memcpy (&res_lib_msg_messagesendasync.source,
  1050. &req_exec_msg_messagesend->source,
  1051. sizeof (mar_message_source_t));
  1052. openais_conn_send_response (
  1053. req_exec_msg_messagesend->source.conn,
  1054. &res_lib_msg_messagesendasync,
  1055. sizeof (struct res_lib_msg_messagesendasync));
  1056. openais_conn_send_response (
  1057. openais_conn_partner_get (req_exec_msg_messagesend->source.conn),
  1058. &res_lib_msg_messagesendasync,
  1059. sizeof (struct res_lib_msg_messagesendasync));
  1060. } else {
  1061. res_lib_msg_messagesend.header.size =
  1062. sizeof (struct res_lib_msg_messagesend);
  1063. res_lib_msg_messagesend.header.id =
  1064. MESSAGE_RES_MSG_MESSAGESEND;
  1065. res_lib_msg_messagesend.header.error = error;
  1066. memcpy (&res_lib_msg_messagesend.source,
  1067. &req_exec_msg_messagesend->source,
  1068. sizeof (mar_message_source_t));
  1069. openais_conn_send_response (
  1070. req_exec_msg_messagesend->source.conn,
  1071. &res_lib_msg_messagesend,
  1072. sizeof (struct res_lib_msg_messagesend));
  1073. }
  1074. }
  1075. }
  1076. static void message_handler_req_exec_msg_messageget (
  1077. void *message,
  1078. unsigned int nodeid)
  1079. {
  1080. struct req_exec_msg_messageget *req_exec_msg_messageget =
  1081. (struct req_exec_msg_messageget *)message;
  1082. struct res_lib_msg_messageget res_lib_msg_messageget;
  1083. struct message_queue *queue;
  1084. struct message_entry *entry;
  1085. SaAisErrorT error = SA_AIS_OK;
  1086. log_printf (LOG_LEVEL_NOTICE, "EXEC request: saMsgMessageGet %s\n",
  1087. getSaNameT (&req_exec_msg_messageget->queue_name));
  1088. queue = queue_find (&req_exec_msg_messageget->queue_name);
  1089. if (queue == NULL) {
  1090. error = SA_AIS_ERR_NOT_EXIST;
  1091. goto error_exit;
  1092. }
  1093. if (list_empty (queue->message_list_head.next)) {
  1094. error = SA_AIS_ERR_TIMEOUT; /* FIX ME */
  1095. goto error_exit;
  1096. }
  1097. entry = list_entry (queue->message_list_head.next, struct message_entry, list);
  1098. if (entry == NULL) {
  1099. error = SA_AIS_ERR_LIBRARY; /* FIX ME */
  1100. goto error_exit;
  1101. }
  1102. list_del (queue->message_list_head.next);
  1103. error_exit:
  1104. if (message_source_is_local(&req_exec_msg_messageget->source)) {
  1105. res_lib_msg_messageget.header.size =
  1106. sizeof (struct res_lib_msg_messageget);
  1107. res_lib_msg_messageget.header.id =
  1108. MESSAGE_RES_MSG_MESSAGEGET;
  1109. res_lib_msg_messageget.header.error = error;
  1110. memcpy (&res_lib_msg_messageget.message, &entry->message,
  1111. sizeof (SaMsgMessageT));
  1112. memcpy (&res_lib_msg_messageget.source,
  1113. &req_exec_msg_messageget->source,
  1114. sizeof (mar_message_source_t));
  1115. openais_conn_send_response (
  1116. req_exec_msg_messageget->source.conn,
  1117. &res_lib_msg_messageget,
  1118. sizeof (struct res_lib_msg_messageget));
  1119. openais_conn_send_response (
  1120. req_exec_msg_messageget->source.conn,
  1121. res_lib_msg_messageget.message.data,
  1122. res_lib_msg_messageget.message.size);
  1123. }
  1124. }
  1125. static void message_handler_req_exec_msg_messagecancel (
  1126. void *message,
  1127. unsigned int nodeid)
  1128. {
  1129. #if 0
  1130. struct req_exec_msg_messagecancel *req_exec_msg_messagecancel =
  1131. (struct req_exec_msg_messagecancel *)message;
  1132. struct res_lib_msg_messagecancel res_lib_msg_messagecancel;
  1133. #endif
  1134. }
  1135. static void message_handler_req_exec_msg_messagesendreceive (
  1136. void *message,
  1137. unsigned int nodeid)
  1138. {
  1139. #if 0
  1140. struct req_exec_msg_messagesendreceive *req_exec_msg_messagesendreceive =
  1141. (struct req_exec_msg_messagesendreceive *)message;
  1142. struct res_lib_msg_messagesendreceive res_lib_msg_messagesendreceive;
  1143. #endif
  1144. }
  1145. static void message_handler_req_exec_msg_messagereply (
  1146. void *message,
  1147. unsigned int nodeid)
  1148. {
  1149. #if 0
  1150. struct req_exec_msg_messagereply *req_exec_msg_messagereply =
  1151. (struct req_exec_msg_messagereply *)message;
  1152. struct res_lib_msg_messagereply res_lib_msg_messagereply;
  1153. #endif
  1154. }
  1155. static void message_handler_req_lib_msg_queueopen (
  1156. void *conn,
  1157. void *msg)
  1158. {
  1159. struct req_lib_msg_queueopen *req_lib_msg_queueopen =
  1160. (struct req_lib_msg_queueopen *)msg;
  1161. struct req_exec_msg_queueopen req_exec_msg_queueopen;
  1162. struct iovec iovec;
  1163. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueOpen %s\n",
  1164. getSaNameT (&req_lib_msg_queueopen->queueName));
  1165. req_exec_msg_queueopen.header.size =
  1166. sizeof (struct req_exec_msg_queueopen);
  1167. req_exec_msg_queueopen.header.id =
  1168. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEOPEN);
  1169. message_source_set (&req_exec_msg_queueopen.source, conn);
  1170. memcpy (&req_exec_msg_queueopen.queue_name,
  1171. &req_lib_msg_queueopen->queueName, sizeof (SaNameT));
  1172. memcpy (&req_exec_msg_queueopen.creation_attributes,
  1173. &req_lib_msg_queueopen->creationAttributes,
  1174. sizeof (SaMsgQueueCreationAttributesT));
  1175. req_exec_msg_queueopen.async_call = 0;
  1176. req_exec_msg_queueopen.invocation = 0;
  1177. req_exec_msg_queueopen.queue_handle = req_lib_msg_queueopen->queueHandle;
  1178. req_exec_msg_queueopen.openFlags = req_lib_msg_queueopen->openFlags;
  1179. req_exec_msg_queueopen.timeout = req_lib_msg_queueopen->timeout;
  1180. iovec.iov_base = (char *)&req_exec_msg_queueopen;
  1181. iovec.iov_len = sizeof (req_exec_msg_queueopen);
  1182. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1183. TOTEMPG_AGREED) == 0);
  1184. }
  1185. static void message_handler_req_lib_msg_queueopenasync (
  1186. void *conn,
  1187. void *msg)
  1188. {
  1189. struct req_lib_msg_queueopen *req_lib_msg_queueopen =
  1190. (struct req_lib_msg_queueopen *)msg;
  1191. struct req_exec_msg_queueopen req_exec_msg_queueopen;
  1192. struct iovec iovec;
  1193. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueOpenAsync %s\n",
  1194. getSaNameT (&req_lib_msg_queueopen->queueName));
  1195. req_exec_msg_queueopen.header.size =
  1196. sizeof (struct req_exec_msg_queueopen);
  1197. req_exec_msg_queueopen.header.id =
  1198. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEOPEN);
  1199. message_source_set (&req_exec_msg_queueopen.source, conn);
  1200. memcpy (&req_exec_msg_queueopen.queue_name,
  1201. &req_lib_msg_queueopen->queueName, sizeof (SaNameT));
  1202. memcpy (&req_exec_msg_queueopen.creation_attributes,
  1203. &req_lib_msg_queueopen->creationAttributes,
  1204. sizeof (SaMsgQueueCreationAttributesT));
  1205. req_exec_msg_queueopen.async_call = 1;
  1206. req_exec_msg_queueopen.invocation = req_lib_msg_queueopen->invocation;
  1207. req_exec_msg_queueopen.queue_handle = req_lib_msg_queueopen->queueHandle;
  1208. req_exec_msg_queueopen.openFlags = req_lib_msg_queueopen->openFlags;
  1209. req_exec_msg_queueopen.timeout = SA_TIME_END;
  1210. iovec.iov_base = (char *)&req_exec_msg_queueopen;
  1211. iovec.iov_len = sizeof (req_exec_msg_queueopen);
  1212. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1213. TOTEMPG_AGREED) == 0);
  1214. }
  1215. static void message_handler_req_lib_msg_queueclose (
  1216. void *conn,
  1217. void *msg)
  1218. {
  1219. struct req_lib_msg_queueclose *req_lib_msg_queueclose =
  1220. (struct req_lib_msg_queueclose *)msg;
  1221. struct req_exec_msg_queueclose req_exec_msg_queueclose;
  1222. struct iovec iovec;
  1223. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueClose %s\n",
  1224. getSaNameT (&req_lib_msg_queueclose->queueName));
  1225. req_exec_msg_queueclose.header.size =
  1226. sizeof (struct req_exec_msg_queueclose);
  1227. req_exec_msg_queueclose.header.id =
  1228. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUECLOSE);
  1229. message_source_set (&req_exec_msg_queueclose.source, conn);
  1230. memcpy (&req_exec_msg_queueclose.queue_name,
  1231. &req_lib_msg_queueclose->queueName, sizeof (SaNameT));
  1232. iovec.iov_base = (char *)&req_exec_msg_queueclose;
  1233. iovec.iov_len = sizeof (req_exec_msg_queueclose);
  1234. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1235. TOTEMPG_AGREED) == 0);
  1236. }
  1237. static void message_handler_req_lib_msg_queuestatusget (
  1238. void *conn,
  1239. void *msg)
  1240. {
  1241. struct req_lib_msg_queuestatusget *req_lib_msg_queuestatusget =
  1242. (struct req_lib_msg_queuestatusget *)msg;
  1243. struct req_exec_msg_queuestatusget req_exec_msg_queuestatusget;
  1244. struct iovec iovec;
  1245. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueStatusGet %s\n",
  1246. getSaNameT (&req_lib_msg_queuestatusget->queueName));
  1247. req_exec_msg_queuestatusget.header.size =
  1248. sizeof (struct req_exec_msg_queuestatusget);
  1249. req_exec_msg_queuestatusget.header.id =
  1250. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUESTATUSGET);
  1251. message_source_set (&req_exec_msg_queuestatusget.source, conn);
  1252. memcpy (&req_exec_msg_queuestatusget.queue_name,
  1253. &req_lib_msg_queuestatusget->queueName, sizeof (SaNameT));
  1254. iovec.iov_base = (char *)&req_exec_msg_queuestatusget;
  1255. iovec.iov_len = sizeof (req_exec_msg_queuestatusget);
  1256. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1257. TOTEMPG_AGREED) == 0);
  1258. }
  1259. static void message_handler_req_lib_msg_queueunlink (
  1260. void *conn,
  1261. void *msg)
  1262. {
  1263. struct req_lib_msg_queueunlink *req_lib_msg_queueunlink =
  1264. (struct req_lib_msg_queueunlink *)msg;
  1265. struct req_exec_msg_queueunlink req_exec_msg_queueunlink;
  1266. struct iovec iovec;
  1267. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueUnlink %s\n",
  1268. getSaNameT (&req_lib_msg_queueunlink->queueName));
  1269. req_exec_msg_queueunlink.header.size =
  1270. sizeof (struct req_exec_msg_queueunlink);
  1271. req_exec_msg_queueunlink.header.id =
  1272. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEUNLINK);
  1273. message_source_set (&req_exec_msg_queueunlink.source, conn);
  1274. memcpy (&req_exec_msg_queueunlink.queue_name,
  1275. &req_lib_msg_queueunlink->queueName, sizeof (SaNameT));
  1276. iovec.iov_base = (char *)&req_exec_msg_queueunlink;
  1277. iovec.iov_len = sizeof (req_exec_msg_queueunlink);
  1278. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1279. TOTEMPG_AGREED) == 0);
  1280. }
  1281. static void message_handler_req_lib_msg_queuegroupcreate (
  1282. void *conn,
  1283. void *msg)
  1284. {
  1285. struct req_lib_msg_queuegroupcreate *req_lib_msg_queuegroupcreate =
  1286. (struct req_lib_msg_queuegroupcreate *)msg;
  1287. struct req_exec_msg_queuegroupcreate req_exec_msg_queuegroupcreate;
  1288. struct iovec iovec;
  1289. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupCreate %s\n",
  1290. getSaNameT (&req_lib_msg_queuegroupcreate->queueGroupName));
  1291. req_exec_msg_queuegroupcreate.header.size =
  1292. sizeof (struct req_exec_msg_queuegroupcreate);
  1293. req_exec_msg_queuegroupcreate.header.id =
  1294. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPCREATE);
  1295. message_source_set (&req_exec_msg_queuegroupcreate.source, conn);
  1296. memcpy (&req_exec_msg_queuegroupcreate.queue_group_name,
  1297. &req_lib_msg_queuegroupcreate->queueGroupName, sizeof (SaNameT));
  1298. iovec.iov_base = (char *)&req_exec_msg_queuegroupcreate;
  1299. iovec.iov_len = sizeof (req_exec_msg_queuegroupcreate);
  1300. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1301. TOTEMPG_AGREED) == 0);
  1302. }
  1303. static void message_handler_req_lib_msg_queuegroupinsert (
  1304. void *conn,
  1305. void *msg)
  1306. {
  1307. struct req_lib_msg_queuegroupinsert *req_lib_msg_queuegroupinsert =
  1308. (struct req_lib_msg_queuegroupinsert *)msg;
  1309. struct req_exec_msg_queuegroupinsert req_exec_msg_queuegroupinsert;
  1310. struct iovec iovec;
  1311. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupInsert %s\n",
  1312. getSaNameT (&req_lib_msg_queuegroupinsert->queueGroupName));
  1313. req_exec_msg_queuegroupinsert.header.size =
  1314. sizeof (struct req_exec_msg_queuegroupinsert);
  1315. req_exec_msg_queuegroupinsert.header.id =
  1316. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPINSERT);
  1317. message_source_set (&req_exec_msg_queuegroupinsert.source, conn);
  1318. memcpy (&req_exec_msg_queuegroupinsert.queue_name,
  1319. &req_lib_msg_queuegroupinsert->queueName, sizeof (SaNameT));
  1320. memcpy (&req_exec_msg_queuegroupinsert.queue_group_name,
  1321. &req_lib_msg_queuegroupinsert->queueGroupName, sizeof (SaNameT));
  1322. iovec.iov_base = (char *)&req_exec_msg_queuegroupinsert;
  1323. iovec.iov_len = sizeof (req_exec_msg_queuegroupinsert);
  1324. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1325. TOTEMPG_AGREED) == 0);
  1326. }
  1327. static void message_handler_req_lib_msg_queuegroupremove (
  1328. void *conn,
  1329. void *msg)
  1330. {
  1331. struct req_lib_msg_queuegroupremove *req_lib_msg_queuegroupremove =
  1332. (struct req_lib_msg_queuegroupremove *)msg;
  1333. struct req_exec_msg_queuegroupremove req_exec_msg_queuegroupremove;
  1334. struct iovec iovec;
  1335. req_exec_msg_queuegroupremove.header.size =
  1336. sizeof (struct req_exec_msg_queuegroupremove);
  1337. req_exec_msg_queuegroupremove.header.id =
  1338. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPREMOVE);
  1339. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupRemove %s\n",
  1340. getSaNameT (&req_lib_msg_queuegroupremove->queueGroupName));
  1341. message_source_set (&req_exec_msg_queuegroupremove.source, conn);
  1342. memcpy (&req_exec_msg_queuegroupremove.queue_name,
  1343. &req_lib_msg_queuegroupremove->queueName, sizeof (SaNameT));
  1344. memcpy (&req_exec_msg_queuegroupremove.queue_group_name,
  1345. &req_lib_msg_queuegroupremove->queueGroupName, sizeof (SaNameT));
  1346. iovec.iov_base = (char *)&req_exec_msg_queuegroupremove;
  1347. iovec.iov_len = sizeof (req_exec_msg_queuegroupremove);
  1348. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1349. TOTEMPG_AGREED) == 0);
  1350. }
  1351. static void message_handler_req_lib_msg_queuegroupdelete (
  1352. void *conn,
  1353. void *msg)
  1354. {
  1355. struct req_lib_msg_queuegroupdelete *req_lib_msg_queuegroupdelete =
  1356. (struct req_lib_msg_queuegroupdelete *)msg;
  1357. struct req_exec_msg_queuegroupdelete req_exec_msg_queuegroupdelete;
  1358. struct iovec iovec;
  1359. req_exec_msg_queuegroupdelete.header.size =
  1360. sizeof (struct req_exec_msg_queuegroupdelete);
  1361. req_exec_msg_queuegroupdelete.header.id =
  1362. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPDELETE);
  1363. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupDelete %s\n",
  1364. getSaNameT (&req_lib_msg_queuegroupdelete->queueGroupName));
  1365. message_source_set (&req_exec_msg_queuegroupdelete.source, conn);
  1366. memcpy (&req_exec_msg_queuegroupdelete.queue_group_name,
  1367. &req_lib_msg_queuegroupdelete->queueGroupName, sizeof (SaNameT));
  1368. iovec.iov_base = (char *)&req_exec_msg_queuegroupdelete;
  1369. iovec.iov_len = sizeof (req_exec_msg_queuegroupdelete);
  1370. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1371. TOTEMPG_AGREED) == 0);
  1372. }
  1373. static void message_handler_req_lib_msg_queuegrouptrack (
  1374. void *conn,
  1375. void *msg)
  1376. {
  1377. struct req_lib_msg_queuegrouptrack *req_lib_msg_queuegrouptrack =
  1378. (struct req_lib_msg_queuegrouptrack *)msg;
  1379. struct req_exec_msg_queuegrouptrack req_exec_msg_queuegrouptrack;
  1380. struct iovec iovec;
  1381. req_exec_msg_queuegrouptrack.header.size =
  1382. sizeof (struct req_exec_msg_queuegrouptrack);
  1383. req_exec_msg_queuegrouptrack.header.id =
  1384. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPTRACK);
  1385. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupTrack %s\n",
  1386. getSaNameT (&req_lib_msg_queuegrouptrack->queueGroupName));
  1387. message_source_set (&req_exec_msg_queuegrouptrack.source, conn);
  1388. memcpy (&req_exec_msg_queuegrouptrack.queue_group_name,
  1389. &req_lib_msg_queuegrouptrack->queueGroupName, sizeof (SaNameT));
  1390. iovec.iov_base = (char *)&req_exec_msg_queuegrouptrack;
  1391. iovec.iov_len = sizeof (req_exec_msg_queuegrouptrack);
  1392. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1393. TOTEMPG_AGREED) == 0);
  1394. }
  1395. static void message_handler_req_lib_msg_queuegrouptrackstop (
  1396. void *conn,
  1397. void *msg)
  1398. {
  1399. struct req_lib_msg_queuegrouptrackstop *req_lib_msg_queuegrouptrackstop =
  1400. (struct req_lib_msg_queuegrouptrackstop *)msg;
  1401. struct req_exec_msg_queuegrouptrackstop req_exec_msg_queuegrouptrackstop;
  1402. struct iovec iovec;
  1403. req_exec_msg_queuegrouptrackstop.header.size =
  1404. sizeof (struct req_exec_msg_queuegrouptrackstop);
  1405. req_exec_msg_queuegrouptrackstop.header.id =
  1406. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPTRACKSTOP);
  1407. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupTrackStop %s\n",
  1408. getSaNameT (&req_lib_msg_queuegrouptrackstop->queueGroupName));
  1409. message_source_set (&req_exec_msg_queuegrouptrackstop.source, conn);
  1410. memcpy (&req_exec_msg_queuegrouptrackstop.queue_group_name,
  1411. &req_lib_msg_queuegrouptrackstop->queueGroupName, sizeof (SaNameT));
  1412. iovec.iov_base = (char *)&req_exec_msg_queuegrouptrackstop;
  1413. iovec.iov_len = sizeof (req_exec_msg_queuegrouptrackstop);
  1414. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1415. TOTEMPG_AGREED) == 0);
  1416. }
  1417. static void message_handler_req_lib_msg_messagesend (
  1418. void *conn,
  1419. void *msg)
  1420. {
  1421. struct req_lib_msg_messagesend *req_lib_msg_messagesend =
  1422. (struct req_lib_msg_messagesend *)msg;
  1423. struct req_exec_msg_messagesend req_exec_msg_messagesend;
  1424. struct iovec iovecs[2];
  1425. req_exec_msg_messagesend.header.size =
  1426. sizeof (struct req_exec_msg_messagesend);
  1427. req_exec_msg_messagesend.header.id =
  1428. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGESEND);
  1429. req_exec_msg_messagesend.async_call = 0;
  1430. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageSend %s\n",
  1431. getSaNameT (&req_lib_msg_messagesend->destination));
  1432. message_source_set (&req_exec_msg_messagesend.source, conn);
  1433. memcpy (&req_exec_msg_messagesend.destination,
  1434. &req_lib_msg_messagesend->destination, sizeof (SaNameT));
  1435. memcpy (&req_exec_msg_messagesend.message,
  1436. &req_lib_msg_messagesend->message, sizeof (SaMsgMessageT));
  1437. req_exec_msg_messagesend.async_call = 0;
  1438. req_exec_msg_messagesend.invocation = 0;
  1439. req_exec_msg_messagesend.ack_flags = req_lib_msg_messagesend->ackFlags;
  1440. req_exec_msg_messagesend.timeout = req_lib_msg_messagesend->timeout;
  1441. iovecs[0].iov_base = (char *)&req_exec_msg_messagesend;
  1442. iovecs[0].iov_len = sizeof (req_exec_msg_messagesend);
  1443. iovecs[1].iov_base = ((char *)req_lib_msg_messagesend) +
  1444. sizeof (struct req_lib_msg_messagesend);
  1445. iovecs[1].iov_len = req_lib_msg_messagesend->header.size -
  1446. sizeof (struct req_lib_msg_messagesend);
  1447. req_exec_msg_messagesend.header.size += iovecs[1].iov_len;
  1448. if (iovecs[1].iov_len > 0) {
  1449. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2,
  1450. TOTEMPG_AGREED) == 0);
  1451. } else {
  1452. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1,
  1453. TOTEMPG_AGREED) == 0);
  1454. }
  1455. }
  1456. static void message_handler_req_lib_msg_messagesendasync (
  1457. void *conn,
  1458. void *msg)
  1459. {
  1460. struct req_lib_msg_messagesend *req_lib_msg_messagesend =
  1461. (struct req_lib_msg_messagesend *)msg;
  1462. struct req_exec_msg_messagesend req_exec_msg_messagesend;
  1463. struct iovec iovecs[2];
  1464. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageSendAsync %s\n",
  1465. getSaNameT (&req_lib_msg_messagesend->destination));
  1466. req_exec_msg_messagesend.header.size =
  1467. sizeof (struct req_exec_msg_messagesend);
  1468. req_exec_msg_messagesend.header.id =
  1469. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGESEND);
  1470. message_source_set (&req_exec_msg_messagesend.source, conn);
  1471. memcpy (&req_exec_msg_messagesend.destination,
  1472. &req_lib_msg_messagesend->destination, sizeof (SaNameT));
  1473. memcpy (&req_exec_msg_messagesend.message,
  1474. &req_lib_msg_messagesend->message, sizeof (SaMsgMessageT));
  1475. req_exec_msg_messagesend.async_call = 1;
  1476. req_exec_msg_messagesend.invocation = req_lib_msg_messagesend->invocation;
  1477. req_exec_msg_messagesend.ack_flags = req_lib_msg_messagesend->ackFlags;
  1478. req_exec_msg_messagesend.timeout = SA_TIME_END;
  1479. iovecs[0].iov_base = (char *)&req_exec_msg_messagesend;
  1480. iovecs[0].iov_len = sizeof (req_exec_msg_messagesend);
  1481. iovecs[1].iov_base = ((char *)req_lib_msg_messagesend) +
  1482. sizeof (struct req_lib_msg_messagesend);
  1483. iovecs[1].iov_len = req_lib_msg_messagesend->header.size -
  1484. sizeof (struct req_lib_msg_messagesend);
  1485. req_exec_msg_messagesend.header.size += iovecs[1].iov_len;
  1486. if (iovecs[1].iov_len > 0) {
  1487. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2,
  1488. TOTEMPG_AGREED) == 0);
  1489. } else {
  1490. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2,
  1491. TOTEMPG_AGREED) == 0);
  1492. }
  1493. }
  1494. static void message_handler_req_lib_msg_messageget (
  1495. void *conn,
  1496. void *msg)
  1497. {
  1498. struct req_lib_msg_messageget *req_lib_msg_messageget =
  1499. (struct req_lib_msg_messageget *)msg;
  1500. struct req_exec_msg_messageget req_exec_msg_messageget;
  1501. struct iovec iovec;
  1502. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageGet %s\n",
  1503. getSaNameT (&req_lib_msg_messageget->queueName));
  1504. req_exec_msg_messageget.header.size =
  1505. sizeof (struct req_exec_msg_messageget);
  1506. req_exec_msg_messageget.header.id =
  1507. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGEGET);
  1508. message_source_set (&req_exec_msg_messageget.source, conn);
  1509. memcpy (&req_exec_msg_messageget.queue_name,
  1510. &req_lib_msg_messageget->queueName, sizeof (SaNameT));
  1511. iovec.iov_base = (char *)&req_exec_msg_messageget;
  1512. iovec.iov_len = sizeof (req_exec_msg_messageget);
  1513. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1514. TOTEMPG_AGREED) == 0);
  1515. }
  1516. static void message_handler_req_lib_msg_messagecancel (
  1517. void *conn,
  1518. void *msg)
  1519. {
  1520. struct req_lib_msg_messagecancel *req_lib_msg_messagecancel =
  1521. (struct req_lib_msg_messagecancel *)msg;
  1522. struct req_exec_msg_messagecancel req_exec_msg_messagecancel;
  1523. struct iovec iovec;
  1524. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageCancel %s\n",
  1525. getSaNameT (&req_lib_msg_messagecancel->queueName));
  1526. req_exec_msg_messagecancel.header.size =
  1527. sizeof (struct req_exec_msg_messagecancel);
  1528. req_exec_msg_messagecancel.header.id =
  1529. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGECANCEL);
  1530. message_source_set (&req_exec_msg_messagecancel.source, conn);
  1531. memcpy (&req_exec_msg_messagecancel.queue_name,
  1532. &req_lib_msg_messagecancel->queueName, sizeof (SaNameT));
  1533. iovec.iov_base = (char *)&req_exec_msg_messagecancel;
  1534. iovec.iov_len = sizeof (req_exec_msg_messagecancel);
  1535. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1536. TOTEMPG_AGREED) == 0);
  1537. }
  1538. static void message_handler_req_lib_msg_messagesendreceive (
  1539. void *conn,
  1540. void *msg)
  1541. {
  1542. struct req_lib_msg_messagesendreceive *req_lib_msg_messagesendreceive =
  1543. (struct req_lib_msg_messagesendreceive *)msg;
  1544. struct req_exec_msg_messagesendreceive req_exec_msg_messagesendreceive;
  1545. struct iovec iovec;
  1546. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageSendReceive %s\n",
  1547. getSaNameT (&req_lib_msg_messagesendreceive->queueName));
  1548. req_exec_msg_messagesendreceive.header.size =
  1549. sizeof (struct req_exec_msg_messagesendreceive);
  1550. req_exec_msg_messagesendreceive.header.id =
  1551. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGESENDRECEIVE);
  1552. message_source_set (&req_exec_msg_messagesendreceive.source, conn);
  1553. memcpy (&req_exec_msg_messagesendreceive.queue_name,
  1554. &req_lib_msg_messagesendreceive->queueName, sizeof (SaNameT));
  1555. iovec.iov_base = (char *)&req_exec_msg_messagesendreceive;
  1556. iovec.iov_len = sizeof (req_exec_msg_messagesendreceive);
  1557. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1558. TOTEMPG_AGREED) == 0);
  1559. }
  1560. static void message_handler_req_lib_msg_messagereply (
  1561. void *conn,
  1562. void *msg)
  1563. {
  1564. struct req_lib_msg_messagereply *req_lib_msg_messagereply =
  1565. (struct req_lib_msg_messagereply *)msg;
  1566. struct req_exec_msg_messagereply req_exec_msg_messagereply;
  1567. struct iovec iovec;
  1568. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageReply %s\n",
  1569. getSaNameT (&req_lib_msg_messagereply->queueName));
  1570. req_exec_msg_messagereply.header.size =
  1571. sizeof (struct req_exec_msg_messagereply);
  1572. req_exec_msg_messagereply.header.id =
  1573. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGEREPLY);
  1574. req_exec_msg_messagereply.async_call = 0;
  1575. message_source_set (&req_exec_msg_messagereply.source, conn);
  1576. memcpy (&req_exec_msg_messagereply.queue_name,
  1577. &req_lib_msg_messagereply->queueName, sizeof (SaNameT));
  1578. iovec.iov_base = (char *)&req_exec_msg_messagereply;
  1579. iovec.iov_len = sizeof (req_exec_msg_messagereply);
  1580. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1581. TOTEMPG_AGREED) == 0);
  1582. }
  1583. static void message_handler_req_lib_msg_messagereplyasync (
  1584. void *conn,
  1585. void *msg)
  1586. {
  1587. struct req_lib_msg_messagereply *req_lib_msg_messagereply =
  1588. (struct req_lib_msg_messagereply *)msg;
  1589. struct req_exec_msg_messagereply req_exec_msg_messagereply;
  1590. struct iovec iovec;
  1591. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageReplyAsync %s\n",
  1592. getSaNameT (&req_lib_msg_messagereply->queueName));
  1593. req_exec_msg_messagereply.header.size =
  1594. sizeof (struct req_exec_msg_messagereply);
  1595. req_exec_msg_messagereply.header.id =
  1596. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGEREPLY);
  1597. req_exec_msg_messagereply.async_call = 1;
  1598. message_source_set (&req_exec_msg_messagereply.source, conn);
  1599. memcpy (&req_exec_msg_messagereply.queue_name,
  1600. &req_lib_msg_messagereply->queueName, sizeof (SaNameT));
  1601. iovec.iov_base = (char *)&req_exec_msg_messagereply;
  1602. iovec.iov_len = sizeof (req_exec_msg_messagereply);
  1603. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1604. TOTEMPG_AGREED) == 0);
  1605. }