static void init(qcom_sQid* myQid) { pwr_tStatus sts; sts = gdh_Init("pwr_nacp"); if (EVEN(sts)) { errh_Fatal("gdh_Init, %m", sts); errh_SetStatus(PWR__SRVTERM); exit(sts); } #if defined OS_CYGWIN qcom_sQattr qAttr; qcom_sQid qid = qcom_cQnacp; qAttr.type = qcom_eQtype_private; qAttr.quota = 100; if (!qcom_CreateQ(&sts, &qid, &qAttr, "nacp")) { errh_Error("Failed to create QCOM que\n%m", sts); errh_SetStatus(PWR__SRVTERM); exit(sts); } #else if (!qcom_AttachQ(&sts, &qcom_cQnacp)) { errh_Fatal("qcom_AttachQ, %m", sts); errh_SetStatus(PWR__SRVTERM); exit(sts); } #endif *myQid = qcom_cQnacp; if (!qcom_Bind(&sts, myQid, &qcom_cQini)) { errh_Fatal("qcom_Bind, %m", sts); errh_SetStatus(PWR__SRVTERM); exit(-1); } /* Activate all subscriptions that were requested before we started! */ gdb_ScopeLock { gdbroot->db->neth_acp = *myQid; subc_ActivateList(&gdbroot->my_node->subc_lh, pwr_cNObjid); subc_ActivateList(&gdbroot->no_node->subc_lh, pwr_cNObjid); } gdb_ScopeUnlock; }
void subcm_FlushNode ( pwr_tStatus *sts, gdb_sNode *np ) { subc_ActivateList(&np->subc_lh, pwr_cNObjid); }
static void nodeUp(net_sNodeUp* mp) { pwr_tStatus sts; gdb_sNode* np; np = hash_Search(&sts, gdbroot->nid_ht, &mp->nid); if (np == NULL) { errh_Error("Message about unknown node: (%s) received\n", cdh_NodeIdToString(NULL, mp->nid, 0, 0)); return; } errh_Info("Up, link to node %s (%s)", np->name, cdh_NodeIdToString(NULL, mp->nid, 0, 0)); gdb_ScopeLock { lockMountServers(np); subc_ActivateList(&np->subc_lh, pwr_cNObjid); subc_ActivateList(&gdbroot->no_node->subc_lh, pwr_cNObjid); sanc_SubscribeMountServers(&sts, np); } gdb_ScopeUnlock; }
static void init ( qcom_sQid *myQid ) { pwr_tStatus sts; sts = gdh_Init("pwr_nacp"); if (EVEN(sts)) { errh_Fatal("gdh_Init, %m", sts); errh_SetStatus( PWR__SRVTERM); exit(sts); } if (!qcom_AttachQ(&sts, &qcom_cQnacp)) { errh_Fatal("qcom_AttachQ, %m", sts); errh_SetStatus( PWR__SRVTERM); exit(sts); } *myQid = qcom_cQnacp; if (!qcom_Bind(&sts, myQid, &qcom_cQini)) { errh_Fatal("qcom_Bind, %m", sts); errh_SetStatus( PWR__SRVTERM); exit(-1); } /* Activate all subscriptions that were requested before we started! */ gdb_ScopeLock { gdbroot->db->neth_acp = *myQid; subc_ActivateList(&gdbroot->my_node->subc_lh, pwr_cNObjid); subc_ActivateList(&gdbroot->no_node->subc_lh, pwr_cNObjid); } gdb_ScopeUnlock; }
int main ( int argc, char **argv ) { pwr_tStatus sts; qcom_sGet get; net_sNotify *notify; net_sMessage *mp; gdb_sNode *np; qcom_sQid qid = qcom_cNQid; errh_Init("pwr_nacp", errh_eAnix_neth_acp); errh_SetStatus( PWR__SRVSTARTUP); init(&qid); errh_SetStatus( PWR__SRUN); for (;;) { mp = receive(&qid, &get); np = node(mp); if (np == NULL) { errh_Error("sender %u.%u, type %u.%u, size %u, reply %u.%u", get.sender.nid, get.sender.aix, get.type.b, get.type.s, get.size, get.reply.nid, get.reply.qix); continue; } switch (get.type.s) { case net_eMsg_nodeUp: nodeUp((net_sNodeUp *) mp); break; case net_eMsg_createObject: gdb_ScopeLock { subc_ActivateList(&gdbroot->no_node->subc_lh, pwr_cNObjid); } gdb_ScopeUnlock; break; case net_eMsg_deleteObject: notify = (net_sNotify *) mp; gdb_ScopeLock { subc_ActivateList(&np->subc_lh, notify->oid); } gdb_ScopeUnlock; break; case net_eMsg_moveObject: case net_eMsg_renameObject: gdb_ScopeLock { subc_ActivateList(&np->subc_lh, pwr_cNObjid); subc_ActivateList(&gdbroot->no_node->subc_lh, pwr_cNObjid); } gdb_ScopeUnlock; break; default: errh_Error("Unexpected subtype %d received from %d.%d %X", get.type.s, get.reply.qix, get.reply.nid, get.pid); } qcom_Free(&sts, mp); } }