0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
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 "cmd_processor.h"
0044 #include <ndrxd.h>
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 expublic void reload_reply_mod(command_reply_t *reply, size_t *send_size, mod_param_t *paramsg)
0059 {
0060 mod_param5_t *params = (mod_param5_t *)paramsg;
0061
0062 command_reply_reload_t * err_info = (command_reply_reload_t *)reply;
0063
0064 reply->msg_type = NDRXD_CALL_TYPE_PM_RELERR;
0065
0066 *send_size += (sizeof(command_reply_reload_t) - sizeof(command_reply_t));
0067
0068 if (NULL!=params->mod_param1)
0069 NDRX_STRCPY_SAFE(err_info->old_binary, params->mod_param1);
0070
0071 if (NULL!=params->mod_param3)
0072 NDRX_STRCPY_SAFE(err_info->new_binary, params->mod_param3);
0073
0074 err_info->error = params->param2;
0075 err_info->srvid = (int)params->param4;
0076
0077 NDRX_STRCPY_SAFE(err_info->msg, params->param5);
0078
0079 NDRX_LOG(log_debug, "magic: %ld", err_info->rply.magic);
0080 }
0081
0082
0083
0084
0085
0086
0087
0088 expublic void reload_error(command_call_t * call, int srvid, char *old_bin,
0089 char *new_bin, int error, char *msg)
0090 {
0091 int ret=EXSUCCEED;
0092 mod_param5_t params;
0093
0094 NDRX_LOG(log_debug, "reload_error enter");
0095 memset(¶ms, 0, sizeof(mod_param_t));
0096
0097
0098 params.mod_param1 = old_bin;
0099 params.param2 = error;
0100 params.mod_param3 = new_bin;
0101 params.param4 = srvid;
0102 NDRX_STRCPY_SAFE(params.param5, msg);
0103
0104 if (EXSUCCEED!=simple_command_reply(call, ret, NDRXD_CALL_FLAGS_RSPHAVE_MORE,
0105
0106 (mod_param_t*)¶ms, reload_reply_mod, 0L, 0, NULL))
0107 {
0108 userlog("Failed to send progress back to [%s]", call->reply_queue);
0109 }
0110
0111 NDRX_LOG(log_debug, "reload_error exit");
0112 }
0113
0114
0115
0116
0117
0118
0119 expublic int cmd_testcfg (command_call_t * call, char *data, size_t len, int context)
0120 {
0121 int ret=EXSUCCEED;
0122
0123 ret = test_config(EXFALSE, call, reload_error);
0124
0125 if (EXSUCCEED!=simple_command_reply(call, ret, 0L, NULL, NULL, 0L, 0, NULL))
0126 {
0127 userlog("Failed to send reply back to [%s]", call->reply_queue);
0128 }
0129
0130 NDRX_LOG(log_warn, "cmd_testcfg returns with status %d", ret);
0131
0132 return EXSUCCEED;
0133 }
0134
0135
0136
0137
0138
0139
0140
0141 expublic int cmd_reload (command_call_t * call, char *data, size_t len, int context)
0142 {
0143 int ret=EXSUCCEED;
0144
0145 ret = test_config(EXTRUE, call, reload_error);
0146
0147 if (EXSUCCEED!=simple_command_reply(call, ret, 0L, NULL, NULL, 0L, 0, NULL))
0148 {
0149 userlog("Failed to send reply back to [%s]", call->reply_queue);
0150 }
0151
0152 NDRX_LOG(log_warn, "cmd_reload returns with status %d", ret);
0153
0154 return EXSUCCEED;
0155 }
0156