| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347 |
- /*
- * Copyright (c) 2005-2006 MontaVista Software, Inc.
- * Copyright (c) 2006 Red Hat, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake@redhat.com)
- *
- * This software licensed under BSD license, the text of which follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the MontaVista Software, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
- #include <sys/types.h>
- #include <sys/uio.h>
- #include <sys/socket.h>
- #include <sys/un.h>
- #include <sys/time.h>
- #include <netinet/in.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <errno.h>
- #include <signal.h>
- #include <arpa/inet.h>
- #include "../include/saAis.h"
- #include "../include/saMsg.h"
- #include "../include/ipc_msg.h"
- #include "../include/list.h"
- #include "../include/queue.h"
- #include "../lcr/lcr_comp.h"
- #include "objdb.h"
- #include "totem.h"
- #include "service.h"
- #include "mempool.h"
- #include "util.h"
- #include "main.h"
- #include "flow.h"
- #include "tlist.h"
- #include "ipc.h"
- #include "totempg.h"
- #include "logsys.h"
- LOGSYS_DECLARE_SUBSYS ("MSG", LOG_INFO);
- enum msg_exec_message_req_types {
- MESSAGE_REQ_EXEC_MSG_QUEUEOPEN = 0,
- MESSAGE_REQ_EXEC_MSG_QUEUECLOSE = 1,
- MESSAGE_REQ_EXEC_MSG_QUEUESTATUSGET = 2,
- MESSAGE_REQ_EXEC_MSG_QUEUEUNLINK = 3,
- MESSAGE_REQ_EXEC_MSG_QUEUEGROUPCREATE = 4,
- MESSAGE_REQ_EXEC_MSG_QUEUEGROUPINSERT = 5,
- MESSAGE_REQ_EXEC_MSG_QUEUEGROUPREMOVE = 6,
- MESSAGE_REQ_EXEC_MSG_QUEUEGROUPDELETE = 7,
- MESSAGE_REQ_EXEC_MSG_QUEUEGROUPTRACK = 8,
- MESSAGE_REQ_EXEC_MSG_QUEUEGROUPTRACKSTOP = 9,
- MESSAGE_REQ_EXEC_MSG_MESSAGESEND = 10,
- MESSAGE_REQ_EXEC_MSG_MESSAGEGET = 11,
- MESSAGE_REQ_EXEC_MSG_MESSAGECANCEL = 12,
- MESSAGE_REQ_EXEC_MSG_MESSAGESENDRECEIVE = 13,
- MESSAGE_REQ_EXEC_MSG_MESSAGEREPLY = 14
- };
- struct message_entry {
- SaTimeT time;
- SaMsgMessageT message;
- struct list_head list;
- };
- struct message_queue {
- SaNameT name;
- int refcount;
- struct list_head list;
- struct list_head message_list_head;
- };
- struct queue_group {
- SaNameT name;
- SaUint8T track_flags;
- SaMsgQueueGroupPolicyT policy;
- struct list_head list;
- struct list_head message_queue_head;
- };
- struct queue_group_entry {
- SaMsgQueueGroupChangesT change;
- struct message_queue *message_queue;
- struct list_head list;
- };
- /*
- struct queue_cleanup {
- struct message_queue *queue;
- SaMsgResourceHandleT queue_handle;
- struct list_head queue_lock_list_head;
- struct list_head list;
- };
- */
- DECLARE_LIST_INIT(queue_list_head);
- DECLARE_LIST_INIT(queue_group_list_head);
- static int msg_exec_init_fn (struct objdb_iface_ver0 *objdb);
- static int msg_lib_exit_fn (void *conn);
- static int msg_lib_init_fn (void *conn);
- static void message_handler_req_exec_msg_queueopen (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_queueclose (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_queuestatusget (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_queueunlink (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_queuegroupcreate (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_queuegroupinsert (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_queuegroupremove (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_queuegroupdelete (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_queuegrouptrack (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_queuegrouptrackstop (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_messagesend (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_messageget (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_messagecancel (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_messagesendreceive (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_msg_messagereply (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_lib_msg_queueopen (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_queueopenasync (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_queueclose (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_queuestatusget (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_queueunlink (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_queuegroupcreate (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_queuegroupinsert (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_queuegroupremove (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_queuegroupdelete (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_queuegrouptrack (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_queuegrouptrackstop (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_messagesend (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_messagesendasync (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_messageget (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_messagecancel (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_messagesendreceive (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_messagereply (
- void *conn,
- void *msg);
- static void message_handler_req_lib_msg_messagereplyasync (
- void *conn,
- void *msg);
- #ifdef TODO
- static void msg_sync_init (void);
- #endif /* TODO */
- static void msg_sync_activate (void);
- static int msg_sync_process (void);
- static void msg_sync_abort(void);
- void queue_release (struct message_queue *queue);
- static void msg_confchg_fn (
- enum totem_configuration_type configuration_type,
- unsigned int *member_list, int member_list_entries,
- unsigned int *left_list, int left_list_entries,
- unsigned int *joined_list, int joined_list_entries,
- struct memb_ring_id *ring_id);
- struct msg_pd {
- struct list_head queue_list;
- struct list_head queue_cleanup_list;
- };
- /*
- * Executive Handler Definition
- */
- struct openais_lib_handler msg_lib_service[] =
- {
- { /* 0 */
- .lib_handler_fn = message_handler_req_lib_msg_queueopen,
- .response_size = sizeof (struct res_lib_msg_queueopen),
- .response_id = MESSAGE_RES_MSG_QUEUEOPEN,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 1 */
- .lib_handler_fn = message_handler_req_lib_msg_queueopenasync,
- .response_size = sizeof (struct res_lib_msg_queueopenasync),
- .response_id = MESSAGE_RES_MSG_QUEUEOPENASYNC,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 2 */
- .lib_handler_fn = message_handler_req_lib_msg_queueclose,
- .response_size = sizeof (struct res_lib_msg_queueclose),
- .response_id = MESSAGE_RES_MSG_QUEUECLOSE,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 3 */
- .lib_handler_fn = message_handler_req_lib_msg_queuestatusget,
- .response_size = sizeof (struct res_lib_msg_queuestatusget),
- .response_id = MESSAGE_RES_MSG_QUEUESTATUSGET,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 4 */
- .lib_handler_fn = message_handler_req_lib_msg_queueunlink,
- .response_size = sizeof (struct res_lib_msg_queueunlink),
- .response_id = MESSAGE_RES_MSG_QUEUEUNLINK,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 5 */
- .lib_handler_fn = message_handler_req_lib_msg_queuegroupcreate,
- .response_size = sizeof (struct res_lib_msg_queuegroupcreate),
- .response_id = MESSAGE_RES_MSG_QUEUEGROUPCREATE,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 6 */
- .lib_handler_fn = message_handler_req_lib_msg_queuegroupinsert,
- .response_size = sizeof (struct res_lib_msg_queuegroupinsert),
- .response_id = MESSAGE_RES_MSG_QUEUEGROUPINSERT,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 7 */
- .lib_handler_fn = message_handler_req_lib_msg_queuegroupremove,
- .response_size = sizeof (struct res_lib_msg_queuegroupremove),
- .response_id = MESSAGE_RES_MSG_QUEUEGROUPREMOVE,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 8 */
- .lib_handler_fn = message_handler_req_lib_msg_queuegroupdelete,
- .response_size = sizeof (struct res_lib_msg_queuegroupdelete),
- .response_id = MESSAGE_RES_MSG_QUEUEGROUPDELETE,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 9 */
- .lib_handler_fn = message_handler_req_lib_msg_queuegrouptrack,
- .response_size = sizeof (struct res_lib_msg_queuegrouptrack),
- .response_id = MESSAGE_RES_MSG_QUEUEGROUPTRACK,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 10 */
- .lib_handler_fn = message_handler_req_lib_msg_queuegrouptrackstop,
- .response_size = sizeof (struct res_lib_msg_queuegrouptrackstop),
- .response_id = MESSAGE_RES_MSG_QUEUEGROUPTRACKSTOP,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 11 */
- .lib_handler_fn = message_handler_req_lib_msg_messagesend,
- .response_size = sizeof (struct res_lib_msg_messagesend),
- .response_id = MESSAGE_RES_MSG_MESSAGESEND,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 12 */
- .lib_handler_fn = message_handler_req_lib_msg_messagesendasync,
- .response_size = sizeof (struct res_lib_msg_messagesendasync),
- .response_id = MESSAGE_RES_MSG_MESSAGESENDASYNC,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 13 */
- .lib_handler_fn = message_handler_req_lib_msg_messageget,
- .response_size = sizeof (struct res_lib_msg_messageget),
- .response_id = MESSAGE_RES_MSG_MESSAGEGET,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 14 */
- .lib_handler_fn = message_handler_req_lib_msg_messagecancel,
- .response_size = sizeof (struct res_lib_msg_messagecancel),
- .response_id = MESSAGE_RES_MSG_MESSAGECANCEL,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 15 */
- .lib_handler_fn = message_handler_req_lib_msg_messagesendreceive,
- .response_size = sizeof (struct res_lib_msg_messagesendreceive),
- .response_id = MESSAGE_RES_MSG_MESSAGESENDRECEIVE,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 16 */
- .lib_handler_fn = message_handler_req_lib_msg_messagereply,
- .response_size = sizeof (struct res_lib_msg_messagereply),
- .response_id = MESSAGE_RES_MSG_MESSAGEREPLY,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 17 */
- .lib_handler_fn = message_handler_req_lib_msg_messagereplyasync,
- .response_size = sizeof (struct res_lib_msg_messagereplyasync),
- .response_id = MESSAGE_RES_MSG_MESSAGEREPLYASYNC,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- };
- static struct openais_exec_handler msg_exec_service[] = {
- {
- .exec_handler_fn = message_handler_req_exec_msg_queueopen,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_queueclose,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_queuestatusget,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_queueunlink,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_queuegroupcreate,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_queuegroupinsert,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_queuegroupremove,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_queuegroupdelete,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_queuegrouptrack,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_queuegrouptrackstop,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_messagesend,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_messageget,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_messagecancel,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_messagesendreceive,
- },
- {
- .exec_handler_fn = message_handler_req_exec_msg_messagereply
- }
- };
- struct openais_service_handler msg_service_handler = {
- .name = "openais message service B.01.01",
- .id = MSG_SERVICE,
- .private_data_size = sizeof (struct msg_pd),
- .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED,
- .lib_init_fn = msg_lib_init_fn,
- .lib_exit_fn = msg_lib_exit_fn,
- .lib_service = msg_lib_service,
- .lib_service_count = sizeof (msg_lib_service) / sizeof (struct openais_lib_handler),
- .exec_init_fn = msg_exec_init_fn,
- .exec_service = msg_exec_service,
- .exec_service_count = sizeof (msg_exec_service) / sizeof (struct openais_exec_handler),
- .confchg_fn = msg_confchg_fn,
- .exec_dump_fn = NULL,
- .sync_init = NULL, // TODO msg_sync_init,
- .sync_process = msg_sync_process,
- .sync_activate = msg_sync_activate,
- .sync_abort = msg_sync_abort
- };
- static struct openais_service_handler *msg_get_handler_ver0 (void);
- static struct openais_service_handler_iface_ver0 msg_service_handler_iface = {
- .openais_get_service_handler_ver0 = msg_get_handler_ver0
- };
- static struct lcr_iface openais_msg_ver0[1] = {
- {
- .name = "openais_msg",
- .version = 0,
- .versions_replace = 0,
- .versions_replace_count = 0,
- .dependencies = 0,
- .dependency_count = 0,
- .constructor = NULL,
- .destructor = NULL,
- .interfaces = NULL
- }
- };
- static struct lcr_comp msg_comp_ver0 = {
- .iface_count = 1,
- .ifaces = openais_msg_ver0
- };
- static struct openais_service_handler *msg_get_handler_ver0 (void)
- {
- return (&msg_service_handler);
- }
- __attribute__ ((constructor)) static void register_this_component (void) {
- lcr_interfaces_set (&openais_msg_ver0[0], &msg_service_handler_iface);
- lcr_component_register (&msg_comp_ver0);
- }
- /*
- * All data types used for executive messages
- */
- struct req_exec_msg_queueopen {
- mar_req_header_t header;
- mar_message_source_t source;
- int async_call;
- SaNameT queue_name;
- SaInvocationT invocation;
- SaMsgQueueHandleT queue_handle;
- SaMsgQueueCreationAttributesT creation_attributes;
- SaMsgQueueOpenFlagsT openFlags;
- SaTimeT timeout;
- };
- struct req_exec_msg_queueclose {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT queue_name;
- };
- struct req_exec_msg_queuestatusget {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT queue_name;
- };
- struct req_exec_msg_queueunlink {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT queue_name;
- };
- struct req_exec_msg_queuegroupcreate {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT queue_group_name;
- SaMsgQueueGroupPolicyT policy;
- };
- struct req_exec_msg_queuegroupinsert {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT queue_name;
- SaNameT queue_group_name;
- };
- struct req_exec_msg_queuegroupremove {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT queue_name;
- SaNameT queue_group_name;
- };
- struct req_exec_msg_queuegroupdelete {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT queue_group_name;
- };
- struct req_exec_msg_queuegrouptrack {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT queue_group_name;
- SaUint8T track_flags;
- SaUint8T buffer_flag;
- };
- struct req_exec_msg_queuegrouptrackstop {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT queue_group_name;
- };
- struct req_exec_msg_messagesend {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT destination;
- SaTimeT timeout;
- SaMsgMessageT message;
- SaInvocationT invocation;
- SaMsgAckFlagsT ack_flags;
- int async_call;
- };
- struct req_exec_msg_messageget {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT queue_name;
- };
- struct req_exec_msg_messagecancel {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT queue_name;
- };
- struct req_exec_msg_messagesendreceive {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT queue_name;
- };
- struct req_exec_msg_messagereply {
- mar_req_header_t header;
- mar_message_source_t source;
- SaNameT queue_name;
- int async_call;
- };
- #ifdef TODO
- static void msg_sync_init (void)
- {
- return;
- }
- #endif /* TODO */
- static int msg_sync_process (void)
- {
- return (0);
- }
- static void msg_sync_activate (void)
- {
- return;
- }
- static void msg_sync_abort (void)
- {
- return;
- }
- static void msg_confchg_fn (
- enum totem_configuration_type configuration_type,
- unsigned int *member_list, int member_list_entries,
- unsigned int *left_list, int left_list_entries,
- unsigned int *joined_list, int joined_list_entries,
- struct memb_ring_id *ring_id)
- {
- return;
- }
- static void print_message_list (struct message_queue *queue)
- {
- struct list_head *list;
- struct message_entry *entry;
- for (list = queue->message_list_head.next;
- list != &queue->message_list_head;
- list = list->next)
- {
- entry = list_entry (list, struct message_entry, list);
- log_printf (LOG_LEVEL_NOTICE, "[DEBUG]: print_message_list (%s) (%llu)\n",
- (char *)(entry->message.data),
- (unsigned long long)(entry->time));
- }
- }
- static void print_queue_group_list (struct queue_group *group)
- {
- struct list_head *list;
- struct queue_group_entry *entry;
- for (list = group->message_queue_head.next;
- list != &group->message_queue_head;
- list = list->next)
- {
- entry = list_entry (list, struct queue_group_entry, list);
- log_printf (LOG_LEVEL_NOTICE, "[DEBUG]: print_queue_group_list (%s) (%u)\n",
- (char *)(entry->message_queue->name.value),
- (unsigned int)(entry->change));
- }
- }
- static struct message_queue *queue_find (SaNameT *name)
- {
- struct list_head *list;
- struct message_queue *queue;
- for (list = queue_list_head.next;
- list != &queue_list_head;
- list = list->next)
- {
- queue = list_entry (list, struct message_queue, list);
- if (name_match (name, &queue->name)) {
- return (queue);
- }
- }
- return (0);
- }
- static struct queue_group *queue_group_find (SaNameT *name)
- {
- struct list_head *list;
- struct queue_group *group;
- for (list = queue_group_list_head.next;
- list != &queue_group_list_head;
- list = list->next)
- {
- group = list_entry (list, struct queue_group, list);
- if (name_match (name, &group->name)) {
- return (group);
- }
- }
- return (0);
- }
- static struct queue_group_entry *queue_group_entry_find (struct queue_group *group, struct message_queue *queue)
- {
- struct list_head *list;
- struct queue_group_entry *entry;
- for (list = group->message_queue_head.next;
- list != &group->message_queue_head;
- list = list->next)
- {
- entry = list_entry (list, struct queue_group_entry, list);
- if (entry->message_queue == queue) {
- return (entry);
- }
- }
- return (0);
- }
- static unsigned int queue_group_member_count (struct queue_group *group)
- {
- struct list_head *list;
- unsigned int count = 0;
- for (list = group->message_queue_head.next;
- list != &group->message_queue_head;
- list = list->next)
- {
- count++;
- }
- return (count);
- }
- static unsigned int queue_group_change_count (struct queue_group *group)
- {
- struct list_head *list;
- struct queue_group_entry *entry;
- unsigned int count = 0;
- for (list = group->message_queue_head.next;
- list != &group->message_queue_head;
- list = list->next)
- {
- entry = list_entry (list, struct queue_group_entry, list);
- if (entry->change != SA_MSG_QUEUE_GROUP_NO_CHANGE) {
- count++;
- }
- }
- return (count);
- }
- static unsigned int queue_group_track (
- struct queue_group *group,
- unsigned int flags,
- void *buffer)
- {
- struct list_head *list;
- struct queue_group_entry *entry;
- unsigned int i = 0;
- SaMsgQueueGroupNotificationT *notification =
- (SaMsgQueueGroupNotificationT *) buffer;
- switch (flags) {
- case SA_TRACK_CURRENT:
- case SA_TRACK_CHANGES:
- for (list = group->message_queue_head.next;
- list != &group->message_queue_head;
- list = list->next)
- {
- entry = list_entry (list, struct queue_group_entry, list);
- memcpy (¬ification[i].member.queueName,
- &entry->message_queue->name,
- sizeof (SaNameT));
- notification[i].change = entry->change;
- i++;
- }
- break;
- case SA_TRACK_CHANGES_ONLY:
- for (list = group->message_queue_head.next;
- list != &group->message_queue_head;
- list = list->next)
- {
- entry = list_entry (list, struct queue_group_entry, list);
- if (entry->change != SA_MSG_QUEUE_GROUP_NO_CHANGE) {
- memcpy (¬ification[i].member.queueName,
- &entry->message_queue->name,
- sizeof (SaNameT));
- notification[i].change = entry->change;
- i++;
- }
- }
- break;
- default:
- break;
- }
- return (i);
- }
- static int msg_exec_init_fn (struct objdb_iface_ver0 *objdb)
- {
- /*
- * Initialize the saved ring ID.
- */
- /* saved_ring_id.seq = 0; */
- /* saved_ring_id.rep.s_addr = this_ip->sin_addr.s_addr; */
- return (0);
- }
- static int msg_lib_exit_fn (void *conn)
- {
- /*
- * struct msg_pd *msg_pd = (struct msg_pd *)openais_conn_private_data_get (conn);
- */
- #ifdef COMPILE_OUT
- struct queue_cleanup *queue_cleanup;
- struct list_head *list;
-
- /*
- * close all queues opened on this fd
- */
- list = conn_info->conn_info_partner->ais_ci.u.libmsg_ci.queue_cleanup_list.next;
- while (!list_empty(&conn_info->conn_info_partner->ais_ci.u.libmsg_ci.queue_cleanup_list)) {
-
- queue_cleanup = list_entry (list, struct queue_cleanup, list);
- if (queue_cleanup->queue->name.length > 0) {
- msg_queue_cleanup_lock_remove (queue_cleanup);
- msg_queue_close (queue_cleanup->queue);
- }
- list_del (&queue_cleanup->list);
- free (queue_cleanup);
-
- list = conn_info->conn_info_partner->ais_ci.u.libmsg_ci.queue_cleanup_list.next;
- }
- #endif /* COMPILE_OUT */
- return (0);
- }
- static int msg_lib_init_fn (void *conn)
- {
- struct msg_pd *msg_pd = (struct msg_pd *)openais_conn_private_data_get (conn);
- list_init (&msg_pd->queue_list);
- list_init (&msg_pd->queue_cleanup_list);
- return (0);
- }
- static void message_handler_req_exec_msg_queueopen (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_msg_queueopen *req_exec_msg_queueopen =
- (struct req_exec_msg_queueopen *)message;
- struct res_lib_msg_queueopen res_lib_msg_queueopen;
- struct res_lib_msg_queueopenasync res_lib_msg_queueopenasync;
- struct message_queue *queue;
- /* struct queue_cleanup *queue_cleanup; */
- SaAisErrorT error = SA_AIS_OK;
- log_printf (LOG_LEVEL_NOTICE, "EXEC request: saMsgQueueOpen %s\n",
- getSaNameT (&req_exec_msg_queueopen->queue_name));
-
- queue = queue_find (&req_exec_msg_queueopen->queue_name);
- /*
- * If queue doesn't exist, create one
- */
- if (queue == 0) {
- if ((req_exec_msg_queueopen->openFlags & SA_MSG_QUEUE_CREATE) == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- queue = malloc (sizeof (struct message_queue));
- if (queue == 0) {
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- memset (queue, 0, sizeof (struct message_queue));
- memcpy (&queue->name,
- &req_exec_msg_queueopen->queue_name,
- sizeof (SaNameT));
- list_init (&queue->list);
- list_init (&queue->message_list_head);
- list_add (&queue->list, &queue_list_head);
- queue->refcount = 0;
- }
- queue->refcount += 1;
- #ifdef COMPILE_OUT
- /*
- * Setup connection information and mark queue as referenced
- */
- queue_cleanup = malloc (sizeof (struct queue_cleanup));
- if (queue_cleanup == 0) {
- free (queue);
- error = SA_AIS_ERR_NO_MEMORY;
- } else {
- list_init (&queue_cleanup->list);
- list_init (&queue_cleanup->queue_lock_list_head);
- queue_cleanup->queue = queue;
- queue_cleanup->queue_handle = req_exec_msg_queueopen->queue_handle;
- list_add (
- &queue_cleanup->list,
- &req_exec_msg_queueopen->source.conn_info->ais_ci.u.libmsg_ci.queue_cleanup_list);
- }
- queue->refcount += 1;
- #endif /* COMPILE_OUT */
-
- /*
- * Send error result to MSG library
- */
- error_exit:
- /*
- * If this node was the source of the message, respond to this node
- */
- if (message_source_is_local (&req_exec_msg_queueopen->source)) {
- /*
- * If its an async call respond with the invocation and handle
- */
- if (req_exec_msg_queueopen->async_call)
- {
- res_lib_msg_queueopenasync.header.size =
- sizeof (struct res_lib_msg_queueopenasync);
- res_lib_msg_queueopenasync.header.id =
- MESSAGE_RES_MSG_QUEUEOPENASYNC;
- res_lib_msg_queueopenasync.header.error = error;
- res_lib_msg_queueopenasync.invocation =
- req_exec_msg_queueopen->invocation;
- res_lib_msg_queueopenasync.queueHandle =
- req_exec_msg_queueopen->queue_handle;
- memcpy (&res_lib_msg_queueopenasync.source,
- &req_exec_msg_queueopen->source,
- sizeof (mar_message_source_t));
- openais_conn_send_response (
- req_exec_msg_queueopen->source.conn,
- &res_lib_msg_queueopenasync,
- sizeof (struct res_lib_msg_queueopenasync));
- openais_conn_send_response (
- openais_conn_partner_get (req_exec_msg_queueopen->source.conn),
- &res_lib_msg_queueopenasync,
- sizeof (struct res_lib_msg_queueopenasync));
- } else {
- /*
- * otherwise respond with the normal queueopen response
- */
- res_lib_msg_queueopen.header.size =
- sizeof (struct res_lib_msg_queueopen);
- res_lib_msg_queueopen.header.id =
- MESSAGE_RES_MSG_QUEUEOPEN;
- res_lib_msg_queueopen.header.error = error;
- res_lib_msg_queueopen.queueHandle =
- req_exec_msg_queueopen->queue_handle;
- memcpy (&res_lib_msg_queueopen.source,
- &req_exec_msg_queueopen->source,
- sizeof (mar_message_source_t));
- openais_conn_send_response (
- req_exec_msg_queueopen->source.conn,
- &res_lib_msg_queueopen,
- sizeof (struct res_lib_msg_queueopen));
- }
- }
- }
- static void message_handler_req_exec_msg_queueclose (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_msg_queueclose *req_exec_msg_queueclose =
- (struct req_exec_msg_queueclose *)message;
- struct res_lib_msg_queueclose res_lib_msg_queueclose;
- struct message_queue *queue = 0;
- SaAisErrorT error = SA_AIS_OK;
- log_printf (LOG_LEVEL_NOTICE, "EXEC request: saMsgQueueClose %s\n",
- getSaNameT (&req_exec_msg_queueclose->queue_name));
- queue = queue_find (&req_exec_msg_queueclose->queue_name);
- if (queue == 0) {
- goto error_exit;
- }
-
- queue->refcount -= 1;
- if (queue->refcount == 0) {
- /* free queue */
- }
- error_exit:
- if (message_source_is_local(&req_exec_msg_queueclose->source))
- {
- /* TODO */
- /*
- * msg_queue_cleanup_remove (
- * req_exec_msg_queueclose->source.conn_info,
- * req_exec_msg_queueclose->queue_handle);
- */
- res_lib_msg_queueclose.header.size =
- sizeof (struct res_lib_msg_queueclose);
- res_lib_msg_queueclose.header.id =
- MESSAGE_RES_MSG_QUEUECLOSE;
- res_lib_msg_queueclose.header.error = error;
- openais_conn_send_response (
- req_exec_msg_queueclose->source.conn,
- &res_lib_msg_queueclose,
- sizeof (struct res_lib_msg_queueclose));
- }
- }
- static void message_handler_req_exec_msg_queuestatusget (
- void *message,
- unsigned int nodeid)
- {
- #if 0
- struct req_exec_msg_queuestatusget *req_exec_msg_queuestatusget =
- (struct req_exec_msg_queuestatusget *)message;
- struct res_lib_msg_queuestatusget res_lib_msg_queuestatusget;
- #endif
- }
- static void message_handler_req_exec_msg_queueunlink (
- void *message,
- unsigned int nodeid)
- {
- #if 0
- struct req_exec_msg_queueunlink *req_exec_msg_queueunlink =
- (struct req_exec_msg_queueunlink *)message;
- struct res_lib_msg_queueunlink res_lib_msg_queueunlink;
- #endif
- }
- static void message_handler_req_exec_msg_queuegroupcreate (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_msg_queuegroupcreate *req_exec_msg_queuegroupcreate =
- (struct req_exec_msg_queuegroupcreate *)message;
- struct res_lib_msg_queuegroupcreate res_lib_msg_queuegroupcreate;
- struct queue_group *queue_group;
- SaAisErrorT error = SA_AIS_OK;
- queue_group = queue_group_find (&req_exec_msg_queuegroupcreate->queue_group_name);
- if (queue_group == 0) {
- queue_group = malloc (sizeof (struct queue_group));
- if (queue_group == 0) {
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- memset (queue_group, 0, sizeof (struct queue_group));
- memcpy (&queue_group->name,
- &req_exec_msg_queuegroupcreate->queue_group_name,
- sizeof (SaNameT));
- list_init (&queue_group->list);
- list_init (&queue_group->message_queue_head);
- list_add (&queue_group->list, &queue_group_list_head);
- } else {
- error = SA_AIS_ERR_EXIST;
- }
- error_exit:
- if (message_source_is_local(&req_exec_msg_queuegroupcreate->source)) {
- res_lib_msg_queuegroupcreate.header.size =
- sizeof (struct res_lib_msg_queuegroupcreate);
- res_lib_msg_queuegroupcreate.header.id =
- MESSAGE_RES_MSG_QUEUEGROUPCREATE;
- res_lib_msg_queuegroupcreate.header.error = error;
- openais_conn_send_response (
- req_exec_msg_queuegroupcreate->source.conn,
- &res_lib_msg_queuegroupcreate,
- sizeof (struct res_lib_msg_queuegroupcreate));
- }
- }
- static void message_handler_req_exec_msg_queuegroupinsert (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_msg_queuegroupinsert *req_exec_msg_queuegroupinsert =
- (struct req_exec_msg_queuegroupinsert *)message;
- struct res_lib_msg_queuegroupinsert res_lib_msg_queuegroupinsert;
- struct res_lib_msg_queuegrouptrack res_lib_msg_queuegrouptrack;
- struct message_queue *queue;
- struct queue_group *queue_group;
- struct queue_group_entry *queue_group_entry;
- SaMsgQueueGroupNotificationT *notification;
- SaAisErrorT error = SA_AIS_OK;
- SaAisErrorT error_cb = SA_AIS_OK;
- unsigned int change_count = 0;
- unsigned int member_count = 0;
- queue_group = queue_group_find (&req_exec_msg_queuegroupinsert->queue_group_name);
- if (queue_group == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- queue = queue_find (&req_exec_msg_queuegroupinsert->queue_name);
- if (queue == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- queue_group_entry = malloc (sizeof (struct queue_group_entry));
- if (queue_group_entry == 0) {
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- list_init (&queue_group_entry->list);
- list_add (&queue_group_entry->list, &queue_group->message_queue_head);
- list_add (&queue->list, &queue_list_head);
- queue_group_entry->message_queue = queue;
- queue_group_entry->change = SA_MSG_QUEUE_GROUP_ADDED;
- if (queue_group->track_flags & SA_TRACK_CHANGES) {
- member_count = queue_group_member_count (queue_group);
- change_count = queue_group_change_count (queue_group);
- notification = malloc (sizeof (SaMsgQueueGroupNotificationT) * member_count);
- if (notification == NULL) {
- error_cb = SA_AIS_ERR_NO_MEMORY;
- goto error_track;
- }
- memset (notification, 0, sizeof (SaMsgQueueGroupNotificationT) * member_count);
- res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems =
- queue_group_track (queue_group,
- SA_TRACK_CHANGES,
- (void *)(notification));
- }
- if (queue_group->track_flags & SA_TRACK_CHANGES_ONLY) {
- member_count = queue_group_member_count (queue_group);
- change_count = queue_group_change_count (queue_group);
- notification = malloc (sizeof (SaMsgQueueGroupNotificationT) * change_count);
- if (notification == NULL) {
- error_cb = SA_AIS_ERR_NO_MEMORY;
- goto error_track;
- }
- memset (notification, 0, sizeof (SaMsgQueueGroupNotificationT) * change_count);
- res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems =
- queue_group_track (queue_group,
- SA_TRACK_CHANGES_ONLY,
- (void *)(notification));
- }
- error_track:
- queue_group_entry->change = SA_MSG_QUEUE_GROUP_NO_CHANGE;
- error_exit:
- if (message_source_is_local(&req_exec_msg_queuegroupinsert->source)) {
- res_lib_msg_queuegroupinsert.header.size =
- sizeof (struct res_lib_msg_queuegroupinsert);
- res_lib_msg_queuegroupinsert.header.id =
- MESSAGE_RES_MSG_QUEUEGROUPINSERT;
- res_lib_msg_queuegroupinsert.header.error = error;
- openais_conn_send_response (
- req_exec_msg_queuegroupinsert->source.conn,
- &res_lib_msg_queuegroupinsert,
- sizeof (struct res_lib_msg_queuegroupinsert));
- /*
- * Track changes (callback) if tracking is enabled
- */
- if ((queue_group->track_flags & SA_TRACK_CHANGES) ||
- (queue_group->track_flags & SA_TRACK_CHANGES_ONLY))
- {
- res_lib_msg_queuegrouptrack.header.size =
- (sizeof (struct res_lib_msg_queuegrouptrack) +
- (sizeof (SaMsgQueueGroupNotificationT) *
- res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems));
- res_lib_msg_queuegrouptrack.header.id =
- MESSAGE_RES_MSG_QUEUEGROUPTRACK;
- res_lib_msg_queuegrouptrack.header.error = error_cb;
- res_lib_msg_queuegrouptrack.numberOfMembers = member_count;
- memcpy (&res_lib_msg_queuegrouptrack.queueGroupName,
- &req_exec_msg_queuegroupinsert->queue_group_name,
- sizeof (SaNameT));
- openais_conn_send_response (
- openais_conn_partner_get (req_exec_msg_queuegroupinsert->source.conn),
- &res_lib_msg_queuegrouptrack,
- sizeof (struct res_lib_msg_queuegrouptrack));
- openais_conn_send_response (
- openais_conn_partner_get (req_exec_msg_queuegroupinsert->source.conn),
- notification,
- (sizeof (SaMsgQueueGroupNotificationT) *
- res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems));
- }
- }
- }
- static void message_handler_req_exec_msg_queuegroupremove (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_msg_queuegroupremove *req_exec_msg_queuegroupremove =
- (struct req_exec_msg_queuegroupremove *)message;
- struct res_lib_msg_queuegroupremove res_lib_msg_queuegroupremove;
- struct res_lib_msg_queuegrouptrack res_lib_msg_queuegrouptrack;
- struct queue_group *queue_group;
- struct message_queue *queue;
- struct queue_group_entry *queue_group_entry;
- SaMsgQueueGroupNotificationT *notification;
- SaAisErrorT error = SA_AIS_OK;
- SaAisErrorT error_cb = SA_AIS_OK;
- unsigned int change_count = 0;
- unsigned int member_count = 0;
- queue_group = queue_group_find (&req_exec_msg_queuegroupremove->queue_group_name);
- if (queue_group == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- queue = queue_find (&req_exec_msg_queuegroupremove->queue_name);
- if (queue == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- queue_group_entry = queue_group_entry_find (queue_group, queue);
- if (queue_group_entry == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- queue_group_entry->change = SA_MSG_QUEUE_GROUP_REMOVED;
- if (queue_group->track_flags & SA_TRACK_CHANGES) {
- member_count = queue_group_member_count (queue_group);
- change_count = queue_group_change_count (queue_group);
- notification = malloc (sizeof (SaMsgQueueGroupNotificationT) * member_count);
- if (notification == NULL) {
- error_cb = SA_AIS_ERR_NO_MEMORY;
- goto error_track;
- }
- memset (notification, 0, (sizeof (SaMsgQueueGroupNotificationT) * member_count));
- res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems =
- queue_group_track (queue_group,
- SA_TRACK_CHANGES,
- (void *)(notification));
- }
- if (queue_group->track_flags & SA_TRACK_CHANGES_ONLY) {
- member_count = queue_group_member_count (queue_group);
- change_count = queue_group_change_count (queue_group);
- notification = malloc (sizeof (SaMsgQueueGroupNotificationT) * change_count);
- if (notification == NULL) {
- error_cb = SA_AIS_ERR_NO_MEMORY;
- goto error_track;
- }
- memset (notification, 0, (sizeof (SaMsgQueueGroupNotificationT) * change_count));
- res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems =
- queue_group_track (queue_group,
- SA_TRACK_CHANGES_ONLY,
- (void *)(notification));
- }
- error_track:
- queue_group_entry->change = SA_MSG_QUEUE_GROUP_NO_CHANGE;
- list_del (&queue_group_entry->list);
- error_exit:
- if (message_source_is_local(&req_exec_msg_queuegroupremove->source)) {
- res_lib_msg_queuegroupremove.header.size =
- sizeof (struct res_lib_msg_queuegroupremove);
- res_lib_msg_queuegroupremove.header.id =
- MESSAGE_RES_MSG_QUEUEGROUPREMOVE;
- res_lib_msg_queuegroupremove.header.error = error;
- openais_conn_send_response (
- req_exec_msg_queuegroupremove->source.conn,
- &res_lib_msg_queuegroupremove,
- sizeof (struct res_lib_msg_queuegroupremove));
- /*
- * Track changes (callback) if tracking is enabled
- */
- if ((queue_group->track_flags & SA_TRACK_CHANGES) ||
- (queue_group->track_flags & SA_TRACK_CHANGES_ONLY))
- {
- res_lib_msg_queuegrouptrack.header.size =
- (sizeof (struct res_lib_msg_queuegrouptrack) +
- (sizeof (SaMsgQueueGroupNotificationT) *
- res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems));
- res_lib_msg_queuegrouptrack.header.id =
- MESSAGE_RES_MSG_QUEUEGROUPTRACK;
- res_lib_msg_queuegrouptrack.header.error = error_cb;
- res_lib_msg_queuegrouptrack.numberOfMembers = member_count;
- memcpy (&res_lib_msg_queuegrouptrack.queueGroupName,
- &req_exec_msg_queuegroupremove->queue_group_name,
- sizeof (SaNameT));
- openais_conn_send_response (
- openais_conn_partner_get (req_exec_msg_queuegroupremove->source.conn),
- &res_lib_msg_queuegrouptrack,
- sizeof (struct res_lib_msg_queuegrouptrack));
- openais_conn_send_response (
- openais_conn_partner_get (req_exec_msg_queuegroupremove->source.conn),
- notification,
- (sizeof (SaMsgQueueGroupNotificationT) *
- res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems));
- }
- }
- }
- static void message_handler_req_exec_msg_queuegroupdelete (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_msg_queuegroupdelete *req_exec_msg_queuegroupdelete =
- (struct req_exec_msg_queuegroupdelete *)message;
- struct res_lib_msg_queuegroupdelete res_lib_msg_queuegroupdelete;
- struct queue_group *queue_group;
- SaAisErrorT error = SA_AIS_OK;
- queue_group = queue_group_find (&req_exec_msg_queuegroupdelete->queue_group_name);
- if (queue_group) {
- list_del (&queue_group->list);
- free (queue_group);
- } else {
- error = SA_AIS_ERR_NOT_EXIST;
- }
- if (message_source_is_local(&req_exec_msg_queuegroupdelete->source)) {
- res_lib_msg_queuegroupdelete.header.size =
- sizeof (struct res_lib_msg_queuegroupdelete);
- res_lib_msg_queuegroupdelete.header.id =
- MESSAGE_RES_MSG_QUEUEGROUPDELETE;
- res_lib_msg_queuegroupdelete.header.error = error;
- openais_conn_send_response (
- req_exec_msg_queuegroupdelete->source.conn,
- &res_lib_msg_queuegroupdelete,
- sizeof (struct res_lib_msg_queuegroupdelete));
- }
- }
- static void message_handler_req_exec_msg_queuegrouptrack (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_msg_queuegrouptrack *req_exec_msg_queuegrouptrack =
- (struct req_exec_msg_queuegrouptrack *)message;
- struct res_lib_msg_queuegrouptrack res_lib_msg_queuegrouptrack;
- struct queue_group *queue_group;
- SaAisErrorT error = SA_AIS_OK;
- unsigned int change_count = 0;
- unsigned int member_count = 0;
- SaMsgQueueGroupNotificationT *notification;
- queue_group = queue_group_find (&req_exec_msg_queuegrouptrack->queue_group_name);
- if (queue_group == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- member_count = queue_group_member_count (queue_group);
- change_count = queue_group_change_count (queue_group);
- if (req_exec_msg_queuegrouptrack->track_flags & SA_TRACK_CURRENT) {
- /* DEBUG */
- log_printf (LOG_LEVEL_NOTICE, "[DEBUG]: SA_TRACK_CURRENT\n");
- notification = malloc (sizeof (SaMsgQueueGroupNotificationT) * member_count);
- if (notification == NULL) {
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- memset (notification, 0, sizeof (SaMsgQueueGroupNotificationT) * member_count);
- res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems =
- queue_group_track (queue_group, SA_TRACK_CURRENT, (void *)(notification));
- }
- if (req_exec_msg_queuegrouptrack->track_flags & SA_TRACK_CHANGES) {
- /* DEBUG */
- log_printf (LOG_LEVEL_NOTICE, "[DEBUG]: SA_TRACK_CHANGES\n");
- queue_group->track_flags = req_exec_msg_queuegrouptrack->track_flags;
- }
- if (req_exec_msg_queuegrouptrack->track_flags & SA_TRACK_CHANGES_ONLY) {
- /* DEBUG */
- log_printf (LOG_LEVEL_NOTICE, "[DEBUG]: SA_TRACK_CHANGES_ONLY\n");
- queue_group->track_flags = req_exec_msg_queuegrouptrack->track_flags;
- }
- error_exit:
- if (message_source_is_local(&req_exec_msg_queuegrouptrack->source)) {
- res_lib_msg_queuegrouptrack.header.size =
- sizeof (struct res_lib_msg_queuegrouptrack);
- res_lib_msg_queuegrouptrack.header.id =
- MESSAGE_RES_MSG_QUEUEGROUPTRACK;
- res_lib_msg_queuegrouptrack.header.error = error;
- res_lib_msg_queuegrouptrack.numberOfMembers = member_count;
- memcpy (&res_lib_msg_queuegrouptrack.queueGroupName,
- &req_exec_msg_queuegrouptrack->queue_group_name,
- sizeof (SaNameT));
- if (req_exec_msg_queuegrouptrack->track_flags & SA_TRACK_CURRENT) {
- if (req_exec_msg_queuegrouptrack->buffer_flag) {
- res_lib_msg_queuegrouptrack.header.size +=
- (sizeof (SaMsgQueueGroupNotificationT) *
- res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems);
- openais_conn_send_response (
- req_exec_msg_queuegrouptrack->source.conn,
- &res_lib_msg_queuegrouptrack,
- sizeof (struct res_lib_msg_queuegrouptrack));
- openais_conn_send_response (
- req_exec_msg_queuegrouptrack->source.conn,
- notification,
- (sizeof (SaMsgQueueGroupNotificationT) *
- res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems));
- } else {
- openais_conn_send_response (
- req_exec_msg_queuegrouptrack->source.conn,
- &res_lib_msg_queuegrouptrack,
- sizeof (struct res_lib_msg_queuegrouptrack));
- res_lib_msg_queuegrouptrack.header.size +=
- (sizeof (SaMsgQueueGroupNotificationT) *
- res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems);
- openais_conn_send_response (
- openais_conn_partner_get (req_exec_msg_queuegrouptrack->source.conn),
- &res_lib_msg_queuegrouptrack,
- sizeof (struct res_lib_msg_queuegrouptrack));
- openais_conn_send_response (
- openais_conn_partner_get (req_exec_msg_queuegrouptrack->source.conn),
- notification,
- (sizeof (SaMsgQueueGroupNotificationT) *
- res_lib_msg_queuegrouptrack.notificationBuffer.numberOfItems));
- }
- } else {
- openais_conn_send_response (
- req_exec_msg_queuegrouptrack->source.conn,
- &res_lib_msg_queuegrouptrack,
- sizeof (struct res_lib_msg_queuegrouptrack));
- }
- }
- }
- static void message_handler_req_exec_msg_queuegrouptrackstop (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_msg_queuegrouptrackstop *req_exec_msg_queuegrouptrackstop =
- (struct req_exec_msg_queuegrouptrackstop *)message;
- struct res_lib_msg_queuegrouptrackstop res_lib_msg_queuegrouptrackstop;
- struct queue_group *queue_group;
- SaAisErrorT error = SA_AIS_OK;
- queue_group = queue_group_find (&req_exec_msg_queuegrouptrackstop->queue_group_name);
- if (queue_group == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- if ((queue_group->track_flags != SA_TRACK_CHANGES) &&
- (queue_group->track_flags != SA_TRACK_CHANGES_ONLY)) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- queue_group->track_flags = 0;
- error_exit:
- if (message_source_is_local(&req_exec_msg_queuegrouptrackstop->source)) {
- res_lib_msg_queuegrouptrackstop.header.size =
- sizeof (struct res_lib_msg_queuegrouptrackstop);
- res_lib_msg_queuegrouptrackstop.header.id =
- MESSAGE_RES_MSG_QUEUEGROUPTRACKSTOP;
- res_lib_msg_queuegrouptrackstop.header.error = error;
- openais_conn_send_response (
- req_exec_msg_queuegrouptrackstop->source.conn,
- &res_lib_msg_queuegrouptrackstop,
- sizeof (struct res_lib_msg_queuegrouptrackstop));
- }
- }
- static void message_handler_req_exec_msg_messagesend (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_msg_messagesend *req_exec_msg_messagesend =
- (struct req_exec_msg_messagesend *)message;
- struct res_lib_msg_messagesend res_lib_msg_messagesend;
- struct res_lib_msg_messagesendasync res_lib_msg_messagesendasync;
- struct message_queue *queue;
- struct message_entry *entry;
- SaAisErrorT error = SA_AIS_OK;
- char *data = ((char *)(req_exec_msg_messagesend) +
- sizeof (struct req_exec_msg_messagesend));
- log_printf (LOG_LEVEL_NOTICE, "EXEC request: saMsgMessageSend %s\n",
- getSaNameT (&req_exec_msg_messagesend->destination));
- queue = queue_find (&req_exec_msg_messagesend->destination);
- if (queue == NULL) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- entry = malloc (sizeof (struct message_entry));
- if (entry == NULL) {
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- memset (entry, 0, sizeof (struct message_entry));
- memcpy (&entry->message, &req_exec_msg_messagesend->message,
- sizeof (SaMsgMessageT));
- entry->message.data = malloc (entry->message.size);
- if (entry->message.data == NULL) {
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- memset (entry->message.data, 0, entry->message.size);
- memcpy (entry->message.data, (void *)(data), entry->message.size);
- entry->time = clust_time_now();
- list_add_tail (&entry->list, &queue->message_list_head);
- error_exit:
- if (message_source_is_local(&req_exec_msg_messagesend->source)) {
- if (req_exec_msg_messagesend->async_call) {
- res_lib_msg_messagesendasync.header.size =
- sizeof (struct res_lib_msg_messagesendasync);
- res_lib_msg_messagesendasync.header.id =
- MESSAGE_RES_MSG_MESSAGESENDASYNC;
- res_lib_msg_messagesendasync.header.error = error;
- res_lib_msg_messagesendasync.invocation =
- req_exec_msg_messagesend->invocation;
- memcpy (&res_lib_msg_messagesendasync.source,
- &req_exec_msg_messagesend->source,
- sizeof (mar_message_source_t));
- openais_conn_send_response (
- req_exec_msg_messagesend->source.conn,
- &res_lib_msg_messagesendasync,
- sizeof (struct res_lib_msg_messagesendasync));
- openais_conn_send_response (
- openais_conn_partner_get (req_exec_msg_messagesend->source.conn),
- &res_lib_msg_messagesendasync,
- sizeof (struct res_lib_msg_messagesendasync));
- } else {
- res_lib_msg_messagesend.header.size =
- sizeof (struct res_lib_msg_messagesend);
- res_lib_msg_messagesend.header.id =
- MESSAGE_RES_MSG_MESSAGESEND;
- res_lib_msg_messagesend.header.error = error;
- memcpy (&res_lib_msg_messagesend.source,
- &req_exec_msg_messagesend->source,
- sizeof (mar_message_source_t));
- openais_conn_send_response (
- req_exec_msg_messagesend->source.conn,
- &res_lib_msg_messagesend,
- sizeof (struct res_lib_msg_messagesend));
- }
- }
- }
- static void message_handler_req_exec_msg_messageget (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_msg_messageget *req_exec_msg_messageget =
- (struct req_exec_msg_messageget *)message;
- struct res_lib_msg_messageget res_lib_msg_messageget;
- struct message_queue *queue;
- struct message_entry *entry;
- SaAisErrorT error = SA_AIS_OK;
- log_printf (LOG_LEVEL_NOTICE, "EXEC request: saMsgMessageGet %s\n",
- getSaNameT (&req_exec_msg_messageget->queue_name));
- queue = queue_find (&req_exec_msg_messageget->queue_name);
- if (queue == NULL) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- if (list_empty (queue->message_list_head.next)) {
- error = SA_AIS_ERR_TIMEOUT; /* FIX ME */
- goto error_exit;
- }
- entry = list_entry (queue->message_list_head.next, struct message_entry, list);
- if (entry == NULL) {
- error = SA_AIS_ERR_LIBRARY; /* FIX ME */
- goto error_exit;
- }
- list_del (queue->message_list_head.next);
- error_exit:
- if (message_source_is_local(&req_exec_msg_messageget->source)) {
- res_lib_msg_messageget.header.size =
- sizeof (struct res_lib_msg_messageget);
- res_lib_msg_messageget.header.id =
- MESSAGE_RES_MSG_MESSAGEGET;
- res_lib_msg_messageget.header.error = error;
- memcpy (&res_lib_msg_messageget.message, &entry->message,
- sizeof (SaMsgMessageT));
- memcpy (&res_lib_msg_messageget.source,
- &req_exec_msg_messageget->source,
- sizeof (mar_message_source_t));
- openais_conn_send_response (
- req_exec_msg_messageget->source.conn,
- &res_lib_msg_messageget,
- sizeof (struct res_lib_msg_messageget));
- openais_conn_send_response (
- req_exec_msg_messageget->source.conn,
- res_lib_msg_messageget.message.data,
- res_lib_msg_messageget.message.size);
- }
- }
- static void message_handler_req_exec_msg_messagecancel (
- void *message,
- unsigned int nodeid)
- {
- #if 0
- struct req_exec_msg_messagecancel *req_exec_msg_messagecancel =
- (struct req_exec_msg_messagecancel *)message;
- struct res_lib_msg_messagecancel res_lib_msg_messagecancel;
- #endif
- }
- static void message_handler_req_exec_msg_messagesendreceive (
- void *message,
- unsigned int nodeid)
- {
- #if 0
- struct req_exec_msg_messagesendreceive *req_exec_msg_messagesendreceive =
- (struct req_exec_msg_messagesendreceive *)message;
- struct res_lib_msg_messagesendreceive res_lib_msg_messagesendreceive;
- #endif
- }
- static void message_handler_req_exec_msg_messagereply (
- void *message,
- unsigned int nodeid)
- {
- #if 0
- struct req_exec_msg_messagereply *req_exec_msg_messagereply =
- (struct req_exec_msg_messagereply *)message;
- struct res_lib_msg_messagereply res_lib_msg_messagereply;
- #endif
- }
- static void message_handler_req_lib_msg_queueopen (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_queueopen *req_lib_msg_queueopen =
- (struct req_lib_msg_queueopen *)msg;
- struct req_exec_msg_queueopen req_exec_msg_queueopen;
- struct iovec iovec;
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueOpen %s\n",
- getSaNameT (&req_lib_msg_queueopen->queueName));
- req_exec_msg_queueopen.header.size =
- sizeof (struct req_exec_msg_queueopen);
- req_exec_msg_queueopen.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEOPEN);
- message_source_set (&req_exec_msg_queueopen.source, conn);
- memcpy (&req_exec_msg_queueopen.queue_name,
- &req_lib_msg_queueopen->queueName, sizeof (SaNameT));
- memcpy (&req_exec_msg_queueopen.creation_attributes,
- &req_lib_msg_queueopen->creationAttributes,
- sizeof (SaMsgQueueCreationAttributesT));
- req_exec_msg_queueopen.async_call = 0;
- req_exec_msg_queueopen.invocation = 0;
- req_exec_msg_queueopen.queue_handle = req_lib_msg_queueopen->queueHandle;
- req_exec_msg_queueopen.openFlags = req_lib_msg_queueopen->openFlags;
- req_exec_msg_queueopen.timeout = req_lib_msg_queueopen->timeout;
- iovec.iov_base = (char *)&req_exec_msg_queueopen;
- iovec.iov_len = sizeof (req_exec_msg_queueopen);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_queueopenasync (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_queueopen *req_lib_msg_queueopen =
- (struct req_lib_msg_queueopen *)msg;
- struct req_exec_msg_queueopen req_exec_msg_queueopen;
- struct iovec iovec;
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueOpenAsync %s\n",
- getSaNameT (&req_lib_msg_queueopen->queueName));
- req_exec_msg_queueopen.header.size =
- sizeof (struct req_exec_msg_queueopen);
- req_exec_msg_queueopen.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEOPEN);
- message_source_set (&req_exec_msg_queueopen.source, conn);
- memcpy (&req_exec_msg_queueopen.queue_name,
- &req_lib_msg_queueopen->queueName, sizeof (SaNameT));
- memcpy (&req_exec_msg_queueopen.creation_attributes,
- &req_lib_msg_queueopen->creationAttributes,
- sizeof (SaMsgQueueCreationAttributesT));
- req_exec_msg_queueopen.async_call = 1;
- req_exec_msg_queueopen.invocation = req_lib_msg_queueopen->invocation;
- req_exec_msg_queueopen.queue_handle = req_lib_msg_queueopen->queueHandle;
- req_exec_msg_queueopen.openFlags = req_lib_msg_queueopen->openFlags;
- req_exec_msg_queueopen.timeout = SA_TIME_END;
- iovec.iov_base = (char *)&req_exec_msg_queueopen;
- iovec.iov_len = sizeof (req_exec_msg_queueopen);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_queueclose (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_queueclose *req_lib_msg_queueclose =
- (struct req_lib_msg_queueclose *)msg;
- struct req_exec_msg_queueclose req_exec_msg_queueclose;
- struct iovec iovec;
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueClose %s\n",
- getSaNameT (&req_lib_msg_queueclose->queueName));
- req_exec_msg_queueclose.header.size =
- sizeof (struct req_exec_msg_queueclose);
- req_exec_msg_queueclose.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUECLOSE);
- message_source_set (&req_exec_msg_queueclose.source, conn);
- memcpy (&req_exec_msg_queueclose.queue_name,
- &req_lib_msg_queueclose->queueName, sizeof (SaNameT));
- iovec.iov_base = (char *)&req_exec_msg_queueclose;
- iovec.iov_len = sizeof (req_exec_msg_queueclose);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_queuestatusget (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_queuestatusget *req_lib_msg_queuestatusget =
- (struct req_lib_msg_queuestatusget *)msg;
- struct req_exec_msg_queuestatusget req_exec_msg_queuestatusget;
- struct iovec iovec;
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueStatusGet %s\n",
- getSaNameT (&req_lib_msg_queuestatusget->queueName));
- req_exec_msg_queuestatusget.header.size =
- sizeof (struct req_exec_msg_queuestatusget);
- req_exec_msg_queuestatusget.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUESTATUSGET);
- message_source_set (&req_exec_msg_queuestatusget.source, conn);
- memcpy (&req_exec_msg_queuestatusget.queue_name,
- &req_lib_msg_queuestatusget->queueName, sizeof (SaNameT));
- iovec.iov_base = (char *)&req_exec_msg_queuestatusget;
- iovec.iov_len = sizeof (req_exec_msg_queuestatusget);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_queueunlink (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_queueunlink *req_lib_msg_queueunlink =
- (struct req_lib_msg_queueunlink *)msg;
- struct req_exec_msg_queueunlink req_exec_msg_queueunlink;
- struct iovec iovec;
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueUnlink %s\n",
- getSaNameT (&req_lib_msg_queueunlink->queueName));
- req_exec_msg_queueunlink.header.size =
- sizeof (struct req_exec_msg_queueunlink);
- req_exec_msg_queueunlink.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEUNLINK);
- message_source_set (&req_exec_msg_queueunlink.source, conn);
- memcpy (&req_exec_msg_queueunlink.queue_name,
- &req_lib_msg_queueunlink->queueName, sizeof (SaNameT));
- iovec.iov_base = (char *)&req_exec_msg_queueunlink;
- iovec.iov_len = sizeof (req_exec_msg_queueunlink);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_queuegroupcreate (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_queuegroupcreate *req_lib_msg_queuegroupcreate =
- (struct req_lib_msg_queuegroupcreate *)msg;
- struct req_exec_msg_queuegroupcreate req_exec_msg_queuegroupcreate;
- struct iovec iovec;
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupCreate %s\n",
- getSaNameT (&req_lib_msg_queuegroupcreate->queueGroupName));
- req_exec_msg_queuegroupcreate.header.size =
- sizeof (struct req_exec_msg_queuegroupcreate);
- req_exec_msg_queuegroupcreate.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPCREATE);
- message_source_set (&req_exec_msg_queuegroupcreate.source, conn);
- memcpy (&req_exec_msg_queuegroupcreate.queue_group_name,
- &req_lib_msg_queuegroupcreate->queueGroupName, sizeof (SaNameT));
- req_exec_msg_queuegroupcreate.policy =
- req_lib_msg_queuegroupcreate->queueGroupPolicy;
- iovec.iov_base = (char *)&req_exec_msg_queuegroupcreate;
- iovec.iov_len = sizeof (req_exec_msg_queuegroupcreate);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_queuegroupinsert (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_queuegroupinsert *req_lib_msg_queuegroupinsert =
- (struct req_lib_msg_queuegroupinsert *)msg;
- struct req_exec_msg_queuegroupinsert req_exec_msg_queuegroupinsert;
- struct iovec iovec;
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupInsert %s\n",
- getSaNameT (&req_lib_msg_queuegroupinsert->queueGroupName));
- req_exec_msg_queuegroupinsert.header.size =
- sizeof (struct req_exec_msg_queuegroupinsert);
- req_exec_msg_queuegroupinsert.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPINSERT);
- message_source_set (&req_exec_msg_queuegroupinsert.source, conn);
- memcpy (&req_exec_msg_queuegroupinsert.queue_name,
- &req_lib_msg_queuegroupinsert->queueName, sizeof (SaNameT));
- memcpy (&req_exec_msg_queuegroupinsert.queue_group_name,
- &req_lib_msg_queuegroupinsert->queueGroupName, sizeof (SaNameT));
- iovec.iov_base = (char *)&req_exec_msg_queuegroupinsert;
- iovec.iov_len = sizeof (req_exec_msg_queuegroupinsert);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_queuegroupremove (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_queuegroupremove *req_lib_msg_queuegroupremove =
- (struct req_lib_msg_queuegroupremove *)msg;
- struct req_exec_msg_queuegroupremove req_exec_msg_queuegroupremove;
- struct iovec iovec;
- req_exec_msg_queuegroupremove.header.size =
- sizeof (struct req_exec_msg_queuegroupremove);
- req_exec_msg_queuegroupremove.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPREMOVE);
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupRemove %s\n",
- getSaNameT (&req_lib_msg_queuegroupremove->queueGroupName));
- message_source_set (&req_exec_msg_queuegroupremove.source, conn);
- memcpy (&req_exec_msg_queuegroupremove.queue_name,
- &req_lib_msg_queuegroupremove->queueName, sizeof (SaNameT));
- memcpy (&req_exec_msg_queuegroupremove.queue_group_name,
- &req_lib_msg_queuegroupremove->queueGroupName, sizeof (SaNameT));
- iovec.iov_base = (char *)&req_exec_msg_queuegroupremove;
- iovec.iov_len = sizeof (req_exec_msg_queuegroupremove);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_queuegroupdelete (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_queuegroupdelete *req_lib_msg_queuegroupdelete =
- (struct req_lib_msg_queuegroupdelete *)msg;
- struct req_exec_msg_queuegroupdelete req_exec_msg_queuegroupdelete;
- struct iovec iovec;
- req_exec_msg_queuegroupdelete.header.size =
- sizeof (struct req_exec_msg_queuegroupdelete);
- req_exec_msg_queuegroupdelete.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPDELETE);
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupDelete %s\n",
- getSaNameT (&req_lib_msg_queuegroupdelete->queueGroupName));
- message_source_set (&req_exec_msg_queuegroupdelete.source, conn);
- memcpy (&req_exec_msg_queuegroupdelete.queue_group_name,
- &req_lib_msg_queuegroupdelete->queueGroupName, sizeof (SaNameT));
- iovec.iov_base = (char *)&req_exec_msg_queuegroupdelete;
- iovec.iov_len = sizeof (req_exec_msg_queuegroupdelete);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_queuegrouptrack (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_queuegrouptrack *req_lib_msg_queuegrouptrack =
- (struct req_lib_msg_queuegrouptrack *)msg;
- struct req_exec_msg_queuegrouptrack req_exec_msg_queuegrouptrack;
- struct iovec iovec;
- req_exec_msg_queuegrouptrack.header.size =
- sizeof (struct req_exec_msg_queuegrouptrack);
- req_exec_msg_queuegrouptrack.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPTRACK);
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupTrack %s\n",
- getSaNameT (&req_lib_msg_queuegrouptrack->queueGroupName));
- message_source_set (&req_exec_msg_queuegrouptrack.source, conn);
- memcpy (&req_exec_msg_queuegrouptrack.queue_group_name,
- &req_lib_msg_queuegrouptrack->queueGroupName, sizeof (SaNameT));
- req_exec_msg_queuegrouptrack.track_flags =
- req_lib_msg_queuegrouptrack->trackFlags;
- req_exec_msg_queuegrouptrack.buffer_flag =
- req_lib_msg_queuegrouptrack->bufferFlag;
- iovec.iov_base = (char *)&req_exec_msg_queuegrouptrack;
- iovec.iov_len = sizeof (req_exec_msg_queuegrouptrack);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_queuegrouptrackstop (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_queuegrouptrackstop *req_lib_msg_queuegrouptrackstop =
- (struct req_lib_msg_queuegrouptrackstop *)msg;
- struct req_exec_msg_queuegrouptrackstop req_exec_msg_queuegrouptrackstop;
- struct iovec iovec;
- req_exec_msg_queuegrouptrackstop.header.size =
- sizeof (struct req_exec_msg_queuegrouptrackstop);
- req_exec_msg_queuegrouptrackstop.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_QUEUEGROUPTRACKSTOP);
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgQueueGroupTrackStop %s\n",
- getSaNameT (&req_lib_msg_queuegrouptrackstop->queueGroupName));
- message_source_set (&req_exec_msg_queuegrouptrackstop.source, conn);
- memcpy (&req_exec_msg_queuegrouptrackstop.queue_group_name,
- &req_lib_msg_queuegrouptrackstop->queueGroupName, sizeof (SaNameT));
- iovec.iov_base = (char *)&req_exec_msg_queuegrouptrackstop;
- iovec.iov_len = sizeof (req_exec_msg_queuegrouptrackstop);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_messagesend (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_messagesend *req_lib_msg_messagesend =
- (struct req_lib_msg_messagesend *)msg;
- struct req_exec_msg_messagesend req_exec_msg_messagesend;
- struct iovec iovecs[2];
- req_exec_msg_messagesend.header.size =
- sizeof (struct req_exec_msg_messagesend);
- req_exec_msg_messagesend.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGESEND);
- req_exec_msg_messagesend.async_call = 0;
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageSend %s\n",
- getSaNameT (&req_lib_msg_messagesend->destination));
- message_source_set (&req_exec_msg_messagesend.source, conn);
- memcpy (&req_exec_msg_messagesend.destination,
- &req_lib_msg_messagesend->destination, sizeof (SaNameT));
- memcpy (&req_exec_msg_messagesend.message,
- &req_lib_msg_messagesend->message, sizeof (SaMsgMessageT));
- req_exec_msg_messagesend.async_call = 0;
- req_exec_msg_messagesend.invocation = 0;
- req_exec_msg_messagesend.ack_flags = req_lib_msg_messagesend->ackFlags;
- req_exec_msg_messagesend.timeout = req_lib_msg_messagesend->timeout;
- iovecs[0].iov_base = (char *)&req_exec_msg_messagesend;
- iovecs[0].iov_len = sizeof (req_exec_msg_messagesend);
- iovecs[1].iov_base = ((char *)req_lib_msg_messagesend) +
- sizeof (struct req_lib_msg_messagesend);
- iovecs[1].iov_len = req_lib_msg_messagesend->header.size -
- sizeof (struct req_lib_msg_messagesend);
- req_exec_msg_messagesend.header.size += iovecs[1].iov_len;
- if (iovecs[1].iov_len > 0) {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2,
- TOTEMPG_AGREED) == 0);
- } else {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1,
- TOTEMPG_AGREED) == 0);
- }
- }
- static void message_handler_req_lib_msg_messagesendasync (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_messagesend *req_lib_msg_messagesend =
- (struct req_lib_msg_messagesend *)msg;
- struct req_exec_msg_messagesend req_exec_msg_messagesend;
- struct iovec iovecs[2];
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageSendAsync %s\n",
- getSaNameT (&req_lib_msg_messagesend->destination));
- req_exec_msg_messagesend.header.size =
- sizeof (struct req_exec_msg_messagesend);
- req_exec_msg_messagesend.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGESEND);
- message_source_set (&req_exec_msg_messagesend.source, conn);
- memcpy (&req_exec_msg_messagesend.destination,
- &req_lib_msg_messagesend->destination, sizeof (SaNameT));
- memcpy (&req_exec_msg_messagesend.message,
- &req_lib_msg_messagesend->message, sizeof (SaMsgMessageT));
- req_exec_msg_messagesend.async_call = 1;
- req_exec_msg_messagesend.invocation = req_lib_msg_messagesend->invocation;
- req_exec_msg_messagesend.ack_flags = req_lib_msg_messagesend->ackFlags;
- req_exec_msg_messagesend.timeout = SA_TIME_END;
- iovecs[0].iov_base = (char *)&req_exec_msg_messagesend;
- iovecs[0].iov_len = sizeof (req_exec_msg_messagesend);
- iovecs[1].iov_base = ((char *)req_lib_msg_messagesend) +
- sizeof (struct req_lib_msg_messagesend);
- iovecs[1].iov_len = req_lib_msg_messagesend->header.size -
- sizeof (struct req_lib_msg_messagesend);
- req_exec_msg_messagesend.header.size += iovecs[1].iov_len;
- if (iovecs[1].iov_len > 0) {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2,
- TOTEMPG_AGREED) == 0);
- } else {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2,
- TOTEMPG_AGREED) == 0);
- }
- }
- static void message_handler_req_lib_msg_messageget (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_messageget *req_lib_msg_messageget =
- (struct req_lib_msg_messageget *)msg;
- struct req_exec_msg_messageget req_exec_msg_messageget;
- struct iovec iovec;
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageGet %s\n",
- getSaNameT (&req_lib_msg_messageget->queueName));
- req_exec_msg_messageget.header.size =
- sizeof (struct req_exec_msg_messageget);
- req_exec_msg_messageget.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGEGET);
- message_source_set (&req_exec_msg_messageget.source, conn);
- memcpy (&req_exec_msg_messageget.queue_name,
- &req_lib_msg_messageget->queueName, sizeof (SaNameT));
- iovec.iov_base = (char *)&req_exec_msg_messageget;
- iovec.iov_len = sizeof (req_exec_msg_messageget);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_messagecancel (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_messagecancel *req_lib_msg_messagecancel =
- (struct req_lib_msg_messagecancel *)msg;
- struct req_exec_msg_messagecancel req_exec_msg_messagecancel;
- struct iovec iovec;
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageCancel %s\n",
- getSaNameT (&req_lib_msg_messagecancel->queueName));
- req_exec_msg_messagecancel.header.size =
- sizeof (struct req_exec_msg_messagecancel);
- req_exec_msg_messagecancel.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGECANCEL);
- message_source_set (&req_exec_msg_messagecancel.source, conn);
- memcpy (&req_exec_msg_messagecancel.queue_name,
- &req_lib_msg_messagecancel->queueName, sizeof (SaNameT));
- iovec.iov_base = (char *)&req_exec_msg_messagecancel;
- iovec.iov_len = sizeof (req_exec_msg_messagecancel);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_messagesendreceive (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_messagesendreceive *req_lib_msg_messagesendreceive =
- (struct req_lib_msg_messagesendreceive *)msg;
- struct req_exec_msg_messagesendreceive req_exec_msg_messagesendreceive;
- struct iovec iovec;
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageSendReceive %s\n",
- getSaNameT (&req_lib_msg_messagesendreceive->queueName));
- req_exec_msg_messagesendreceive.header.size =
- sizeof (struct req_exec_msg_messagesendreceive);
- req_exec_msg_messagesendreceive.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGESENDRECEIVE);
- message_source_set (&req_exec_msg_messagesendreceive.source, conn);
- memcpy (&req_exec_msg_messagesendreceive.queue_name,
- &req_lib_msg_messagesendreceive->queueName, sizeof (SaNameT));
- iovec.iov_base = (char *)&req_exec_msg_messagesendreceive;
- iovec.iov_len = sizeof (req_exec_msg_messagesendreceive);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_messagereply (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_messagereply *req_lib_msg_messagereply =
- (struct req_lib_msg_messagereply *)msg;
- struct req_exec_msg_messagereply req_exec_msg_messagereply;
- struct iovec iovec;
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageReply %s\n",
- getSaNameT (&req_lib_msg_messagereply->queueName));
- req_exec_msg_messagereply.header.size =
- sizeof (struct req_exec_msg_messagereply);
- req_exec_msg_messagereply.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGEREPLY);
- req_exec_msg_messagereply.async_call = 0;
- message_source_set (&req_exec_msg_messagereply.source, conn);
- memcpy (&req_exec_msg_messagereply.queue_name,
- &req_lib_msg_messagereply->queueName, sizeof (SaNameT));
- iovec.iov_base = (char *)&req_exec_msg_messagereply;
- iovec.iov_len = sizeof (req_exec_msg_messagereply);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_msg_messagereplyasync (
- void *conn,
- void *msg)
- {
- struct req_lib_msg_messagereply *req_lib_msg_messagereply =
- (struct req_lib_msg_messagereply *)msg;
- struct req_exec_msg_messagereply req_exec_msg_messagereply;
- struct iovec iovec;
- log_printf (LOG_LEVEL_NOTICE, "LIB request: saMsgMessageReplyAsync %s\n",
- getSaNameT (&req_lib_msg_messagereply->queueName));
- req_exec_msg_messagereply.header.size =
- sizeof (struct req_exec_msg_messagereply);
- req_exec_msg_messagereply.header.id =
- SERVICE_ID_MAKE (MSG_SERVICE, MESSAGE_REQ_EXEC_MSG_MESSAGEREPLY);
- req_exec_msg_messagereply.async_call = 1;
- message_source_set (&req_exec_msg_messagereply.source, conn);
- memcpy (&req_exec_msg_messagereply.queue_name,
- &req_lib_msg_messagereply->queueName, sizeof (SaNameT));
- iovec.iov_base = (char *)&req_exec_msg_messagereply;
- iovec.iov_len = sizeof (req_exec_msg_messagereply);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
|