msg.c 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347
  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. SaUint8T track_flags;
  97. SaMsgQueueGroupPolicyT policy;
  98. struct list_head list;
  99. struct list_head message_queue_head;
  100. };
  101. struct queue_group_entry {
  102. SaMsgQueueGroupChangesT change;
  103. struct message_queue *message_queue;
  104. struct list_head list;
  105. };
  106. /*
  107. struct queue_cleanup {
  108. struct message_queue *queue;
  109. SaMsgResourceHandleT queue_handle;
  110. struct list_head queue_lock_list_head;
  111. struct list_head list;
  112. };
  113. */
  114. DECLARE_LIST_INIT(queue_list_head);
  115. DECLARE_LIST_INIT(queue_group_list_head);
  116. static int msg_exec_init_fn (struct objdb_iface_ver0 *objdb);
  117. static int msg_lib_exit_fn (void *conn);
  118. static int msg_lib_init_fn (void *conn);
  119. static void message_handler_req_exec_msg_queueopen (
  120. void *message,
  121. unsigned int nodeid);
  122. static void message_handler_req_exec_msg_queueclose (
  123. void *message,
  124. unsigned int nodeid);
  125. static void message_handler_req_exec_msg_queuestatusget (
  126. void *message,
  127. unsigned int nodeid);
  128. static void message_handler_req_exec_msg_queueunlink (
  129. void *message,
  130. unsigned int nodeid);
  131. static void message_handler_req_exec_msg_queuegroupcreate (
  132. void *message,
  133. unsigned int nodeid);
  134. static void message_handler_req_exec_msg_queuegroupinsert (
  135. void *message,
  136. unsigned int nodeid);
  137. static void message_handler_req_exec_msg_queuegroupremove (
  138. void *message,
  139. unsigned int nodeid);
  140. static void message_handler_req_exec_msg_queuegroupdelete (
  141. void *message,
  142. unsigned int nodeid);
  143. static void message_handler_req_exec_msg_queuegrouptrack (
  144. void *message,
  145. unsigned int nodeid);
  146. static void message_handler_req_exec_msg_queuegrouptrackstop (
  147. void *message,
  148. unsigned int nodeid);
  149. static void message_handler_req_exec_msg_messagesend (
  150. void *message,
  151. unsigned int nodeid);
  152. static void message_handler_req_exec_msg_messageget (
  153. void *message,
  154. unsigned int nodeid);
  155. static void message_handler_req_exec_msg_messagecancel (
  156. void *message,
  157. unsigned int nodeid);
  158. static void message_handler_req_exec_msg_messagesendreceive (
  159. void *message,
  160. unsigned int nodeid);
  161. static void message_handler_req_exec_msg_messagereply (
  162. void *message,
  163. unsigned int nodeid);
  164. static void message_handler_req_lib_msg_queueopen (
  165. void *conn,
  166. void *msg);
  167. static void message_handler_req_lib_msg_queueopenasync (
  168. void *conn,
  169. void *msg);
  170. static void message_handler_req_lib_msg_queueclose (
  171. void *conn,
  172. void *msg);
  173. static void message_handler_req_lib_msg_queuestatusget (
  174. void *conn,
  175. void *msg);
  176. static void message_handler_req_lib_msg_queueunlink (
  177. void *conn,
  178. void *msg);
  179. static void message_handler_req_lib_msg_queuegroupcreate (
  180. void *conn,
  181. void *msg);
  182. static void message_handler_req_lib_msg_queuegroupinsert (
  183. void *conn,
  184. void *msg);
  185. static void message_handler_req_lib_msg_queuegroupremove (
  186. void *conn,
  187. void *msg);
  188. static void message_handler_req_lib_msg_queuegroupdelete (
  189. void *conn,
  190. void *msg);
  191. static void message_handler_req_lib_msg_queuegrouptrack (
  192. void *conn,
  193. void *msg);
  194. static void message_handler_req_lib_msg_queuegrouptrackstop (
  195. void *conn,
  196. void *msg);
  197. static void message_handler_req_lib_msg_messagesend (
  198. void *conn,
  199. void *msg);
  200. static void message_handler_req_lib_msg_messagesendasync (
  201. void *conn,
  202. void *msg);
  203. static void message_handler_req_lib_msg_messageget (
  204. void *conn,
  205. void *msg);
  206. static void message_handler_req_lib_msg_messagecancel (
  207. void *conn,
  208. void *msg);
  209. static void message_handler_req_lib_msg_messagesendreceive (
  210. void *conn,
  211. void *msg);
  212. static void message_handler_req_lib_msg_messagereply (
  213. void *conn,
  214. void *msg);
  215. static void message_handler_req_lib_msg_messagereplyasync (
  216. void *conn,
  217. void *msg);
  218. #ifdef TODO
  219. static void msg_sync_init (void);
  220. #endif /* TODO */
  221. static void msg_sync_activate (void);
  222. static int msg_sync_process (void);
  223. static void msg_sync_abort(void);
  224. void queue_release (struct message_queue *queue);
  225. static void msg_confchg_fn (
  226. enum totem_configuration_type configuration_type,
  227. unsigned int *member_list, int member_list_entries,
  228. unsigned int *left_list, int left_list_entries,
  229. unsigned int *joined_list, int joined_list_entries,
  230. struct memb_ring_id *ring_id);
  231. struct msg_pd {
  232. struct list_head queue_list;
  233. struct list_head queue_cleanup_list;
  234. };
  235. /*
  236. * Executive Handler Definition
  237. */
  238. struct openais_lib_handler msg_lib_service[] =
  239. {
  240. { /* 0 */
  241. .lib_handler_fn = message_handler_req_lib_msg_queueopen,
  242. .response_size = sizeof (struct res_lib_msg_queueopen),
  243. .response_id = MESSAGE_RES_MSG_QUEUEOPEN,
  244. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  245. },
  246. { /* 1 */
  247. .lib_handler_fn = message_handler_req_lib_msg_queueopenasync,
  248. .response_size = sizeof (struct res_lib_msg_queueopenasync),
  249. .response_id = MESSAGE_RES_MSG_QUEUEOPENASYNC,
  250. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  251. },
  252. { /* 2 */
  253. .lib_handler_fn = message_handler_req_lib_msg_queueclose,
  254. .response_size = sizeof (struct res_lib_msg_queueclose),
  255. .response_id = MESSAGE_RES_MSG_QUEUECLOSE,
  256. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  257. },
  258. { /* 3 */
  259. .lib_handler_fn = message_handler_req_lib_msg_queuestatusget,
  260. .response_size = sizeof (struct res_lib_msg_queuestatusget),
  261. .response_id = MESSAGE_RES_MSG_QUEUESTATUSGET,
  262. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  263. },
  264. { /* 4 */
  265. .lib_handler_fn = message_handler_req_lib_msg_queueunlink,
  266. .response_size = sizeof (struct res_lib_msg_queueunlink),
  267. .response_id = MESSAGE_RES_MSG_QUEUEUNLINK,
  268. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  269. },
  270. { /* 5 */
  271. .lib_handler_fn = message_handler_req_lib_msg_queuegroupcreate,
  272. .response_size = sizeof (struct res_lib_msg_queuegroupcreate),
  273. .response_id = MESSAGE_RES_MSG_QUEUEGROUPCREATE,
  274. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  275. },
  276. { /* 6 */
  277. .lib_handler_fn = message_handler_req_lib_msg_queuegroupinsert,
  278. .response_size = sizeof (struct res_lib_msg_queuegroupinsert),
  279. .response_id = MESSAGE_RES_MSG_QUEUEGROUPINSERT,
  280. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  281. },
  282. { /* 7 */
  283. .lib_handler_fn = message_handler_req_lib_msg_queuegroupremove,
  284. .response_size = sizeof (struct res_lib_msg_queuegroupremove),
  285. .response_id = MESSAGE_RES_MSG_QUEUEGROUPREMOVE,
  286. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  287. },
  288. { /* 8 */
  289. .lib_handler_fn = message_handler_req_lib_msg_queuegroupdelete,
  290. .response_size = sizeof (struct res_lib_msg_queuegroupdelete),
  291. .response_id = MESSAGE_RES_MSG_QUEUEGROUPDELETE,
  292. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  293. },
  294. { /* 9 */
  295. .lib_handler_fn = message_handler_req_lib_msg_queuegrouptrack,
  296. .response_size = sizeof (struct res_lib_msg_queuegrouptrack),
  297. .response_id = MESSAGE_RES_MSG_QUEUEGROUPTRACK,
  298. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  299. },
  300. { /* 10 */
  301. .lib_handler_fn = message_handler_req_lib_msg_queuegrouptrackstop,
  302. .response_size = sizeof (struct res_lib_msg_queuegrouptrackstop),
  303. .response_id = MESSAGE_RES_MSG_QUEUEGROUPTRACKSTOP,
  304. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  305. },
  306. { /* 11 */
  307. .lib_handler_fn = message_handler_req_lib_msg_messagesend,
  308. .response_size = sizeof (struct res_lib_msg_messagesend),
  309. .response_id = MESSAGE_RES_MSG_MESSAGESEND,
  310. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  311. },
  312. { /* 12 */
  313. .lib_handler_fn = message_handler_req_lib_msg_messagesendasync,
  314. .response_size = sizeof (struct res_lib_msg_messagesendasync),
  315. .response_id = MESSAGE_RES_MSG_MESSAGESENDASYNC,
  316. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  317. },
  318. { /* 13 */
  319. .lib_handler_fn = message_handler_req_lib_msg_messageget,
  320. .response_size = sizeof (struct res_lib_msg_messageget),
  321. .response_id = MESSAGE_RES_MSG_MESSAGEGET,
  322. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  323. },
  324. { /* 14 */
  325. .lib_handler_fn = message_handler_req_lib_msg_messagecancel,
  326. .response_size = sizeof (struct res_lib_msg_messagecancel),
  327. .response_id = MESSAGE_RES_MSG_MESSAGECANCEL,
  328. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  329. },
  330. { /* 15 */
  331. .lib_handler_fn = message_handler_req_lib_msg_messagesendreceive,
  332. .response_size = sizeof (struct res_lib_msg_messagesendreceive),
  333. .response_id = MESSAGE_RES_MSG_MESSAGESENDRECEIVE,
  334. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  335. },
  336. { /* 16 */
  337. .lib_handler_fn = message_handler_req_lib_msg_messagereply,
  338. .response_size = sizeof (struct res_lib_msg_messagereply),
  339. .response_id = MESSAGE_RES_MSG_MESSAGEREPLY,
  340. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  341. },
  342. { /* 17 */
  343. .lib_handler_fn = message_handler_req_lib_msg_messagereplyasync,
  344. .response_size = sizeof (struct res_lib_msg_messagereplyasync),
  345. .response_id = MESSAGE_RES_MSG_MESSAGEREPLYASYNC,
  346. .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
  347. },
  348. };
  349. static struct openais_exec_handler msg_exec_service[] = {
  350. {
  351. .exec_handler_fn = message_handler_req_exec_msg_queueopen,
  352. },
  353. {
  354. .exec_handler_fn = message_handler_req_exec_msg_queueclose,
  355. },
  356. {
  357. .exec_handler_fn = message_handler_req_exec_msg_queuestatusget,
  358. },
  359. {
  360. .exec_handler_fn = message_handler_req_exec_msg_queueunlink,
  361. },
  362. {
  363. .exec_handler_fn = message_handler_req_exec_msg_queuegroupcreate,
  364. },
  365. {
  366. .exec_handler_fn = message_handler_req_exec_msg_queuegroupinsert,
  367. },
  368. {
  369. .exec_handler_fn = message_handler_req_exec_msg_queuegroupremove,
  370. },
  371. {
  372. .exec_handler_fn = message_handler_req_exec_msg_queuegroupdelete,
  373. },
  374. {
  375. .exec_handler_fn = message_handler_req_exec_msg_queuegrouptrack,
  376. },
  377. {
  378. .exec_handler_fn = message_handler_req_exec_msg_queuegrouptrackstop,
  379. },
  380. {
  381. .exec_handler_fn = message_handler_req_exec_msg_messagesend,
  382. },
  383. {
  384. .exec_handler_fn = message_handler_req_exec_msg_messageget,
  385. },
  386. {
  387. .exec_handler_fn = message_handler_req_exec_msg_messagecancel,
  388. },
  389. {
  390. .exec_handler_fn = message_handler_req_exec_msg_messagesendreceive,
  391. },
  392. {
  393. .exec_handler_fn = message_handler_req_exec_msg_messagereply
  394. }
  395. };
  396. struct openais_service_handler msg_service_handler = {
  397. .name = "openais message service B.01.01",
  398. .id = MSG_SERVICE,
  399. .private_data_size = sizeof (struct msg_pd),
  400. .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED,
  401. .lib_init_fn = msg_lib_init_fn,
  402. .lib_exit_fn = msg_lib_exit_fn,
  403. .lib_service = msg_lib_service,
  404. .lib_service_count = sizeof (msg_lib_service) / sizeof (struct openais_lib_handler),
  405. .exec_init_fn = msg_exec_init_fn,
  406. .exec_service = msg_exec_service,
  407. .exec_service_count = sizeof (msg_exec_service) / sizeof (struct openais_exec_handler),
  408. .confchg_fn = msg_confchg_fn,
  409. .exec_dump_fn = NULL,
  410. .sync_init = NULL, // TODO msg_sync_init,
  411. .sync_process = msg_sync_process,
  412. .sync_activate = msg_sync_activate,
  413. .sync_abort = msg_sync_abort
  414. };
  415. static struct openais_service_handler *msg_get_handler_ver0 (void);
  416. static struct openais_service_handler_iface_ver0 msg_service_handler_iface = {
  417. .openais_get_service_handler_ver0 = msg_get_handler_ver0
  418. };
  419. static struct lcr_iface openais_msg_ver0[1] = {
  420. {
  421. .name = "openais_msg",
  422. .version = 0,
  423. .versions_replace = 0,
  424. .versions_replace_count = 0,
  425. .dependencies = 0,
  426. .dependency_count = 0,
  427. .constructor = NULL,
  428. .destructor = NULL,
  429. .interfaces = NULL
  430. }
  431. };
  432. static struct lcr_comp msg_comp_ver0 = {
  433. .iface_count = 1,
  434. .ifaces = openais_msg_ver0
  435. };
  436. static struct openais_service_handler *msg_get_handler_ver0 (void)
  437. {
  438. return (&msg_service_handler);
  439. }
  440. __attribute__ ((constructor)) static void register_this_component (void) {
  441. lcr_interfaces_set (&openais_msg_ver0[0], &msg_service_handler_iface);
  442. lcr_component_register (&msg_comp_ver0);
  443. }
  444. /*
  445. * All data types used for executive messages
  446. */
  447. struct req_exec_msg_queueopen {
  448. mar_req_header_t header;
  449. mar_message_source_t source;
  450. int async_call;
  451. SaNameT queue_name;
  452. SaInvocationT invocation;
  453. SaMsgQueueHandleT queue_handle;
  454. SaMsgQueueCreationAttributesT creation_attributes;
  455. SaMsgQueueOpenFlagsT openFlags;
  456. SaTimeT timeout;
  457. };
  458. struct req_exec_msg_queueclose {
  459. mar_req_header_t header;
  460. mar_message_source_t source;
  461. SaNameT queue_name;
  462. };
  463. struct req_exec_msg_queuestatusget {
  464. mar_req_header_t header;
  465. mar_message_source_t source;
  466. SaNameT queue_name;
  467. };
  468. struct req_exec_msg_queueunlink {
  469. mar_req_header_t header;
  470. mar_message_source_t source;
  471. SaNameT queue_name;
  472. };
  473. struct req_exec_msg_queuegroupcreate {
  474. mar_req_header_t header;
  475. mar_message_source_t source;
  476. SaNameT queue_group_name;
  477. SaMsgQueueGroupPolicyT policy;
  478. };
  479. struct req_exec_msg_queuegroupinsert {
  480. mar_req_header_t header;
  481. mar_message_source_t source;
  482. SaNameT queue_name;
  483. SaNameT queue_group_name;
  484. };
  485. struct req_exec_msg_queuegroupremove {
  486. mar_req_header_t header;
  487. mar_message_source_t source;
  488. SaNameT queue_name;
  489. SaNameT queue_group_name;
  490. };
  491. struct req_exec_msg_queuegroupdelete {
  492. mar_req_header_t header;
  493. mar_message_source_t source;
  494. SaNameT queue_group_name;
  495. };
  496. struct req_exec_msg_queuegrouptrack {
  497. mar_req_header_t header;
  498. mar_message_source_t source;
  499. SaNameT queue_group_name;
  500. SaUint8T track_flags;
  501. SaUint8T buffer_flag;
  502. };
  503. struct req_exec_msg_queuegrouptrackstop {
  504. mar_req_header_t header;
  505. mar_message_source_t source;
  506. SaNameT queue_group_name;
  507. };
  508. struct req_exec_msg_messagesend {
  509. mar_req_header_t header;
  510. mar_message_source_t source;
  511. SaNameT destination;
  512. SaTimeT timeout;
  513. SaMsgMessageT message;
  514. SaInvocationT invocation;
  515. SaMsgAckFlagsT ack_flags;
  516. int async_call;
  517. };
  518. struct req_exec_msg_messageget {
  519. mar_req_header_t header;
  520. mar_message_source_t source;
  521. SaNameT queue_name;
  522. };
  523. struct req_exec_msg_messagecancel {
  524. mar_req_header_t header;
  525. mar_message_source_t source;
  526. SaNameT queue_name;
  527. };
  528. struct req_exec_msg_messagesendreceive {
  529. mar_req_header_t header;
  530. mar_message_source_t source;
  531. SaNameT queue_name;
  532. };
  533. struct req_exec_msg_messagereply {
  534. mar_req_header_t header;
  535. mar_message_source_t source;
  536. SaNameT queue_name;
  537. int async_call;
  538. };
  539. #ifdef TODO
  540. static void msg_sync_init (void)
  541. {
  542. return;
  543. }
  544. #endif /* TODO */
  545. static int msg_sync_process (void)
  546. {
  547. return (0);
  548. }
  549. static void msg_sync_activate (void)
  550. {
  551. return;
  552. }
  553. static void msg_sync_abort (void)
  554. {
  555. return;
  556. }
  557. static void msg_confchg_fn (
  558. enum totem_configuration_type configuration_type,
  559. unsigned int *member_list, int member_list_entries,
  560. unsigned int *left_list, int left_list_entries,
  561. unsigned int *joined_list, int joined_list_entries,
  562. struct memb_ring_id *ring_id)
  563. {
  564. return;
  565. }
  566. static void print_message_list (struct message_queue *queue)
  567. {
  568. struct list_head *list;
  569. struct message_entry *entry;
  570. for (list = queue->message_list_head.next;
  571. list != &queue->message_list_head;
  572. list = list->next)
  573. {
  574. entry = list_entry (list, struct message_entry, list);
  575. log_printf (LOG_LEVEL_NOTICE, "[DEBUG]: print_message_list (%s) (%llu)\n",
  576. (char *)(entry->message.data),
  577. (unsigned long long)(entry->time));
  578. }
  579. }
  580. static void print_queue_group_list (struct queue_group *group)
  581. {
  582. struct list_head *list;
  583. struct queue_group_entry *entry;
  584. for (list = group->message_queue_head.next;
  585. list != &group->message_queue_head;
  586. list = list->next)
  587. {
  588. entry = list_entry (list, struct queue_group_entry, list);
  589. log_printf (LOG_LEVEL_NOTICE, "[DEBUG]: print_queue_group_list (%s) (%u)\n",
  590. (char *)(entry->message_queue->name.value),
  591. (unsigned int)(entry->change));
  592. }
  593. }
  594. static struct message_queue *queue_find (SaNameT *name)
  595. {
  596. struct list_head *list;
  597. struct message_queue *queue;
  598. for (list = queue_list_head.next;
  599. list != &queue_list_head;
  600. list = list->next)
  601. {
  602. queue = list_entry (list, struct message_queue, list);
  603. if (name_match (name, &queue->name)) {
  604. return (queue);
  605. }
  606. }
  607. return (0);
  608. }
  609. static struct queue_group *queue_group_find (SaNameT *name)
  610. {
  611. struct list_head *list;
  612. struct queue_group *group;
  613. for (list = queue_group_list_head.next;
  614. list != &queue_group_list_head;
  615. list = list->next)
  616. {
  617. group = list_entry (list, struct queue_group, list);
  618. if (name_match (name, &group->name)) {
  619. return (group);
  620. }
  621. }
  622. return (0);
  623. }
  624. static struct queue_group_entry *queue_group_entry_find (struct queue_group *group, struct message_queue *queue)
  625. {
  626. struct list_head *list;
  627. struct queue_group_entry *entry;
  628. for (list = group->message_queue_head.next;
  629. list != &group->message_queue_head;
  630. list = list->next)
  631. {
  632. entry = list_entry (list, struct queue_group_entry, list);
  633. if (entry->message_queue == queue) {
  634. return (entry);
  635. }
  636. }
  637. return (0);
  638. }
  639. static unsigned int queue_group_member_count (struct queue_group *group)
  640. {
  641. struct list_head *list;
  642. unsigned int count = 0;
  643. for (list = group->message_queue_head.next;
  644. list != &group->message_queue_head;
  645. list = list->next)
  646. {
  647. count++;
  648. }
  649. return (count);
  650. }
  651. static unsigned int queue_group_change_count (struct queue_group *group)
  652. {
  653. struct list_head *list;
  654. struct queue_group_entry *entry;
  655. unsigned int count = 0;
  656. for (list = group->message_queue_head.next;
  657. list != &group->message_queue_head;
  658. list = list->next)
  659. {
  660. entry = list_entry (list, struct queue_group_entry, list);
  661. if (entry->change != SA_MSG_QUEUE_GROUP_NO_CHANGE) {
  662. count++;
  663. }
  664. }
  665. return (count);
  666. }
  667. static unsigned int queue_group_track (
  668. struct queue_group *group,
  669. unsigned int flags,
  670. void *buffer)
  671. {
  672. struct list_head *list;
  673. struct queue_group_entry *entry;
  674. unsigned int i = 0;
  675. SaMsgQueueGroupNotificationT *notification =
  676. (SaMsgQueueGroupNotificationT *) buffer;
  677. switch (flags) {
  678. case SA_TRACK_CURRENT:
  679. case SA_TRACK_CHANGES:
  680. for (list = group->message_queue_head.next;
  681. list != &group->message_queue_head;
  682. list = list->next)
  683. {
  684. entry = list_entry (list, struct queue_group_entry, list);
  685. memcpy (&notification[i].member.queueName,
  686. &entry->message_queue->name,
  687. sizeof (SaNameT));
  688. notification[i].change = entry->change;
  689. i++;
  690. }
  691. break;
  692. case SA_TRACK_CHANGES_ONLY:
  693. for (list = group->message_queue_head.next;
  694. list != &group->message_queue_head;
  695. list = list->next)
  696. {
  697. entry = list_entry (list, struct queue_group_entry, list);
  698. if (entry->change != SA_MSG_QUEUE_GROUP_NO_CHANGE) {
  699. memcpy (&notification[i].member.queueName,
  700. &entry->message_queue->name,
  701. sizeof (SaNameT));
  702. notification[i].change = entry->change;
  703. i++;
  704. }
  705. }
  706. break;
  707. default:
  708. break;
  709. }
  710. return (i);
  711. }
  712. static int msg_exec_init_fn (struct objdb_iface_ver0 *objdb)
  713. {
  714. /*
  715. * Initialize the saved ring ID.
  716. */
  717. /* saved_ring_id.seq = 0; */
  718. /* saved_ring_id.rep.s_addr = this_ip->sin_addr.s_addr; */
  719. return (0);
  720. }
  721. static int msg_lib_exit_fn (void *conn)
  722. {
  723. /*
  724. * struct msg_pd *msg_pd = (struct msg_pd *)openais_conn_private_data_get (conn);
  725. */
  726. #ifdef COMPILE_OUT
  727. struct queue_cleanup *queue_cleanup;
  728. struct list_head *list;
  729. /*
  730. * close all queues opened on this fd
  731. */
  732. list = conn_info->conn_info_partner->ais_ci.u.libmsg_ci.queue_cleanup_list.next;
  733. while (!list_empty(&conn_info->conn_info_partner->ais_ci.u.libmsg_ci.queue_cleanup_list)) {
  734. queue_cleanup = list_entry (list, struct queue_cleanup, list);
  735. if (queue_cleanup->queue->name.length > 0) {
  736. msg_queue_cleanup_lock_remove (queue_cleanup);
  737. msg_queue_close (queue_cleanup->queue);
  738. }
  739. list_del (&queue_cleanup->list);
  740. free (queue_cleanup);
  741. list = conn_info->conn_info_partner->ais_ci.u.libmsg_ci.queue_cleanup_list.next;
  742. }
  743. #endif /* COMPILE_OUT */
  744. return (0);
  745. }
  746. static int msg_lib_init_fn (void *conn)
  747. {
  748. struct msg_pd *msg_pd = (struct msg_pd *)openais_conn_private_data_get (conn);
  749. list_init (&msg_pd->queue_list);
  750. list_init (&msg_pd->queue_cleanup_list);
  751. return (0);
  752. }
  753. static void message_handler_req_exec_msg_queueopen (
  754. void *message,
  755. unsigned int nodeid)
  756. {
  757. struct req_exec_msg_queueopen *req_exec_msg_queueopen =
  758. (struct req_exec_msg_queueopen *)message;
  759. struct res_lib_msg_queueopen res_lib_msg_queueopen;
  760. struct res_lib_msg_queueopenasync res_lib_msg_queueopenasync;
  761. struct message_queue *queue;
  762. /* struct queue_cleanup *queue_cleanup; */
  763. SaAisErrorT error = SA_AIS_OK;
  764. log_printf (LOG_LEVEL_NOTICE, "EXEC request: saMsgQueueOpen %s\n",
  765. getSaNameT (&req_exec_msg_queueopen->queue_name));
  766. queue = queue_find (&req_exec_msg_queueopen->queue_name);
  767. /*
  768. * If queue doesn't exist, create one
  769. */
  770. if (queue == 0) {
  771. if ((req_exec_msg_queueopen->openFlags & SA_MSG_QUEUE_CREATE) == 0) {
  772. error = SA_AIS_ERR_NOT_EXIST;
  773. goto error_exit;
  774. }
  775. queue = malloc (sizeof (struct message_queue));
  776. if (queue == 0) {
  777. error = SA_AIS_ERR_NO_MEMORY;
  778. goto error_exit;
  779. }
  780. memset (queue, 0, sizeof (struct message_queue));
  781. memcpy (&queue->name,
  782. &req_exec_msg_queueopen->queue_name,
  783. sizeof (SaNameT));
  784. list_init (&queue->list);
  785. list_init (&queue->message_list_head);
  786. list_add (&queue->list, &queue_list_head);
  787. queue->refcount = 0;
  788. }
  789. queue->refcount += 1;
  790. #ifdef COMPILE_OUT
  791. /*
  792. * Setup connection information and mark queue as referenced
  793. */
  794. queue_cleanup = malloc (sizeof (struct queue_cleanup));
  795. if (queue_cleanup == 0) {
  796. free (queue);
  797. error = SA_AIS_ERR_NO_MEMORY;
  798. } else {
  799. list_init (&queue_cleanup->list);
  800. list_init (&queue_cleanup->queue_lock_list_head);
  801. queue_cleanup->queue = queue;
  802. queue_cleanup->queue_handle = req_exec_msg_queueopen->queue_handle;
  803. list_add (
  804. &queue_cleanup->list,
  805. &req_exec_msg_queueopen->source.conn_info->ais_ci.u.libmsg_ci.queue_cleanup_list);
  806. }
  807. queue->refcount += 1;
  808. #endif /* COMPILE_OUT */
  809. /*
  810. * Send error result to MSG library
  811. */
  812. error_exit:
  813. /*
  814. * If this node was the source of the message, respond to this node
  815. */
  816. if (message_source_is_local (&req_exec_msg_queueopen->source)) {
  817. /*
  818. * If its an async call respond with the invocation and handle
  819. */
  820. if (req_exec_msg_queueopen->async_call)
  821. {
  822. res_lib_msg_queueopenasync.header.size =
  823. sizeof (struct res_lib_msg_queueopenasync);
  824. res_lib_msg_queueopenasync.header.id =
  825. MESSAGE_RES_MSG_QUEUEOPENASYNC;
  826. res_lib_msg_queueopenasync.header.error = error;
  827. res_lib_msg_queueopenasync.invocation =
  828. req_exec_msg_queueopen->invocation;
  829. res_lib_msg_queueopenasync.queueHandle =
  830. req_exec_msg_queueopen->queue_handle;
  831. memcpy (&res_lib_msg_queueopenasync.source,
  832. &req_exec_msg_queueopen->source,
  833. sizeof (mar_message_source_t));
  834. openais_conn_send_response (
  835. req_exec_msg_queueopen->source.conn,
  836. &res_lib_msg_queueopenasync,
  837. sizeof (struct res_lib_msg_queueopenasync));
  838. openais_conn_send_response (
  839. openais_conn_partner_get (req_exec_msg_queueopen->source.conn),
  840. &res_lib_msg_queueopenasync,
  841. sizeof (struct res_lib_msg_queueopenasync));
  842. } else {
  843. /*
  844. * otherwise respond with the normal queueopen response
  845. */
  846. res_lib_msg_queueopen.header.size =
  847. sizeof (struct res_lib_msg_queueopen);
  848. res_lib_msg_queueopen.header.id =
  849. MESSAGE_RES_MSG_QUEUEOPEN;
  850. res_lib_msg_queueopen.header.error = error;
  851. res_lib_msg_queueopen.queueHandle =
  852. req_exec_msg_queueopen->queue_handle;
  853. memcpy (&res_lib_msg_queueopen.source,
  854. &req_exec_msg_queueopen->source,
  855. sizeof (mar_message_source_t));
  856. openais_conn_send_response (
  857. req_exec_msg_queueopen->source.conn,
  858. &res_lib_msg_queueopen,
  859. sizeof (struct res_lib_msg_queueopen));
  860. }
  861. }
  862. }
  863. static void message_handler_req_exec_msg_queueclose (
  864. void *message,
  865. unsigned int nodeid)
  866. {
  867. struct req_exec_msg_queueclose *req_exec_msg_queueclose =
  868. (struct req_exec_msg_queueclose *)message;
  869. struct res_lib_msg_queueclose res_lib_msg_queueclose;
  870. struct message_queue *queue = 0;
  871. SaAisErrorT error = SA_AIS_OK;
  872. log_printf (LOG_LEVEL_NOTICE, "EXEC request: saMsgQueueClose %s\n",
  873. getSaNameT (&req_exec_msg_queueclose->queue_name));
  874. queue = queue_find (&req_exec_msg_queueclose->queue_name);
  875. if (queue == 0) {
  876. goto error_exit;
  877. }
  878. queue->refcount -= 1;
  879. if (queue->refcount == 0) {
  880. /* free queue */
  881. }
  882. error_exit:
  883. if (message_source_is_local(&req_exec_msg_queueclose->source))
  884. {
  885. /* TODO */
  886. /*
  887. * msg_queue_cleanup_remove (
  888. * req_exec_msg_queueclose->source.conn_info,
  889. * req_exec_msg_queueclose->queue_handle);
  890. */
  891. res_lib_msg_queueclose.header.size =
  892. sizeof (struct res_lib_msg_queueclose);
  893. res_lib_msg_queueclose.header.id =
  894. MESSAGE_RES_MSG_QUEUECLOSE;
  895. res_lib_msg_queueclose.header.error = error;
  896. openais_conn_send_response (
  897. req_exec_msg_queueclose->source.conn,
  898. &res_lib_msg_queueclose,
  899. sizeof (struct res_lib_msg_queueclose));
  900. }
  901. }
  902. static void message_handler_req_exec_msg_queuestatusget (
  903. void *message,
  904. unsigned int nodeid)
  905. {
  906. #if 0
  907. struct req_exec_msg_queuestatusget *req_exec_msg_queuestatusget =
  908. (struct req_exec_msg_queuestatusget *)message;
  909. struct res_lib_msg_queuestatusget res_lib_msg_queuestatusget;
  910. #endif
  911. }
  912. static void message_handler_req_exec_msg_queueunlink (
  913. void *message,
  914. unsigned int nodeid)
  915. {
  916. #if 0
  917. struct req_exec_msg_queueunlink *req_exec_msg_queueunlink =
  918. (struct req_exec_msg_queueunlink *)message;
  919. struct res_lib_msg_queueunlink res_lib_msg_queueunlink;
  920. #endif
  921. }
  922. static void message_handler_req_exec_msg_queuegroupcreate (
  923. void *message,
  924. unsigned int nodeid)
  925. {
  926. struct req_exec_msg_queuegroupcreate *req_exec_msg_queuegroupcreate =
  927. (struct req_exec_msg_queuegroupcreate *)message;
  928. struct res_lib_msg_queuegroupcreate res_lib_msg_queuegroupcreate;
  929. struct queue_group *queue_group;
  930. SaAisErrorT error = SA_AIS_OK;
  931. queue_group = queue_group_find (&req_exec_msg_queuegroupcreate->queue_group_name);
  932. if (queue_group == 0) {
  933. queue_group = malloc (sizeof (struct queue_group));
  934. if (queue_group == 0) {
  935. error = SA_AIS_ERR_NO_MEMORY;
  936. goto error_exit;
  937. }
  938. memset (queue_group, 0, sizeof (struct queue_group));
  939. memcpy (&queue_group->name,
  940. &req_exec_msg_queuegroupcreate->queue_group_name,
  941. sizeof (SaNameT));
  942. list_init (&queue_group->list);
  943. list_init (&queue_group->message_queue_head);
  944. list_add (&queue_group->list, &queue_group_list_head);
  945. } else {
  946. error = SA_AIS_ERR_EXIST;
  947. }
  948. error_exit:
  949. if (message_source_is_local(&req_exec_msg_queuegroupcreate->source)) {
  950. res_lib_msg_queuegroupcreate.header.size =
  951. sizeof (struct res_lib_msg_queuegroupcreate);
  952. res_lib_msg_queuegroupcreate.header.id =
  953. MESSAGE_RES_MSG_QUEUEGROUPCREATE;
  954. res_lib_msg_queuegroupcreate.header.error = error;
  955. openais_conn_send_response (
  956. req_exec_msg_queuegroupcreate->source.conn,
  957. &res_lib_msg_queuegroupcreate,
  958. sizeof (struct res_lib_msg_queuegroupcreate));
  959. }
  960. }
  961. static void message_handler_req_exec_msg_queuegroupinsert (
  962. void *message,
  963. unsigned int nodeid)
  964. {
  965. struct req_exec_msg_queuegroupinsert *req_exec_msg_queuegroupinsert =
  966. (struct req_exec_msg_queuegroupinsert *)message;
  967. struct res_lib_msg_queuegroupinsert res_lib_msg_queuegroupinsert;
  968. struct res_lib_msg_queuegrouptrack res_lib_msg_queuegrouptrack;
  969. struct message_queue *queue;
  970. struct queue_group *queue_group;
  971. struct queue_group_entry *queue_group_entry;
  972. SaMsgQueueGroupNotificationT *notification;
  973. SaAisErrorT error = SA_AIS_OK;
  974. SaAisErrorT error_cb = SA_AIS_OK;
  975. unsigned int change_count = 0;
  976. unsigned int member_count = 0;
  977. queue_group = queue_group_find (&req_exec_msg_queuegroupinsert->queue_group_name);
  978. if (queue_group == 0) {
  979. error = SA_AIS_ERR_NOT_EXIST;
  980. goto error_exit;
  981. }
  982. queue = queue_find (&req_exec_msg_queuegroupinsert->queue_name);
  983. if (queue == 0) {
  984. error = SA_AIS_ERR_NOT_EXIST;
  985. goto error_exit;
  986. }
  987. queue_group_entry = malloc (sizeof (struct queue_group_entry));
  988. if (queue_group_entry == 0) {
  989. error = SA_AIS_ERR_NO_MEMORY;
  990. goto error_exit;
  991. }
  992. list_init (&queue_group_entry->list);
  993. list_add (&queue_group_entry->list, &queue_group->message_queue_head);
  994. list_add (&queue->list, &queue_list_head);
  995. queue_group_entry->message_queue = queue;
  996. queue_group_entry->change = SA_MSG_QUEUE_GROUP_ADDED;
  997. if (queue_group->track_flags & SA_TRACK_CHANGES) {
  998. member_count = queue_group_member_count (queue_group);
  999. change_count = queue_group_change_count (queue_group);
  1000. notification = malloc (sizeof (SaMsgQueueGroupNotificationT) * member_count);
  1001. if (notification == NULL) {
  1002. error_cb = SA_AIS_ERR_NO_MEMORY;
  1003. goto error_track;
  1004. }
  1005. memset (notification, 0, sizeof (SaMsgQueueGroupNotificationT) * member_count);
  1006. res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems =
  1007. queue_group_track (queue_group,
  1008. SA_TRACK_CHANGES,
  1009. (void *)(notification));
  1010. }
  1011. if (queue_group->track_flags & SA_TRACK_CHANGES_ONLY) {
  1012. member_count = queue_group_member_count (queue_group);
  1013. change_count = queue_group_change_count (queue_group);
  1014. notification = malloc (sizeof (SaMsgQueueGroupNotificationT) * change_count);
  1015. if (notification == NULL) {
  1016. error_cb = SA_AIS_ERR_NO_MEMORY;
  1017. goto error_track;
  1018. }
  1019. memset (notification, 0, sizeof (SaMsgQueueGroupNotificationT) * change_count);
  1020. res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems =
  1021. queue_group_track (queue_group,
  1022. SA_TRACK_CHANGES_ONLY,
  1023. (void *)(notification));
  1024. }
  1025. error_track:
  1026. queue_group_entry->change = SA_MSG_QUEUE_GROUP_NO_CHANGE;
  1027. error_exit:
  1028. if (message_source_is_local(&req_exec_msg_queuegroupinsert->source)) {
  1029. res_lib_msg_queuegroupinsert.header.size =
  1030. sizeof (struct res_lib_msg_queuegroupinsert);
  1031. res_lib_msg_queuegroupinsert.header.id =
  1032. MESSAGE_RES_MSG_QUEUEGROUPINSERT;
  1033. res_lib_msg_queuegroupinsert.header.error = error;
  1034. openais_conn_send_response (
  1035. req_exec_msg_queuegroupinsert->source.conn,
  1036. &res_lib_msg_queuegroupinsert,
  1037. sizeof (struct res_lib_msg_queuegroupinsert));
  1038. /*
  1039. * Track changes (callback) if tracking is enabled
  1040. */
  1041. if ((queue_group->track_flags & SA_TRACK_CHANGES) ||
  1042. (queue_group->track_flags & SA_TRACK_CHANGES_ONLY))
  1043. {
  1044. res_lib_msg_queuegrouptrack.header.size =
  1045. (sizeof (struct res_lib_msg_queuegrouptrack) +
  1046. (sizeof (SaMsgQueueGroupNotificationT) *
  1047. res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems));
  1048. res_lib_msg_queuegrouptrack.header.id =
  1049. MESSAGE_RES_MSG_QUEUEGROUPTRACK;
  1050. res_lib_msg_queuegrouptrack.header.error = error_cb;
  1051. res_lib_msg_queuegrouptrack.numberOfMembers = member_count;
  1052. memcpy (&res_lib_msg_queuegrouptrack.queueGroupName,
  1053. &req_exec_msg_queuegroupinsert->queue_group_name,
  1054. sizeof (SaNameT));
  1055. openais_conn_send_response (
  1056. openais_conn_partner_get (req_exec_msg_queuegroupinsert->source.conn),
  1057. &res_lib_msg_queuegrouptrack,
  1058. sizeof (struct res_lib_msg_queuegrouptrack));
  1059. openais_conn_send_response (
  1060. openais_conn_partner_get (req_exec_msg_queuegroupinsert->source.conn),
  1061. notification,
  1062. (sizeof (SaMsgQueueGroupNotificationT) *
  1063. res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems));
  1064. }
  1065. }
  1066. }
  1067. static void message_handler_req_exec_msg_queuegroupremove (
  1068. void *message,
  1069. unsigned int nodeid)
  1070. {
  1071. struct req_exec_msg_queuegroupremove *req_exec_msg_queuegroupremove =
  1072. (struct req_exec_msg_queuegroupremove *)message;
  1073. struct res_lib_msg_queuegroupremove res_lib_msg_queuegroupremove;
  1074. struct res_lib_msg_queuegrouptrack res_lib_msg_queuegrouptrack;
  1075. struct queue_group *queue_group;
  1076. struct message_queue *queue;
  1077. struct queue_group_entry *queue_group_entry;
  1078. SaMsgQueueGroupNotificationT *notification;
  1079. SaAisErrorT error = SA_AIS_OK;
  1080. SaAisErrorT error_cb = SA_AIS_OK;
  1081. unsigned int change_count = 0;
  1082. unsigned int member_count = 0;
  1083. queue_group = queue_group_find (&req_exec_msg_queuegroupremove->queue_group_name);
  1084. if (queue_group == 0) {
  1085. error = SA_AIS_ERR_NOT_EXIST;
  1086. goto error_exit;
  1087. }
  1088. queue = queue_find (&req_exec_msg_queuegroupremove->queue_name);
  1089. if (queue == 0) {
  1090. error = SA_AIS_ERR_NOT_EXIST;
  1091. goto error_exit;
  1092. }
  1093. queue_group_entry = queue_group_entry_find (queue_group, queue);
  1094. if (queue_group_entry == 0) {
  1095. error = SA_AIS_ERR_NOT_EXIST;
  1096. goto error_exit;
  1097. }
  1098. queue_group_entry->change = SA_MSG_QUEUE_GROUP_REMOVED;
  1099. if (queue_group->track_flags & SA_TRACK_CHANGES) {
  1100. member_count = queue_group_member_count (queue_group);
  1101. change_count = queue_group_change_count (queue_group);
  1102. notification = malloc (sizeof (SaMsgQueueGroupNotificationT) * member_count);
  1103. if (notification == NULL) {
  1104. error_cb = SA_AIS_ERR_NO_MEMORY;
  1105. goto error_track;
  1106. }
  1107. memset (notification, 0, (sizeof (SaMsgQueueGroupNotificationT) * member_count));
  1108. res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems =
  1109. queue_group_track (queue_group,
  1110. SA_TRACK_CHANGES,
  1111. (void *)(notification));
  1112. }
  1113. if (queue_group->track_flags & SA_TRACK_CHANGES_ONLY) {
  1114. member_count = queue_group_member_count (queue_group);
  1115. change_count = queue_group_change_count (queue_group);
  1116. notification = malloc (sizeof (SaMsgQueueGroupNotificationT) * change_count);
  1117. if (notification == NULL) {
  1118. error_cb = SA_AIS_ERR_NO_MEMORY;
  1119. goto error_track;
  1120. }
  1121. memset (notification, 0, (sizeof (SaMsgQueueGroupNotificationT) * change_count));
  1122. res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems =
  1123. queue_group_track (queue_group,
  1124. SA_TRACK_CHANGES_ONLY,
  1125. (void *)(notification));
  1126. }
  1127. error_track:
  1128. queue_group_entry->change = SA_MSG_QUEUE_GROUP_NO_CHANGE;
  1129. list_del (&queue_group_entry->list);
  1130. error_exit:
  1131. if (message_source_is_local(&req_exec_msg_queuegroupremove->source)) {
  1132. res_lib_msg_queuegroupremove.header.size =
  1133. sizeof (struct res_lib_msg_queuegroupremove);
  1134. res_lib_msg_queuegroupremove.header.id =
  1135. MESSAGE_RES_MSG_QUEUEGROUPREMOVE;
  1136. res_lib_msg_queuegroupremove.header.error = error;
  1137. openais_conn_send_response (
  1138. req_exec_msg_queuegroupremove->source.conn,
  1139. &res_lib_msg_queuegroupremove,
  1140. sizeof (struct res_lib_msg_queuegroupremove));
  1141. /*
  1142. * Track changes (callback) if tracking is enabled
  1143. */
  1144. if ((queue_group->track_flags & SA_TRACK_CHANGES) ||
  1145. (queue_group->track_flags & SA_TRACK_CHANGES_ONLY))
  1146. {
  1147. res_lib_msg_queuegrouptrack.header.size =
  1148. (sizeof (struct res_lib_msg_queuegrouptrack) +
  1149. (sizeof (SaMsgQueueGroupNotificationT) *
  1150. res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems));
  1151. res_lib_msg_queuegrouptrack.header.id =
  1152. MESSAGE_RES_MSG_QUEUEGROUPTRACK;
  1153. res_lib_msg_queuegrouptrack.header.error = error_cb;
  1154. res_lib_msg_queuegrouptrack.numberOfMembers = member_count;
  1155. memcpy (&res_lib_msg_queuegrouptrack.queueGroupName,
  1156. &req_exec_msg_queuegroupremove->queue_group_name,
  1157. sizeof (SaNameT));
  1158. openais_conn_send_response (
  1159. openais_conn_partner_get (req_exec_msg_queuegroupremove->source.conn),
  1160. &res_lib_msg_queuegrouptrack,
  1161. sizeof (struct res_lib_msg_queuegrouptrack));
  1162. openais_conn_send_response (
  1163. openais_conn_partner_get (req_exec_msg_queuegroupremove->source.conn),
  1164. notification,
  1165. (sizeof (SaMsgQueueGroupNotificationT) *
  1166. res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems));
  1167. }
  1168. }
  1169. }
  1170. static void message_handler_req_exec_msg_queuegroupdelete (
  1171. void *message,
  1172. unsigned int nodeid)
  1173. {
  1174. struct req_exec_msg_queuegroupdelete *req_exec_msg_queuegroupdelete =
  1175. (struct req_exec_msg_queuegroupdelete *)message;
  1176. struct res_lib_msg_queuegroupdelete res_lib_msg_queuegroupdelete;
  1177. struct queue_group *queue_group;
  1178. SaAisErrorT error = SA_AIS_OK;
  1179. queue_group = queue_group_find (&req_exec_msg_queuegroupdelete->queue_group_name);
  1180. if (queue_group) {
  1181. list_del (&queue_group->list);
  1182. free (queue_group);
  1183. } else {
  1184. error = SA_AIS_ERR_NOT_EXIST;
  1185. }
  1186. if (message_source_is_local(&req_exec_msg_queuegroupdelete->source)) {
  1187. res_lib_msg_queuegroupdelete.header.size =
  1188. sizeof (struct res_lib_msg_queuegroupdelete);
  1189. res_lib_msg_queuegroupdelete.header.id =
  1190. MESSAGE_RES_MSG_QUEUEGROUPDELETE;
  1191. res_lib_msg_queuegroupdelete.header.error = error;
  1192. openais_conn_send_response (
  1193. req_exec_msg_queuegroupdelete->source.conn,
  1194. &res_lib_msg_queuegroupdelete,
  1195. sizeof (struct res_lib_msg_queuegroupdelete));
  1196. }
  1197. }
  1198. static void message_handler_req_exec_msg_queuegrouptrack (
  1199. void *message,
  1200. unsigned int nodeid)
  1201. {
  1202. struct req_exec_msg_queuegrouptrack *req_exec_msg_queuegrouptrack =
  1203. (struct req_exec_msg_queuegrouptrack *)message;
  1204. struct res_lib_msg_queuegrouptrack res_lib_msg_queuegrouptrack;
  1205. struct queue_group *queue_group;
  1206. SaAisErrorT error = SA_AIS_OK;
  1207. unsigned int change_count = 0;
  1208. unsigned int member_count = 0;
  1209. SaMsgQueueGroupNotificationT *notification;
  1210. queue_group = queue_group_find (&req_exec_msg_queuegrouptrack->queue_group_name);
  1211. if (queue_group == 0) {
  1212. error = SA_AIS_ERR_NOT_EXIST;
  1213. goto error_exit;
  1214. }
  1215. member_count = queue_group_member_count (queue_group);
  1216. change_count = queue_group_change_count (queue_group);
  1217. if (req_exec_msg_queuegrouptrack->track_flags & SA_TRACK_CURRENT) {
  1218. /* DEBUG */
  1219. log_printf (LOG_LEVEL_NOTICE, "[DEBUG]: SA_TRACK_CURRENT\n");
  1220. notification = malloc (sizeof (SaMsgQueueGroupNotificationT) * member_count);
  1221. if (notification == NULL) {
  1222. error = SA_AIS_ERR_NO_MEMORY;
  1223. goto error_exit;
  1224. }
  1225. memset (notification, 0, sizeof (SaMsgQueueGroupNotificationT) * member_count);
  1226. res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems =
  1227. queue_group_track (queue_group, SA_TRACK_CURRENT, (void *)(notification));
  1228. }
  1229. if (req_exec_msg_queuegrouptrack->track_flags & SA_TRACK_CHANGES) {
  1230. /* DEBUG */
  1231. log_printf (LOG_LEVEL_NOTICE, "[DEBUG]: SA_TRACK_CHANGES\n");
  1232. queue_group->track_flags = req_exec_msg_queuegrouptrack->track_flags;
  1233. }
  1234. if (req_exec_msg_queuegrouptrack->track_flags & SA_TRACK_CHANGES_ONLY) {
  1235. /* DEBUG */
  1236. log_printf (LOG_LEVEL_NOTICE, "[DEBUG]: SA_TRACK_CHANGES_ONLY\n");
  1237. queue_group->track_flags = req_exec_msg_queuegrouptrack->track_flags;
  1238. }
  1239. error_exit:
  1240. if (message_source_is_local(&req_exec_msg_queuegrouptrack->source)) {
  1241. res_lib_msg_queuegrouptrack.header.size =
  1242. sizeof (struct res_lib_msg_queuegrouptrack);
  1243. res_lib_msg_queuegrouptrack.header.id =
  1244. MESSAGE_RES_MSG_QUEUEGROUPTRACK;
  1245. res_lib_msg_queuegrouptrack.header.error = error;
  1246. res_lib_msg_queuegrouptrack.numberOfMembers = member_count;
  1247. memcpy (&res_lib_msg_queuegrouptrack.queueGroupName,
  1248. &req_exec_msg_queuegrouptrack->queue_group_name,
  1249. sizeof (SaNameT));
  1250. if (req_exec_msg_queuegrouptrack->track_flags & SA_TRACK_CURRENT) {
  1251. if (req_exec_msg_queuegrouptrack->buffer_flag) {
  1252. res_lib_msg_queuegrouptrack.header.size +=
  1253. (sizeof (SaMsgQueueGroupNotificationT) *
  1254. res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems);
  1255. openais_conn_send_response (
  1256. req_exec_msg_queuegrouptrack->source.conn,
  1257. &res_lib_msg_queuegrouptrack,
  1258. sizeof (struct res_lib_msg_queuegrouptrack));
  1259. openais_conn_send_response (
  1260. req_exec_msg_queuegrouptrack->source.conn,
  1261. notification,
  1262. (sizeof (SaMsgQueueGroupNotificationT) *
  1263. res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems));
  1264. } else {
  1265. openais_conn_send_response (
  1266. req_exec_msg_queuegrouptrack->source.conn,
  1267. &res_lib_msg_queuegrouptrack,
  1268. sizeof (struct res_lib_msg_queuegrouptrack));
  1269. res_lib_msg_queuegrouptrack.header.size +=
  1270. (sizeof (SaMsgQueueGroupNotificationT) *
  1271. res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems);
  1272. openais_conn_send_response (
  1273. openais_conn_partner_get (req_exec_msg_queuegrouptrack->source.conn),
  1274. &res_lib_msg_queuegrouptrack,
  1275. sizeof (struct res_lib_msg_queuegrouptrack));
  1276. openais_conn_send_response (
  1277. openais_conn_partner_get (req_exec_msg_queuegrouptrack->source.conn),
  1278. notification,
  1279. (sizeof (SaMsgQueueGroupNotificationT) *
  1280. res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems));
  1281. }
  1282. } else {
  1283. openais_conn_send_response (
  1284. req_exec_msg_queuegrouptrack->source.conn,
  1285. &res_lib_msg_queuegrouptrack,
  1286. sizeof (struct res_lib_msg_queuegrouptrack));
  1287. }
  1288. }
  1289. }
  1290. static void message_handler_req_exec_msg_queuegrouptrackstop (
  1291. void *message,
  1292. unsigned int nodeid)
  1293. {
  1294. struct req_exec_msg_queuegrouptrackstop *req_exec_msg_queuegrouptrackstop =
  1295. (struct req_exec_msg_queuegrouptrackstop *)message;
  1296. struct res_lib_msg_queuegrouptrackstop res_lib_msg_queuegrouptrackstop;
  1297. struct queue_group *queue_group;
  1298. SaAisErrorT error = SA_AIS_OK;
  1299. queue_group = queue_group_find (&req_exec_msg_queuegrouptrackstop->queue_group_name);
  1300. if (queue_group == 0) {
  1301. error = SA_AIS_ERR_NOT_EXIST;
  1302. goto error_exit;
  1303. }
  1304. if ((queue_group->track_flags != SA_TRACK_CHANGES) &&
  1305. (queue_group->track_flags != SA_TRACK_CHANGES_ONLY)) {
  1306. error = SA_AIS_ERR_NOT_EXIST;
  1307. goto error_exit;
  1308. }
  1309. queue_group->track_flags = 0;
  1310. error_exit:
  1311. if (message_source_is_local(&req_exec_msg_queuegrouptrackstop->source)) {
  1312. res_lib_msg_queuegrouptrackstop.header.size =
  1313. sizeof (struct res_lib_msg_queuegrouptrackstop);
  1314. res_lib_msg_queuegrouptrackstop.header.id =
  1315. MESSAGE_RES_MSG_QUEUEGROUPTRACKSTOP;
  1316. res_lib_msg_queuegrouptrackstop.header.error = error;
  1317. openais_conn_send_response (
  1318. req_exec_msg_queuegrouptrackstop->source.conn,
  1319. &res_lib_msg_queuegrouptrackstop,
  1320. sizeof (struct res_lib_msg_queuegrouptrackstop));
  1321. }
  1322. }
  1323. static void message_handler_req_exec_msg_messagesend (
  1324. void *message,
  1325. unsigned int nodeid)
  1326. {
  1327. struct req_exec_msg_messagesend *req_exec_msg_messagesend =
  1328. (struct req_exec_msg_messagesend *)message;
  1329. struct res_lib_msg_messagesend res_lib_msg_messagesend;
  1330. struct res_lib_msg_messagesendasync res_lib_msg_messagesendasync;
  1331. struct message_queue *queue;
  1332. struct message_entry *entry;
  1333. SaAisErrorT error = SA_AIS_OK;
  1334. char *data = ((char *)(req_exec_msg_messagesend) +
  1335. sizeof (struct req_exec_msg_messagesend));
  1336. log_printf (LOG_LEVEL_NOTICE, "EXEC request: saMsgMessageSend %s\n",
  1337. getSaNameT (&req_exec_msg_messagesend->destination));
  1338. queue = queue_find (&req_exec_msg_messagesend->destination);
  1339. if (queue == NULL) {
  1340. error = SA_AIS_ERR_NOT_EXIST;
  1341. goto error_exit;
  1342. }
  1343. entry = malloc (sizeof (struct message_entry));
  1344. if (entry == NULL) {
  1345. error = SA_AIS_ERR_NO_MEMORY;
  1346. goto error_exit;
  1347. }
  1348. memset (entry, 0, sizeof (struct message_entry));
  1349. memcpy (&entry->message, &req_exec_msg_messagesend->message,
  1350. sizeof (SaMsgMessageT));
  1351. entry->message.data = malloc (entry->message.size);
  1352. if (entry->message.data == NULL) {
  1353. error = SA_AIS_ERR_NO_MEMORY;
  1354. goto error_exit;
  1355. }
  1356. memset (entry->message.data, 0, entry->message.size);
  1357. memcpy (entry->message.data, (void *)(data), entry->message.size);
  1358. entry->time = clust_time_now();
  1359. list_add_tail (&entry->list, &queue->message_list_head);
  1360. error_exit:
  1361. if (message_source_is_local(&req_exec_msg_messagesend->source)) {
  1362. if (req_exec_msg_messagesend->async_call) {
  1363. res_lib_msg_messagesendasync.header.size =
  1364. sizeof (struct res_lib_msg_messagesendasync);
  1365. res_lib_msg_messagesendasync.header.id =
  1366. MESSAGE_RES_MSG_MESSAGESENDASYNC;
  1367. res_lib_msg_messagesendasync.header.error = error;
  1368. res_lib_msg_messagesendasync.invocation =
  1369. req_exec_msg_messagesend->invocation;
  1370. memcpy (&res_lib_msg_messagesendasync.source,
  1371. &req_exec_msg_messagesend->source,
  1372. sizeof (mar_message_source_t));
  1373. openais_conn_send_response (
  1374. req_exec_msg_messagesend->source.conn,
  1375. &res_lib_msg_messagesendasync,
  1376. sizeof (struct res_lib_msg_messagesendasync));
  1377. openais_conn_send_response (
  1378. openais_conn_partner_get (req_exec_msg_messagesend->source.conn),
  1379. &res_lib_msg_messagesendasync,
  1380. sizeof (struct res_lib_msg_messagesendasync));
  1381. } else {
  1382. res_lib_msg_messagesend.header.size =
  1383. sizeof (struct res_lib_msg_messagesend);
  1384. res_lib_msg_messagesend.header.id =
  1385. MESSAGE_RES_MSG_MESSAGESEND;
  1386. res_lib_msg_messagesend.header.error = error;
  1387. memcpy (&res_lib_msg_messagesend.source,
  1388. &req_exec_msg_messagesend->source,
  1389. sizeof (mar_message_source_t));
  1390. openais_conn_send_response (
  1391. req_exec_msg_messagesend->source.conn,
  1392. &res_lib_msg_messagesend,
  1393. sizeof (struct res_lib_msg_messagesend));
  1394. }
  1395. }
  1396. }
  1397. static void message_handler_req_exec_msg_messageget (
  1398. void *message,
  1399. unsigned int nodeid)
  1400. {
  1401. struct req_exec_msg_messageget *req_exec_msg_messageget =
  1402. (struct req_exec_msg_messageget *)message;
  1403. struct res_lib_msg_messageget res_lib_msg_messageget;
  1404. struct message_queue *queue;
  1405. struct message_entry *entry;
  1406. SaAisErrorT error = SA_AIS_OK;
  1407. log_printf (LOG_LEVEL_NOTICE, "EXEC request: saMsgMessageGet %s\n",
  1408. getSaNameT (&req_exec_msg_messageget->queue_name));
  1409. queue = queue_find (&req_exec_msg_messageget->queue_name);
  1410. if (queue == NULL) {
  1411. error = SA_AIS_ERR_NOT_EXIST;
  1412. goto error_exit;
  1413. }
  1414. if (list_empty (queue->message_list_head.next)) {
  1415. error = SA_AIS_ERR_TIMEOUT; /* FIX ME */
  1416. goto error_exit;
  1417. }
  1418. entry = list_entry (queue->message_list_head.next, struct message_entry, list);
  1419. if (entry == NULL) {
  1420. error = SA_AIS_ERR_LIBRARY; /* FIX ME */
  1421. goto error_exit;
  1422. }
  1423. list_del (queue->message_list_head.next);
  1424. error_exit:
  1425. if (message_source_is_local(&req_exec_msg_messageget->source)) {
  1426. res_lib_msg_messageget.header.size =
  1427. sizeof (struct res_lib_msg_messageget);
  1428. res_lib_msg_messageget.header.id =
  1429. MESSAGE_RES_MSG_MESSAGEGET;
  1430. res_lib_msg_messageget.header.error = error;
  1431. memcpy (&res_lib_msg_messageget.message, &entry->message,
  1432. sizeof (SaMsgMessageT));
  1433. memcpy (&res_lib_msg_messageget.source,
  1434. &req_exec_msg_messageget->source,
  1435. sizeof (mar_message_source_t));
  1436. openais_conn_send_response (
  1437. req_exec_msg_messageget->source.conn,
  1438. &res_lib_msg_messageget,
  1439. sizeof (struct res_lib_msg_messageget));
  1440. openais_conn_send_response (
  1441. req_exec_msg_messageget->source.conn,
  1442. res_lib_msg_messageget.message.data,
  1443. res_lib_msg_messageget.message.size);
  1444. }
  1445. }
  1446. static void message_handler_req_exec_msg_messagecancel (
  1447. void *message,
  1448. unsigned int nodeid)
  1449. {
  1450. #if 0
  1451. struct req_exec_msg_messagecancel *req_exec_msg_messagecancel =
  1452. (struct req_exec_msg_messagecancel *)message;
  1453. struct res_lib_msg_messagecancel res_lib_msg_messagecancel;
  1454. #endif
  1455. }
  1456. static void message_handler_req_exec_msg_messagesendreceive (
  1457. void *message,
  1458. unsigned int nodeid)
  1459. {
  1460. #if 0
  1461. struct req_exec_msg_messagesendreceive *req_exec_msg_messagesendreceive =
  1462. (struct req_exec_msg_messagesendreceive *)message;
  1463. struct res_lib_msg_messagesendreceive res_lib_msg_messagesendreceive;
  1464. #endif
  1465. }
  1466. static void message_handler_req_exec_msg_messagereply (
  1467. void *message,
  1468. unsigned int nodeid)
  1469. {
  1470. #if 0
  1471. struct req_exec_msg_messagereply *req_exec_msg_messagereply =
  1472. (struct req_exec_msg_messagereply *)message;
  1473. struct res_lib_msg_messagereply res_lib_msg_messagereply;
  1474. #endif
  1475. }
  1476. static void message_handler_req_lib_msg_queueopen (
  1477. void *conn,
  1478. void *msg)
  1479. {
  1480. struct req_lib_msg_queueopen *req_lib_msg_queueopen =
  1481. (struct req_lib_msg_queueopen *)msg;
  1482. struct req_exec_msg_queueopen req_exec_msg_queueopen;
  1483. struct iovec iovec;
  1484. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueOpen %s\n",
  1485. getSaNameT (&req_lib_msg_queueopen->queueName));
  1486. req_exec_msg_queueopen.header.size =
  1487. sizeof (struct req_exec_msg_queueopen);
  1488. req_exec_msg_queueopen.header.id =
  1489. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEOPEN);
  1490. message_source_set (&req_exec_msg_queueopen.source, conn);
  1491. memcpy (&req_exec_msg_queueopen.queue_name,
  1492. &req_lib_msg_queueopen->queueName, sizeof (SaNameT));
  1493. memcpy (&req_exec_msg_queueopen.creation_attributes,
  1494. &req_lib_msg_queueopen->creationAttributes,
  1495. sizeof (SaMsgQueueCreationAttributesT));
  1496. req_exec_msg_queueopen.async_call = 0;
  1497. req_exec_msg_queueopen.invocation = 0;
  1498. req_exec_msg_queueopen.queue_handle = req_lib_msg_queueopen->queueHandle;
  1499. req_exec_msg_queueopen.openFlags = req_lib_msg_queueopen->openFlags;
  1500. req_exec_msg_queueopen.timeout = req_lib_msg_queueopen->timeout;
  1501. iovec.iov_base = (char *)&req_exec_msg_queueopen;
  1502. iovec.iov_len = sizeof (req_exec_msg_queueopen);
  1503. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1504. TOTEMPG_AGREED) == 0);
  1505. }
  1506. static void message_handler_req_lib_msg_queueopenasync (
  1507. void *conn,
  1508. void *msg)
  1509. {
  1510. struct req_lib_msg_queueopen *req_lib_msg_queueopen =
  1511. (struct req_lib_msg_queueopen *)msg;
  1512. struct req_exec_msg_queueopen req_exec_msg_queueopen;
  1513. struct iovec iovec;
  1514. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueOpenAsync %s\n",
  1515. getSaNameT (&req_lib_msg_queueopen->queueName));
  1516. req_exec_msg_queueopen.header.size =
  1517. sizeof (struct req_exec_msg_queueopen);
  1518. req_exec_msg_queueopen.header.id =
  1519. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEOPEN);
  1520. message_source_set (&req_exec_msg_queueopen.source, conn);
  1521. memcpy (&req_exec_msg_queueopen.queue_name,
  1522. &req_lib_msg_queueopen->queueName, sizeof (SaNameT));
  1523. memcpy (&req_exec_msg_queueopen.creation_attributes,
  1524. &req_lib_msg_queueopen->creationAttributes,
  1525. sizeof (SaMsgQueueCreationAttributesT));
  1526. req_exec_msg_queueopen.async_call = 1;
  1527. req_exec_msg_queueopen.invocation = req_lib_msg_queueopen->invocation;
  1528. req_exec_msg_queueopen.queue_handle = req_lib_msg_queueopen->queueHandle;
  1529. req_exec_msg_queueopen.openFlags = req_lib_msg_queueopen->openFlags;
  1530. req_exec_msg_queueopen.timeout = SA_TIME_END;
  1531. iovec.iov_base = (char *)&req_exec_msg_queueopen;
  1532. iovec.iov_len = sizeof (req_exec_msg_queueopen);
  1533. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1534. TOTEMPG_AGREED) == 0);
  1535. }
  1536. static void message_handler_req_lib_msg_queueclose (
  1537. void *conn,
  1538. void *msg)
  1539. {
  1540. struct req_lib_msg_queueclose *req_lib_msg_queueclose =
  1541. (struct req_lib_msg_queueclose *)msg;
  1542. struct req_exec_msg_queueclose req_exec_msg_queueclose;
  1543. struct iovec iovec;
  1544. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueClose %s\n",
  1545. getSaNameT (&req_lib_msg_queueclose->queueName));
  1546. req_exec_msg_queueclose.header.size =
  1547. sizeof (struct req_exec_msg_queueclose);
  1548. req_exec_msg_queueclose.header.id =
  1549. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUECLOSE);
  1550. message_source_set (&req_exec_msg_queueclose.source, conn);
  1551. memcpy (&req_exec_msg_queueclose.queue_name,
  1552. &req_lib_msg_queueclose->queueName, sizeof (SaNameT));
  1553. iovec.iov_base = (char *)&req_exec_msg_queueclose;
  1554. iovec.iov_len = sizeof (req_exec_msg_queueclose);
  1555. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1556. TOTEMPG_AGREED) == 0);
  1557. }
  1558. static void message_handler_req_lib_msg_queuestatusget (
  1559. void *conn,
  1560. void *msg)
  1561. {
  1562. struct req_lib_msg_queuestatusget *req_lib_msg_queuestatusget =
  1563. (struct req_lib_msg_queuestatusget *)msg;
  1564. struct req_exec_msg_queuestatusget req_exec_msg_queuestatusget;
  1565. struct iovec iovec;
  1566. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueStatusGet %s\n",
  1567. getSaNameT (&req_lib_msg_queuestatusget->queueName));
  1568. req_exec_msg_queuestatusget.header.size =
  1569. sizeof (struct req_exec_msg_queuestatusget);
  1570. req_exec_msg_queuestatusget.header.id =
  1571. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUESTATUSGET);
  1572. message_source_set (&req_exec_msg_queuestatusget.source, conn);
  1573. memcpy (&req_exec_msg_queuestatusget.queue_name,
  1574. &req_lib_msg_queuestatusget->queueName, sizeof (SaNameT));
  1575. iovec.iov_base = (char *)&req_exec_msg_queuestatusget;
  1576. iovec.iov_len = sizeof (req_exec_msg_queuestatusget);
  1577. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1578. TOTEMPG_AGREED) == 0);
  1579. }
  1580. static void message_handler_req_lib_msg_queueunlink (
  1581. void *conn,
  1582. void *msg)
  1583. {
  1584. struct req_lib_msg_queueunlink *req_lib_msg_queueunlink =
  1585. (struct req_lib_msg_queueunlink *)msg;
  1586. struct req_exec_msg_queueunlink req_exec_msg_queueunlink;
  1587. struct iovec iovec;
  1588. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueUnlink %s\n",
  1589. getSaNameT (&req_lib_msg_queueunlink->queueName));
  1590. req_exec_msg_queueunlink.header.size =
  1591. sizeof (struct req_exec_msg_queueunlink);
  1592. req_exec_msg_queueunlink.header.id =
  1593. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEUNLINK);
  1594. message_source_set (&req_exec_msg_queueunlink.source, conn);
  1595. memcpy (&req_exec_msg_queueunlink.queue_name,
  1596. &req_lib_msg_queueunlink->queueName, sizeof (SaNameT));
  1597. iovec.iov_base = (char *)&req_exec_msg_queueunlink;
  1598. iovec.iov_len = sizeof (req_exec_msg_queueunlink);
  1599. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1600. TOTEMPG_AGREED) == 0);
  1601. }
  1602. static void message_handler_req_lib_msg_queuegroupcreate (
  1603. void *conn,
  1604. void *msg)
  1605. {
  1606. struct req_lib_msg_queuegroupcreate *req_lib_msg_queuegroupcreate =
  1607. (struct req_lib_msg_queuegroupcreate *)msg;
  1608. struct req_exec_msg_queuegroupcreate req_exec_msg_queuegroupcreate;
  1609. struct iovec iovec;
  1610. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupCreate %s\n",
  1611. getSaNameT (&req_lib_msg_queuegroupcreate->queueGroupName));
  1612. req_exec_msg_queuegroupcreate.header.size =
  1613. sizeof (struct req_exec_msg_queuegroupcreate);
  1614. req_exec_msg_queuegroupcreate.header.id =
  1615. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPCREATE);
  1616. message_source_set (&req_exec_msg_queuegroupcreate.source, conn);
  1617. memcpy (&req_exec_msg_queuegroupcreate.queue_group_name,
  1618. &req_lib_msg_queuegroupcreate->queueGroupName, sizeof (SaNameT));
  1619. req_exec_msg_queuegroupcreate.policy =
  1620. req_lib_msg_queuegroupcreate->queueGroupPolicy;
  1621. iovec.iov_base = (char *)&req_exec_msg_queuegroupcreate;
  1622. iovec.iov_len = sizeof (req_exec_msg_queuegroupcreate);
  1623. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1624. TOTEMPG_AGREED) == 0);
  1625. }
  1626. static void message_handler_req_lib_msg_queuegroupinsert (
  1627. void *conn,
  1628. void *msg)
  1629. {
  1630. struct req_lib_msg_queuegroupinsert *req_lib_msg_queuegroupinsert =
  1631. (struct req_lib_msg_queuegroupinsert *)msg;
  1632. struct req_exec_msg_queuegroupinsert req_exec_msg_queuegroupinsert;
  1633. struct iovec iovec;
  1634. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupInsert %s\n",
  1635. getSaNameT (&req_lib_msg_queuegroupinsert->queueGroupName));
  1636. req_exec_msg_queuegroupinsert.header.size =
  1637. sizeof (struct req_exec_msg_queuegroupinsert);
  1638. req_exec_msg_queuegroupinsert.header.id =
  1639. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPINSERT);
  1640. message_source_set (&req_exec_msg_queuegroupinsert.source, conn);
  1641. memcpy (&req_exec_msg_queuegroupinsert.queue_name,
  1642. &req_lib_msg_queuegroupinsert->queueName, sizeof (SaNameT));
  1643. memcpy (&req_exec_msg_queuegroupinsert.queue_group_name,
  1644. &req_lib_msg_queuegroupinsert->queueGroupName, sizeof (SaNameT));
  1645. iovec.iov_base = (char *)&req_exec_msg_queuegroupinsert;
  1646. iovec.iov_len = sizeof (req_exec_msg_queuegroupinsert);
  1647. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1648. TOTEMPG_AGREED) == 0);
  1649. }
  1650. static void message_handler_req_lib_msg_queuegroupremove (
  1651. void *conn,
  1652. void *msg)
  1653. {
  1654. struct req_lib_msg_queuegroupremove *req_lib_msg_queuegroupremove =
  1655. (struct req_lib_msg_queuegroupremove *)msg;
  1656. struct req_exec_msg_queuegroupremove req_exec_msg_queuegroupremove;
  1657. struct iovec iovec;
  1658. req_exec_msg_queuegroupremove.header.size =
  1659. sizeof (struct req_exec_msg_queuegroupremove);
  1660. req_exec_msg_queuegroupremove.header.id =
  1661. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPREMOVE);
  1662. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupRemove %s\n",
  1663. getSaNameT (&req_lib_msg_queuegroupremove->queueGroupName));
  1664. message_source_set (&req_exec_msg_queuegroupremove.source, conn);
  1665. memcpy (&req_exec_msg_queuegroupremove.queue_name,
  1666. &req_lib_msg_queuegroupremove->queueName, sizeof (SaNameT));
  1667. memcpy (&req_exec_msg_queuegroupremove.queue_group_name,
  1668. &req_lib_msg_queuegroupremove->queueGroupName, sizeof (SaNameT));
  1669. iovec.iov_base = (char *)&req_exec_msg_queuegroupremove;
  1670. iovec.iov_len = sizeof (req_exec_msg_queuegroupremove);
  1671. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1672. TOTEMPG_AGREED) == 0);
  1673. }
  1674. static void message_handler_req_lib_msg_queuegroupdelete (
  1675. void *conn,
  1676. void *msg)
  1677. {
  1678. struct req_lib_msg_queuegroupdelete *req_lib_msg_queuegroupdelete =
  1679. (struct req_lib_msg_queuegroupdelete *)msg;
  1680. struct req_exec_msg_queuegroupdelete req_exec_msg_queuegroupdelete;
  1681. struct iovec iovec;
  1682. req_exec_msg_queuegroupdelete.header.size =
  1683. sizeof (struct req_exec_msg_queuegroupdelete);
  1684. req_exec_msg_queuegroupdelete.header.id =
  1685. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPDELETE);
  1686. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupDelete %s\n",
  1687. getSaNameT (&req_lib_msg_queuegroupdelete->queueGroupName));
  1688. message_source_set (&req_exec_msg_queuegroupdelete.source, conn);
  1689. memcpy (&req_exec_msg_queuegroupdelete.queue_group_name,
  1690. &req_lib_msg_queuegroupdelete->queueGroupName, sizeof (SaNameT));
  1691. iovec.iov_base = (char *)&req_exec_msg_queuegroupdelete;
  1692. iovec.iov_len = sizeof (req_exec_msg_queuegroupdelete);
  1693. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1694. TOTEMPG_AGREED) == 0);
  1695. }
  1696. static void message_handler_req_lib_msg_queuegrouptrack (
  1697. void *conn,
  1698. void *msg)
  1699. {
  1700. struct req_lib_msg_queuegrouptrack *req_lib_msg_queuegrouptrack =
  1701. (struct req_lib_msg_queuegrouptrack *)msg;
  1702. struct req_exec_msg_queuegrouptrack req_exec_msg_queuegrouptrack;
  1703. struct iovec iovec;
  1704. req_exec_msg_queuegrouptrack.header.size =
  1705. sizeof (struct req_exec_msg_queuegrouptrack);
  1706. req_exec_msg_queuegrouptrack.header.id =
  1707. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPTRACK);
  1708. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupTrack %s\n",
  1709. getSaNameT (&req_lib_msg_queuegrouptrack->queueGroupName));
  1710. message_source_set (&req_exec_msg_queuegrouptrack.source, conn);
  1711. memcpy (&req_exec_msg_queuegrouptrack.queue_group_name,
  1712. &req_lib_msg_queuegrouptrack->queueGroupName, sizeof (SaNameT));
  1713. req_exec_msg_queuegrouptrack.track_flags =
  1714. req_lib_msg_queuegrouptrack->trackFlags;
  1715. req_exec_msg_queuegrouptrack.buffer_flag =
  1716. req_lib_msg_queuegrouptrack->bufferFlag;
  1717. iovec.iov_base = (char *)&req_exec_msg_queuegrouptrack;
  1718. iovec.iov_len = sizeof (req_exec_msg_queuegrouptrack);
  1719. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1720. TOTEMPG_AGREED) == 0);
  1721. }
  1722. static void message_handler_req_lib_msg_queuegrouptrackstop (
  1723. void *conn,
  1724. void *msg)
  1725. {
  1726. struct req_lib_msg_queuegrouptrackstop *req_lib_msg_queuegrouptrackstop =
  1727. (struct req_lib_msg_queuegrouptrackstop *)msg;
  1728. struct req_exec_msg_queuegrouptrackstop req_exec_msg_queuegrouptrackstop;
  1729. struct iovec iovec;
  1730. req_exec_msg_queuegrouptrackstop.header.size =
  1731. sizeof (struct req_exec_msg_queuegrouptrackstop);
  1732. req_exec_msg_queuegrouptrackstop.header.id =
  1733. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPTRACKSTOP);
  1734. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupTrackStop %s\n",
  1735. getSaNameT (&req_lib_msg_queuegrouptrackstop->queueGroupName));
  1736. message_source_set (&req_exec_msg_queuegrouptrackstop.source, conn);
  1737. memcpy (&req_exec_msg_queuegrouptrackstop.queue_group_name,
  1738. &req_lib_msg_queuegrouptrackstop->queueGroupName, sizeof (SaNameT));
  1739. iovec.iov_base = (char *)&req_exec_msg_queuegrouptrackstop;
  1740. iovec.iov_len = sizeof (req_exec_msg_queuegrouptrackstop);
  1741. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1742. TOTEMPG_AGREED) == 0);
  1743. }
  1744. static void message_handler_req_lib_msg_messagesend (
  1745. void *conn,
  1746. void *msg)
  1747. {
  1748. struct req_lib_msg_messagesend *req_lib_msg_messagesend =
  1749. (struct req_lib_msg_messagesend *)msg;
  1750. struct req_exec_msg_messagesend req_exec_msg_messagesend;
  1751. struct iovec iovecs[2];
  1752. req_exec_msg_messagesend.header.size =
  1753. sizeof (struct req_exec_msg_messagesend);
  1754. req_exec_msg_messagesend.header.id =
  1755. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGESEND);
  1756. req_exec_msg_messagesend.async_call = 0;
  1757. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageSend %s\n",
  1758. getSaNameT (&req_lib_msg_messagesend->destination));
  1759. message_source_set (&req_exec_msg_messagesend.source, conn);
  1760. memcpy (&req_exec_msg_messagesend.destination,
  1761. &req_lib_msg_messagesend->destination, sizeof (SaNameT));
  1762. memcpy (&req_exec_msg_messagesend.message,
  1763. &req_lib_msg_messagesend->message, sizeof (SaMsgMessageT));
  1764. req_exec_msg_messagesend.async_call = 0;
  1765. req_exec_msg_messagesend.invocation = 0;
  1766. req_exec_msg_messagesend.ack_flags = req_lib_msg_messagesend->ackFlags;
  1767. req_exec_msg_messagesend.timeout = req_lib_msg_messagesend->timeout;
  1768. iovecs[0].iov_base = (char *)&req_exec_msg_messagesend;
  1769. iovecs[0].iov_len = sizeof (req_exec_msg_messagesend);
  1770. iovecs[1].iov_base = ((char *)req_lib_msg_messagesend) +
  1771. sizeof (struct req_lib_msg_messagesend);
  1772. iovecs[1].iov_len = req_lib_msg_messagesend->header.size -
  1773. sizeof (struct req_lib_msg_messagesend);
  1774. req_exec_msg_messagesend.header.size += iovecs[1].iov_len;
  1775. if (iovecs[1].iov_len > 0) {
  1776. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2,
  1777. TOTEMPG_AGREED) == 0);
  1778. } else {
  1779. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1,
  1780. TOTEMPG_AGREED) == 0);
  1781. }
  1782. }
  1783. static void message_handler_req_lib_msg_messagesendasync (
  1784. void *conn,
  1785. void *msg)
  1786. {
  1787. struct req_lib_msg_messagesend *req_lib_msg_messagesend =
  1788. (struct req_lib_msg_messagesend *)msg;
  1789. struct req_exec_msg_messagesend req_exec_msg_messagesend;
  1790. struct iovec iovecs[2];
  1791. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageSendAsync %s\n",
  1792. getSaNameT (&req_lib_msg_messagesend->destination));
  1793. req_exec_msg_messagesend.header.size =
  1794. sizeof (struct req_exec_msg_messagesend);
  1795. req_exec_msg_messagesend.header.id =
  1796. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGESEND);
  1797. message_source_set (&req_exec_msg_messagesend.source, conn);
  1798. memcpy (&req_exec_msg_messagesend.destination,
  1799. &req_lib_msg_messagesend->destination, sizeof (SaNameT));
  1800. memcpy (&req_exec_msg_messagesend.message,
  1801. &req_lib_msg_messagesend->message, sizeof (SaMsgMessageT));
  1802. req_exec_msg_messagesend.async_call = 1;
  1803. req_exec_msg_messagesend.invocation = req_lib_msg_messagesend->invocation;
  1804. req_exec_msg_messagesend.ack_flags = req_lib_msg_messagesend->ackFlags;
  1805. req_exec_msg_messagesend.timeout = SA_TIME_END;
  1806. iovecs[0].iov_base = (char *)&req_exec_msg_messagesend;
  1807. iovecs[0].iov_len = sizeof (req_exec_msg_messagesend);
  1808. iovecs[1].iov_base = ((char *)req_lib_msg_messagesend) +
  1809. sizeof (struct req_lib_msg_messagesend);
  1810. iovecs[1].iov_len = req_lib_msg_messagesend->header.size -
  1811. sizeof (struct req_lib_msg_messagesend);
  1812. req_exec_msg_messagesend.header.size += iovecs[1].iov_len;
  1813. if (iovecs[1].iov_len > 0) {
  1814. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2,
  1815. TOTEMPG_AGREED) == 0);
  1816. } else {
  1817. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2,
  1818. TOTEMPG_AGREED) == 0);
  1819. }
  1820. }
  1821. static void message_handler_req_lib_msg_messageget (
  1822. void *conn,
  1823. void *msg)
  1824. {
  1825. struct req_lib_msg_messageget *req_lib_msg_messageget =
  1826. (struct req_lib_msg_messageget *)msg;
  1827. struct req_exec_msg_messageget req_exec_msg_messageget;
  1828. struct iovec iovec;
  1829. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageGet %s\n",
  1830. getSaNameT (&req_lib_msg_messageget->queueName));
  1831. req_exec_msg_messageget.header.size =
  1832. sizeof (struct req_exec_msg_messageget);
  1833. req_exec_msg_messageget.header.id =
  1834. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGEGET);
  1835. message_source_set (&req_exec_msg_messageget.source, conn);
  1836. memcpy (&req_exec_msg_messageget.queue_name,
  1837. &req_lib_msg_messageget->queueName, sizeof (SaNameT));
  1838. iovec.iov_base = (char *)&req_exec_msg_messageget;
  1839. iovec.iov_len = sizeof (req_exec_msg_messageget);
  1840. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1841. TOTEMPG_AGREED) == 0);
  1842. }
  1843. static void message_handler_req_lib_msg_messagecancel (
  1844. void *conn,
  1845. void *msg)
  1846. {
  1847. struct req_lib_msg_messagecancel *req_lib_msg_messagecancel =
  1848. (struct req_lib_msg_messagecancel *)msg;
  1849. struct req_exec_msg_messagecancel req_exec_msg_messagecancel;
  1850. struct iovec iovec;
  1851. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageCancel %s\n",
  1852. getSaNameT (&req_lib_msg_messagecancel->queueName));
  1853. req_exec_msg_messagecancel.header.size =
  1854. sizeof (struct req_exec_msg_messagecancel);
  1855. req_exec_msg_messagecancel.header.id =
  1856. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGECANCEL);
  1857. message_source_set (&req_exec_msg_messagecancel.source, conn);
  1858. memcpy (&req_exec_msg_messagecancel.queue_name,
  1859. &req_lib_msg_messagecancel->queueName, sizeof (SaNameT));
  1860. iovec.iov_base = (char *)&req_exec_msg_messagecancel;
  1861. iovec.iov_len = sizeof (req_exec_msg_messagecancel);
  1862. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1863. TOTEMPG_AGREED) == 0);
  1864. }
  1865. static void message_handler_req_lib_msg_messagesendreceive (
  1866. void *conn,
  1867. void *msg)
  1868. {
  1869. struct req_lib_msg_messagesendreceive *req_lib_msg_messagesendreceive =
  1870. (struct req_lib_msg_messagesendreceive *)msg;
  1871. struct req_exec_msg_messagesendreceive req_exec_msg_messagesendreceive;
  1872. struct iovec iovec;
  1873. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageSendReceive %s\n",
  1874. getSaNameT (&req_lib_msg_messagesendreceive->queueName));
  1875. req_exec_msg_messagesendreceive.header.size =
  1876. sizeof (struct req_exec_msg_messagesendreceive);
  1877. req_exec_msg_messagesendreceive.header.id =
  1878. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGESENDRECEIVE);
  1879. message_source_set (&req_exec_msg_messagesendreceive.source, conn);
  1880. memcpy (&req_exec_msg_messagesendreceive.queue_name,
  1881. &req_lib_msg_messagesendreceive->queueName, sizeof (SaNameT));
  1882. iovec.iov_base = (char *)&req_exec_msg_messagesendreceive;
  1883. iovec.iov_len = sizeof (req_exec_msg_messagesendreceive);
  1884. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1885. TOTEMPG_AGREED) == 0);
  1886. }
  1887. static void message_handler_req_lib_msg_messagereply (
  1888. void *conn,
  1889. void *msg)
  1890. {
  1891. struct req_lib_msg_messagereply *req_lib_msg_messagereply =
  1892. (struct req_lib_msg_messagereply *)msg;
  1893. struct req_exec_msg_messagereply req_exec_msg_messagereply;
  1894. struct iovec iovec;
  1895. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageReply %s\n",
  1896. getSaNameT (&req_lib_msg_messagereply->queueName));
  1897. req_exec_msg_messagereply.header.size =
  1898. sizeof (struct req_exec_msg_messagereply);
  1899. req_exec_msg_messagereply.header.id =
  1900. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGEREPLY);
  1901. req_exec_msg_messagereply.async_call = 0;
  1902. message_source_set (&req_exec_msg_messagereply.source, conn);
  1903. memcpy (&req_exec_msg_messagereply.queue_name,
  1904. &req_lib_msg_messagereply->queueName, sizeof (SaNameT));
  1905. iovec.iov_base = (char *)&req_exec_msg_messagereply;
  1906. iovec.iov_len = sizeof (req_exec_msg_messagereply);
  1907. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1908. TOTEMPG_AGREED) == 0);
  1909. }
  1910. static void message_handler_req_lib_msg_messagereplyasync (
  1911. void *conn,
  1912. void *msg)
  1913. {
  1914. struct req_lib_msg_messagereply *req_lib_msg_messagereply =
  1915. (struct req_lib_msg_messagereply *)msg;
  1916. struct req_exec_msg_messagereply req_exec_msg_messagereply;
  1917. struct iovec iovec;
  1918. log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageReplyAsync %s\n",
  1919. getSaNameT (&req_lib_msg_messagereply->queueName));
  1920. req_exec_msg_messagereply.header.size =
  1921. sizeof (struct req_exec_msg_messagereply);
  1922. req_exec_msg_messagereply.header.id =
  1923. SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGEREPLY);
  1924. req_exec_msg_messagereply.async_call = 1;
  1925. message_source_set (&req_exec_msg_messagereply.source, conn);
  1926. memcpy (&req_exec_msg_messagereply.queue_name,
  1927. &req_lib_msg_messagereply->queueName, sizeof (SaNameT));
  1928. iovec.iov_base = (char *)&req_exec_msg_messagereply;
  1929. iovec.iov_len = sizeof (req_exec_msg_messagereply);
  1930. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
  1931. TOTEMPG_AGREED) == 0);
  1932. }