![]() |
|
|||
0001 /** 0002 * @brief Ping command related routines (i.e send ping from ndrxd and get reply from server) 0003 * 0004 * @file cmd_ping.c 0005 */ 0006 /* ----------------------------------------------------------------------------- 0007 * Enduro/X Middleware Platform for Distributed Transaction Processing 0008 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0009 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0010 * This software is released under one of the following licenses: 0011 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0012 * See LICENSE file for full text. 0013 * ----------------------------------------------------------------------------- 0014 * AGPL license: 0015 * 0016 * This program is free software; you can redistribute it and/or modify it under 0017 * the terms of the GNU Affero General Public License, version 3 as published 0018 * by the Free Software Foundation; 0019 * 0020 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0022 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0023 * for more details. 0024 * 0025 * You should have received a copy of the GNU Affero General Public License along 0026 * with this program; if not, write to the Free Software Foundation, Inc., 0027 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0028 * 0029 * ----------------------------------------------------------------------------- 0030 * A commercial use license is available from Mavimax, Ltd 0031 * contact@mavimax.com 0032 * ----------------------------------------------------------------------------- 0033 */ 0034 #include <string.h> 0035 #include <stdio.h> 0036 #include <stdlib.h> 0037 #include <memory.h> 0038 0039 #include <ndrstandard.h> 0040 0041 #include "ndebug.h" 0042 #include "userlog.h" 0043 #include <ndrxd.h> 0044 #include <ndrxdcmn.h> 0045 #include <atmi.h> 0046 #include <cmd_processor.h> 0047 /*---------------------------Externs------------------------------------*/ 0048 /*---------------------------Macros-------------------------------------*/ 0049 /*---------------------------Enums--------------------------------------*/ 0050 /*---------------------------Typedefs-----------------------------------*/ 0051 /*---------------------------Globals------------------------------------*/ 0052 /*---------------------------Statics------------------------------------*/ 0053 /*---------------------------Prototypes---------------------------------*/ 0054 0055 0056 /** 0057 * Unadvertise service, call from xadmin. 0058 * @param args 0059 * @return 0060 */ 0061 expublic int srv_send_ping (pm_node_t *p_pm) 0062 { 0063 int ret=EXSUCCEED; 0064 0065 command_srvping_t ping; 0066 0067 memset(&ping, 0, sizeof(ping)); 0068 if (PING_MAX_SEQ==p_pm->pingseq || 0==p_pm->pingseq) 0069 { 0070 p_pm->pingseq=1; 0071 } 0072 else 0073 { 0074 p_pm->pingseq++; 0075 } 0076 ping.seq = p_pm->pingseq; 0077 ping.srvid = p_pm->srvid; 0078 ndrx_stopwatch_reset(&p_pm->pingroundtrip); 0079 0080 /* Call the server */ 0081 if (EXSUCCEED!=(ret = cmd_generic_callfl(NDRXD_COM_SRVPING_RQ, NDRXD_SRC_ADMIN, 0082 NDRXD_CALL_TYPE_GENERIC, 0083 (command_call_t *)&ping, sizeof(ping), 0084 G_command_state.listenq_str, 0085 G_command_state.listenq, 0086 (mqd_t)EXFAIL, 0087 get_srv_admin_q(p_pm), 0088 0, NULL, 0089 NULL, 0090 NULL, 0091 NULL, 0092 EXFALSE, 0093 TPNOBLOCK))) 0094 { 0095 NDRX_LOG(log_error, "Failed to send ping command to server id=%d!", 0096 ping.srvid); 0097 ret=EXFAIL; 0098 goto out; 0099 } 0100 0101 out: 0102 0103 NDRX_LOG(log_info, "srv_send_ping returns with status %d", ret); 0104 return ret; 0105 } 0106 0107 /** 0108 * Server ping response comman processing 0109 * @param call 0110 * @param data 0111 * @param len 0112 * @param context 0113 * @return 0114 */ 0115 expublic int cmd_srvpingrsp (command_call_t * call, char *data, size_t len, int context) 0116 { 0117 int ret=EXSUCCEED; 0118 0119 command_srvping_t * ping = (command_srvping_t *)call; 0120 pm_node_t *p_pm = get_pm_from_srvid(ping->srvid); 0121 0122 if (NULL==p_pm) 0123 { 0124 NDRX_LOG(log_error, "No such server with id: %d", ping->srvid); 0125 ret=EXFAIL; 0126 goto out; 0127 } 0128 else if (p_pm->pingseq == ping->seq) 0129 { 0130 NDRX_LOG(log_info, "Server id=%d ok, binary: [%s] ping reply seq: %d, rsptime: %s", 0131 ping->srvid, p_pm->binary_name, ping->seq, 0132 ndrx_stopwatch_decode(&p_pm->pingroundtrip, 0)); 0133 0134 /* Well... we should not count the time unless the 0135 * ping has been issued. 0136 * */ 0137 p_pm->rspstwatch = SANITY_CNT_START; 0138 p_pm->pingstwatch = SANITY_CNT_IDLE; 0139 } 0140 else 0141 { 0142 NDRX_LOG(log_error, "WARNING: Server id=%d, binary: [%s] ping " 0143 "seq out of order! Expected: %d got: %d", 0144 ping->srvid, p_pm->binary_name, p_pm->pingseq, ping->seq); 0145 } 0146 0147 out: 0148 /* Ignore the error */ 0149 return EXSUCCEED; 0150 } 0151 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |