Commit 9bf105a1 authored by Justin Mitchell's avatar Justin Mitchell
Browse files

Make the client quit on NONCE mismatch

Needed the server to send an error response instead of immediately
closing, and wait for it to be sent.
also needed certain parts of the client shutdown proceedure tonot
cleanup/free things that hadnt yet been initialised.
parent 63b0a8c0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -66,6 +66,9 @@ void hash_free(int field)
{
    static union fieldrec *frec;

    /* make sure its actually alloced first */
    if (field == -1) return;

    /* Make sure all variables are removed */
    hash_purge(field);

+18 −0
Original line number Diff line number Diff line
@@ -474,6 +474,21 @@ static void display_uptime(ipc_message_t *msg)
	json_decref(j);
}

/** Server sent us an error, usually pretty fatal */
static void handle_ipc_error(ipc_message_t *msg)
{
	json_t * j = json_init(msg);
	const char * type = json_getstring(j, "error");

	if (strcasecmp(type, "NONCE")==0) {
		printf("Incompatible server version. Quitting.\n");
	} else {
		printf("Undefined server error '%s'\n", type);
	}
	json_decref(j);
	close_down(0, NULL, NULL);
}

static void display_error(ipc_message_t *msg)
{
	json_t * j = json_init(msg);
@@ -754,6 +769,9 @@ static void accept_pipe_cmd(ipc_message_t *msg, struct user *mesg_user)
		case IPC_WHOLIST:
			update_wholist(msg);
			break;
		case IPC_ERROR:
			handle_ipc_error(msg);
			break;
		default:
			devel_msg("incoming_mesg", "unknown message type %d.\007", state);
	}
+2 −2
Original line number Diff line number Diff line
@@ -1202,8 +1202,8 @@ int js_isrunning(void)
// cleans up the javascript environment
int stop_js(void)
{
	JS_DestroyContext(jscx);
	JS_DestroyRuntime(jsrt);
	if (jscx != NULL) JS_DestroyContext(jscx);
	if (jsrt != NULL) JS_DestroyRuntime(jsrt);
	return 0;

}
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ extern int current_rights;

struct function *function_list=NULL;
extern const char *autoexec_arg;
var_list_t var_list;
var_list_t var_list = -1;
var_list_t *local_vars=NULL;
CompStack *comparison_stack=NULL;

+1 −0
Original line number Diff line number Diff line
@@ -209,6 +209,7 @@ const char * ipc_nametype(enum ipc_types msgtype)
		case IPC_EVENT: return "IPC_EVENT"; break;
		case IPC_ACTION: return "IPC_ACTION"; break;
		case IPC_WHOLIST: return "IPC_WHOLIST"; break;
		case IPC_ERROR: return "IPC_ERROR"; break;
	}
	return "IPC_Unknown";
}
Loading