![]() |
|
|||
0001 /** 0002 * @brief In this case ndrxd is responder to ping requests 0003 * 0004 * @file cmd_dping.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 #include <utlist.h> 0039 0040 #include <ndrstandard.h> 0041 0042 #include <ndebug.h> 0043 #include <userlog.h> 0044 #include <ndrxd.h> 0045 #include <ndrxdcmn.h> 0046 0047 #include "cmd_processor.h" 0048 #include <atmi_shm.h> 0049 /*---------------------------Externs------------------------------------*/ 0050 /*---------------------------Macros-------------------------------------*/ 0051 /*---------------------------Enums--------------------------------------*/ 0052 /*---------------------------Typedefs-----------------------------------*/ 0053 /*---------------------------Globals------------------------------------*/ 0054 /*---------------------------Statics------------------------------------*/ 0055 /*---------------------------Prototypes---------------------------------*/ 0056 0057 /** 0058 * Modify reply according the data. 0059 * @param call 0060 * @param pm 0061 */ 0062 expublic void dping_reply_mod(command_reply_t *reply, size_t *send_size, 0063 mod_param_t *params) 0064 { 0065 command_reply_srvping_t * rply = (command_reply_srvping_t *)reply; 0066 command_srvping_t *req = (command_srvping_t *)params->mod_param1; 0067 0068 reply->msg_type = NDRXD_CALL_TYPE_DPING; 0069 /* calculate new send size */ 0070 *send_size += (sizeof(command_reply_srvping_t) - sizeof(command_reply_t)); 0071 0072 rply->seq = req->seq; 0073 rply->srvid = req->srvid; 0074 0075 NDRX_LOG(log_debug, "magic: %ld reply ping seq %d", 0076 rply->rply.magic, rply->seq); 0077 } 0078 0079 /** 0080 * Call to dping command 0081 * @param args 0082 * @return 0083 */ 0084 expublic int cmd_dping (command_call_t * call, char *data, size_t len, 0085 int context) 0086 { 0087 int ret=EXSUCCEED; 0088 command_srvping_t *ping = (command_srvping_t *)call; 0089 mod_param_t params; 0090 0091 memset(¶ms, 0, sizeof(mod_param_t)); 0092 params.mod_param1 = (void *)call; 0093 0094 0095 if (EXSUCCEED!=simple_command_reply(call, ret, 0L, ¶ms, dping_reply_mod, 0096 0L, 0, NULL)) 0097 { 0098 userlog("Failed to send reply back to [%s]", call->reply_queue); 0099 } 0100 0101 out: 0102 NDRX_LOG(log_warn, "cmd_dping returns with status %d", ret); 0103 return ret; 0104 } 0105 0106 /** 0107 * Put ndrxd to sleep, reply first 0108 * @param args 0109 * @return 0110 */ 0111 expublic int cmd_dsleep (command_call_t * call, char *data, size_t len, 0112 int context) 0113 { 0114 int ret=EXSUCCEED; 0115 command_dsleep_t *dsleepcall = (command_dsleep_t *)call; 0116 0117 out: 0118 if (EXSUCCEED!=simple_command_reply(call, ret, 0L, NULL, NULL, 0L, 0, NULL)) 0119 { 0120 userlog("Failed to send reply back to [%s]", call->reply_queue); 0121 } 0122 0123 NDRX_LOG(log_warn, "cmd_set returns with status %d, about to sleep: %d", 0124 ret, dsleepcall->secs); 0125 0126 sleep(dsleepcall->secs); 0127 0128 return EXSUCCEED; /* Do not want to break the system! */ 0129 } 0130 0131 /* 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 |
![]() ![]() |