msg.c 69 KB

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