/* ********************************************************************* */ INT rpc_slave_eor() { if(enable_rpc_slave) { cm_disconnect_client(rpc_conn_master_crate, 0); } return SUCCESS; }
void cam_exit(void) { if (midas_connect) { cm_disconnect_client(hConn, FALSE); cm_disconnect_experiment(); } else { if (hConn) rpc_client_disconnect(hConn, FALSE); } }
INT rpc_master_eor() { if(!enable_rpc_master) { return SUCCESS; } for(int i = 0; i < MAX_CRATES; i++) { if(i != crate_number && crate[i].enabled) { cm_disconnect_client(crate[i].conn, 0); } } return SUCCESS; }
int cam_init_rpc(char *host_name, char *exp_name, char *fe_name, char *client_name, char *rpc_server) { INT status, i, size; char str[256]; HNDLE hDB, hKey, hRootKey, hSubkey; if (rpc_server[0]) { /* connect directly to RPC server, not to MIDAS experiment */ midas_connect = FALSE; #ifdef OS_WINNT { WSADATA WSAData; /* Start windows sockets */ if (WSAStartup(MAKEWORD(1, 1), &WSAData) != 0) return RPC_NET_ERROR; } #endif rpc_set_name(client_name); rpc_register_functions(rpc_get_internal_list(0), NULL); rpc_register_functions(rpc_get_internal_list(1), NULL); status = rpc_client_connect(rpc_server, 1750, client_name, &hConn); if (status != RPC_SUCCESS) { printf("Cannot connect to RPC server running on %s at port 1750.\n", rpc_server); return status; } } else { /* connect to MIDAS experiment */ midas_connect = TRUE; /* turn off message display, turn on message logging */ cm_set_msg_print(MT_ALL, 0, NULL); /* connect to experiment */ status = cm_connect_experiment(host_name, exp_name, client_name, 0); if (status != CM_SUCCESS) return CM_UNDEF_EXP; /* connect to the database */ cm_get_experiment_database(&hDB, &hKey); /* find CNAF server if not specified */ strcpy(str, fe_name); if (fe_name[0] == '\0') { /* find client which exports CNAF function */ status = db_find_key(hDB, 0, "System/Clients", &hRootKey); if (status == DB_SUCCESS) { for (i = 0, status = 0;; i++) { status = db_enum_key(hDB, hRootKey, i, &hSubkey); if (status == DB_NO_MORE_SUBKEYS) { printf("No client currently exports the CNAF functionality.\n"); cm_disconnect_experiment(); return CM_UNDEF_EXP; } sprintf(str, "RPC/%d", RPC_CNAF16); status = db_find_key(hDB, hSubkey, str, &hKey); if (status == DB_SUCCESS) { size = sizeof(str); db_get_value(hDB, hSubkey, "Name", str, &size, TID_STRING, TRUE); break; } } } } /* register CNAF_RPC call */ if (cm_connect_client(str, &hConn) == CM_SUCCESS) { DWORD data, size, q, x; /* test if CNAF function implemented */ size = sizeof(WORD); status = rpc_client_call(hConn, RPC_CNAF16, CNAF_TEST, 0, 0, 0, 0, 0, &data, &size, &q, &x); if (status != RPC_SUCCESS) { printf("CNAF functionality not implemented by frontend %s\n", fe_name); cm_disconnect_client(hConn, FALSE); return CM_NO_CLIENT; } } else { printf("Cannot connect to frontend %s\n", fe_name); return CM_NO_CLIENT; } } return SUCCESS; }