[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] MI: Replace sequence number with ID
From: |
Mohammad-Reza Nabipoor |
Subject: |
[PATCH] MI: Replace sequence number with ID |
Date: |
Fri, 6 Aug 2021 18:26:47 +0430 |
With this new design, each message has an ID. It's an `int64` number.
Requests must have odd IDs >= 1. Responses must have even IDs >= 2.
The `ID == 0` is a special case, useful for reporting errors for
invalid requests. Events must have negative IDs. The client is
responsible for issuing requests with valid IDs; poke will use the
`ID + 1` as the ID of response.
2021-08-06 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* poke/pk-mi-msg.h (pk_mi_seqnum): Replaced by `pk_mi_id`.
(pk_mi_id): New typedef.
(pk_mi_make_req): Add new arg (`id`).
(pk_mi_make_event_with_id): Likewise.
(pk_mi_make_resp): Likewise.
(pk_mi_msg_number): Replaced by `pk_mi_msg_id`.
(pk_mi_set_msg_number): Replaced by `pk_mi_set_msg_id`.
(pk_mi_msg_resp_req_number): Replaced by `pk_mi_msg_resp_req_id`.
(pk_mi_msg_id): New function declaration.
(pk_mi_set_msg_id): Likewise.
(pk_mi_msg_resp_req_id): Likewise.
* poke/pk-mi-msg.def (INVREQ): s/reqnum/reqid/ and change it to `INT`.
* poke/pk-mi-msg.c (PK_MI_MSG_RESP_REQ_NUMBER): Replaced by
`PK_MI_MSG_RESP_REQ_ID`.
(PK_MI_MSG_NUMBER): Replaced by `PK_MI_MSG_ID`.
(PK_MI_MSG_RESP_REQ_ID): New accessor macro.
(struct pk_mi_msg_resp): s/req_number/req_id/.
(struct pk_mi_msg): s/number/id/.
(next_seqnum): Replaced by `next_event_id`.
(next_event_id): New global variable.
(PK_MI_MSG_ID): Likewise.
(pk_mi_make_msg): Updated.
(pk_mi_make_resp): Likewise.
(pk_mi_make_event): Likewise.
(pk_mi_msg_number): Removed.
(pk_mi_set_msg_number): Likewise.
(pk_mi_msg_resp_req_number): Likewise.
(pk_mi_make_event_with_id): New function definition.
(pk_mi_msg_id): Likewise.
(pk_mi_set_msg_id): Likewise.
(pk_mi_msg_resp_req_id): Likewise.
* poke/pk-mi.c (pk_mi_invalid_msg): Updated.
(pk_mi_dispatch_msg): Likewise.
* poke/pk-mi-json.c (MI Messages): Updated.
(pk_mi_msg_to_json_object): Likewise.
(pk_mi_json_object_to_msg): Likewise.
* doc/poke.texi (The Machine-Interface): Updated.
---
ChangeLog | 40 ++++++++++++++++++++++++++++
doc/poke.texi | 6 +++--
poke/pk-mi-json.c | 55 +++++++++++++++++++++++---------------
poke/pk-mi-msg.c | 66 +++++++++++++++++++++++++++++-----------------
poke/pk-mi-msg.def | 6 ++---
poke/pk-mi-msg.h | 29 ++++++++++++--------
poke/pk-mi.c | 11 +++++---
7 files changed, 148 insertions(+), 65 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 23a99bd8..ef2e92c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,43 @@
+2021-08-06 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
+
+ * poke/pk-mi-msg.h (pk_mi_seqnum): Replaced by `pk_mi_id`.
+ (pk_mi_id): New typedef.
+ (pk_mi_make_req): Add new arg (`id`).
+ (pk_mi_make_event_with_id): Likewise.
+ (pk_mi_make_resp): Likewise.
+ (pk_mi_msg_number): Replaced by `pk_mi_msg_id`.
+ (pk_mi_set_msg_number): Replaced by `pk_mi_set_msg_id`.
+ (pk_mi_msg_resp_req_number): Replaced by `pk_mi_msg_resp_req_id`.
+ (pk_mi_msg_id): New function declaration.
+ (pk_mi_set_msg_id): Likewise.
+ (pk_mi_msg_resp_req_id): Likewise.
+ * poke/pk-mi-msg.def (INVREQ): s/reqnum/reqid/ and change it to `INT`.
+ * poke/pk-mi-msg.c (PK_MI_MSG_RESP_REQ_NUMBER): Replaced by
+ `PK_MI_MSG_RESP_REQ_ID`.
+ (PK_MI_MSG_NUMBER): Replaced by `PK_MI_MSG_ID`.
+ (PK_MI_MSG_RESP_REQ_ID): New accessor macro.
+ (struct pk_mi_msg_resp): s/req_number/req_id/.
+ (struct pk_mi_msg): s/number/id/.
+ (next_seqnum): Replaced by `next_event_id`.
+ (next_event_id): New global variable.
+ (PK_MI_MSG_ID): Likewise.
+ (pk_mi_make_msg): Updated.
+ (pk_mi_make_resp): Likewise.
+ (pk_mi_make_event): Likewise.
+ (pk_mi_msg_number): Removed.
+ (pk_mi_set_msg_number): Likewise.
+ (pk_mi_msg_resp_req_number): Likewise.
+ (pk_mi_make_event_with_id): New function definition.
+ (pk_mi_msg_id): Likewise.
+ (pk_mi_set_msg_id): Likewise.
+ (pk_mi_msg_resp_req_id): Likewise.
+ * poke/pk-mi.c (pk_mi_invalid_msg): Updated.
+ (pk_mi_dispatch_msg): Likewise.
+ * poke/pk-mi-json.c (MI Messages): Updated.
+ (pk_mi_msg_to_json_object): Likewise.
+ (pk_mi_json_object_to_msg): Likewise.
+ * doc/poke.texi (The Machine-Interface): Updated.
+
2021-08-06 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* poke/pk-mi-msg.c (pk_mi_make_resp): Prevents `errmsg` to be `NULL`.
diff --git a/doc/poke.texi b/doc/poke.texi
index 9acf133a..b673a41e 100644
--- a/doc/poke.texi
+++ b/doc/poke.texi
@@ -13747,7 +13747,9 @@ the standard input and standard output:
@example
$ poke --mi
-^@@^@@^@@G@{"poke_mi":0,"type":2,"data":@{"type":0,"args":@{"version":"0.1-beta"@}@}@}
+^@@^@@^@@G@{"id":-1,"type":2,"data":@{"type":0,"args":@{"mi_version":
+@{"type":"Integer","value":0,"size":32@},"version":@{"type":"String",
+"value":"1.3"@}@}@}@}
@end example
When using sockets, poke prints the number of the socket where it is
@@ -13786,7 +13788,7 @@ maximum length of a frame message payload is two
kilobytes.
@dfn{Requests} are initiated by the client. Once a request is sent,
it will trigger a response. The response is paired with the
-triggering request by the request's sequence number.
+triggering request by the request's ID.
@dfn{Responses} are initiated by poke, in response to a request
received from the client.
diff --git a/poke/pk-mi-json.c b/poke/pk-mi-json.c
index a66a65b0..82769542 100644
--- a/poke/pk-mi-json.c
+++ b/poke/pk-mi-json.c
@@ -132,7 +132,7 @@ jerror (int ok, char **out, const char *fmt, ...)
/* Message::
{
- "seq" : integer
+ "id" : integer
"type" : MessageType
"data" : Request | Response | Event
}
@@ -150,7 +150,7 @@ jerror (int ok, char **out, const char *fmt, ...)
Response::
{
"type" : ResponseType
- "req_number" : uint32
+ "req_id" : int64
"success_p: : boolean
"errmsg" : string
"result"? : null
@@ -1111,14 +1111,14 @@ pk_mi_msg_to_json_object (pk_mi_msg msg)
if (!json)
goto out_of_memory;
- /* Add the number. */
+ /* Add the id. */
{
json_object *number
- = json_object_new_int (pk_mi_msg_number (msg));
+ = json_object_new_int (pk_mi_msg_id (msg));
if (!number)
goto out_of_memory;
- json_object_object_add (json, "seq", number);
+ json_object_object_add (json, "id", number);
}
/* Add the type. */
@@ -1157,7 +1157,7 @@ pk_mi_msg_to_json_object (pk_mi_msg msg)
case PK_MI_MSG_RESPONSE:
{
enum pk_mi_resp_type msg_resp_type = pk_mi_msg_resp_type (msg);
- json_object *resp, *resp_type, *success_p, *req_number, *args;
+ json_object *resp, *resp_type, *success_p, *req_id, *args;
resp = json_object_new_object ();
if (!resp)
@@ -1174,9 +1174,8 @@ pk_mi_msg_to_json_object (pk_mi_msg msg)
goto out_of_memory;
json_object_object_add (resp, "success_p", success_p);
- req_number
- = json_object_new_int (pk_mi_msg_resp_req_number (msg));
- json_object_object_add (resp, "req_number", req_number);
+ req_id = json_object_new_int (pk_mi_msg_resp_req_id (msg));
+ json_object_object_add (resp, "req_id", req_id);
if (pk_mi_msg_resp_errmsg (msg))
{
@@ -1231,7 +1230,7 @@ static pk_mi_msg
pk_mi_json_object_to_msg (json_object *json, char** errmsg)
{
enum pk_mi_msg_kind msg_kind;
- int msg_number;
+ int msg_id;
json_object *obj, *msg_json, *args_json;
pk_mi_msg msg = NULL;
@@ -1239,13 +1238,13 @@ pk_mi_json_object_to_msg (json_object *json, char**
errmsg)
GOTO_ON_JERR (
J_NOK, failed, errmsg,"invalid message: expects JSON object");
- /* Get the message number. */
+ /* Get the message ID. */
{
json_object *number;
- GOTO_ON_JERR (jexpect (json, "seq", json_type_int, &number, errmsg),
+ GOTO_ON_JERR (jexpect (json, "id", json_type_int, &number, errmsg),
failed, errmsg, "invalid message");
- msg_number = json_object_get_int (number);
+ msg_id = json_object_get_int (number);
}
/* Get the message type. */
@@ -1270,15 +1269,19 @@ pk_mi_json_object_to_msg (json_object *json, char**
errmsg)
failed, errmsg, "invalid request message");
msg_req_type = json_object_get_int (req_type);
+ GOTO_ERR_IF (
+ !((msg_id & 1) == 1 && msg_id >= 1), failed, errmsg,
+ "invalid request message: \"id\" should be an odd number >= 1");
+
/* Create the message. */
- msg = pk_mi_make_req (msg_req_type);
+ msg = pk_mi_make_req (msg_req_type, msg_id);
break;
}
case PK_MI_MSG_RESPONSE:
{
json_object *obj;
enum pk_mi_resp_type resp_type;
- pk_mi_seqnum req_number;
+ pk_mi_id req_id;
int success_p;
const char *emsg;
@@ -1287,11 +1290,14 @@ pk_mi_json_object_to_msg (json_object *json, char**
errmsg)
failed, errmsg, "invalid response message");
resp_type = json_object_get_int (obj);
- /* Get the request number. */
+ /* Get the corresponding request ID. */
GOTO_ON_JERR (
- jexpect (msg_json, "req_number", json_type_int, &obj, errmsg),
+ jexpect (msg_json, "req_id", json_type_int, &obj, errmsg),
failed, errmsg, "invalid response message");
- req_number = json_object_get_int (obj);
+ req_id = json_object_get_int (obj);
+ GOTO_ERR_IF (
+ req_id & 1, failed, errmsg,
+ "invalid response message: \"req_id\" must be an even number");
/* Get success_p. */
GOTO_ON_JERR (
@@ -1311,8 +1317,12 @@ pk_mi_json_object_to_msg (json_object *json, char**
errmsg)
}
/* Create the message. */
+ GOTO_ERR_IF (
+ !((msg_id & 1) == 0 && msg_id >= 2), failed, errmsg,
+ "invalid response message: \"id\" should be an even number >= 2");
msg = pk_mi_make_resp (resp_type,
- req_number,
+ msg_id,
+ req_id,
success_p,
emsg);
break;
@@ -1328,7 +1338,10 @@ pk_mi_json_object_to_msg (json_object *json, char**
errmsg)
event_type = json_object_get_int (obj);
/* Create the message. */
- msg = pk_mi_make_event (event_type);
+ GOTO_ERR_IF (
+ msg_id >= 0, failed, errmsg,
+ "invalid event message: \"id\" should be a negative number");
+ msg = pk_mi_make_event_with_id (event_type, msg_id);
break;
}
default:
@@ -1346,7 +1359,7 @@ pk_mi_json_object_to_msg (json_object *json, char**
errmsg)
}
done:
- pk_mi_set_msg_number (msg, msg_number);
+ pk_mi_set_msg_id (msg, msg_id);
return msg;
failed:
diff --git a/poke/pk-mi-msg.c b/poke/pk-mi-msg.c
index c8ee2ab6..c44f7d0f 100644
--- a/poke/pk-mi-msg.c
+++ b/poke/pk-mi-msg.c
@@ -83,8 +83,7 @@ struct pk_mi_msg_req
/* Responses are initiated by poke, in response to a request received
from the client.
- REQ_NUMBER is the sequence number of the request for which this is
- a response.
+ REQ_ID is the ID of the request for which this is a response.
SUCCESS_P is the outcome of the request. A value of 0 means the
request wasn't successful. A value other than 0 means the request
@@ -99,14 +98,14 @@ struct pk_mi_msg_req
below. */
#define PK_MI_MSG_RESP_TYPE(MSG) ((MSG)->data.resp.type)
-#define PK_MI_MSG_RESP_REQ_NUMBER(MSG) ((MSG)->data.resp.req_number)
+#define PK_MI_MSG_RESP_REQ_ID(MSG) ((MSG)->data.resp.req_id)
#define PK_MI_MSG_RESP_SUCCESS_P(MSG) ((MSG)->data.resp.success_p)
#define PK_MI_MSG_RESP_ERRMSG(MSG) ((MSG)->data.resp.errmsg)
struct pk_mi_msg_resp
{
enum pk_mi_resp_type type;
- pk_mi_seqnum req_number;
+ pk_mi_id req_id;
int success_p;
char *errmsg;
};
@@ -128,14 +127,14 @@ struct pk_mi_msg_event
/* The message itself. */
-#define PK_MI_MSG_NUMBER(MSG) ((MSG)->number)
+#define PK_MI_MSG_ID(MSG) ((MSG)->id)
#define PK_MI_MSG_KIND(MSG) ((MSG)->kind)
#define PK_MI_MSG_NUM_ARGS(MSG) ((MSG)->num_args)
#define PK_MI_MSG_ARGS(MSG) ((MSG)->args)
struct pk_mi_msg
{
- pk_mi_seqnum number;
+ pk_mi_id id;
enum pk_mi_msg_kind kind;
union
@@ -153,16 +152,16 @@ typedef struct pk_mi_msg *pk_mi_msg;
/*** Variables and code ***/
-/* Global with the next available message sequence number. */
-static pk_mi_seqnum next_seqnum;
+/* Global with the next available event message ID. */
+static pk_mi_id next_event_id;
static pk_mi_msg
-pk_mi_make_msg (enum pk_mi_msg_kind kind)
+pk_mi_make_msg (enum pk_mi_msg_kind kind, pk_mi_id id)
{
pk_mi_msg msg = xmalloc (sizeof (struct pk_mi_msg));
- PK_MI_MSG_NUMBER (msg) = next_seqnum++;
+ PK_MI_MSG_ID (msg) = id;
PK_MI_MSG_KIND (msg) = kind;
PK_MI_MSG_ARGS (msg) = NULL;
@@ -190,9 +189,11 @@ pk_mi_allocate_msg_args (pk_mi_msg msg,
}
pk_mi_msg
-pk_mi_make_req (enum pk_mi_req_type type)
+pk_mi_make_req (enum pk_mi_req_type type, pk_mi_id id)
{
- pk_mi_msg msg = pk_mi_make_msg (PK_MI_MSG_REQUEST);
+ assert ((id & 1) == 1 && id >= 1);
+
+ pk_mi_msg msg = pk_mi_make_msg (PK_MI_MSG_REQUEST, id);
PK_MI_MSG_REQ_TYPE (msg) = type;
pk_mi_allocate_msg_args (msg, req_arginfo, type);
@@ -202,17 +203,21 @@ pk_mi_make_req (enum pk_mi_req_type type)
pk_mi_msg
pk_mi_make_resp (enum pk_mi_resp_type type,
- pk_mi_seqnum req_seqnum,
+ pk_mi_id id,
+ pk_mi_id req_id,
int success_p,
const char *errmsg)
{
- pk_mi_msg msg = pk_mi_make_msg (PK_MI_MSG_RESPONSE);
+ assert ((id & 1) == 0 && id >= 2);
+ assert ((req_id & 1) == 1 && req_id >= 1);
+
+ pk_mi_msg msg = pk_mi_make_msg (PK_MI_MSG_RESPONSE, id);
if (errmsg == NULL)
errmsg = "";
PK_MI_MSG_RESP_TYPE (msg) = type;
- PK_MI_MSG_RESP_REQ_NUMBER (msg) = req_seqnum;
+ PK_MI_MSG_RESP_REQ_ID (msg) = req_id;
PK_MI_MSG_RESP_SUCCESS_P (msg) = success_p;
PK_MI_MSG_RESP_ERRMSG (msg) = xstrdup (errmsg);
pk_mi_allocate_msg_args (msg, resp_arginfo, type);
@@ -223,7 +228,20 @@ pk_mi_make_resp (enum pk_mi_resp_type type,
pk_mi_msg
pk_mi_make_event (enum pk_mi_event_type type)
{
- pk_mi_msg msg = pk_mi_make_msg (PK_MI_MSG_EVENT);
+ pk_mi_msg msg = pk_mi_make_msg (PK_MI_MSG_EVENT, --next_event_id);
+
+ PK_MI_MSG_EVENT_TYPE (msg) = type;
+ pk_mi_allocate_msg_args (msg, event_arginfo, type);
+
+ return msg;
+}
+
+pk_mi_msg
+pk_mi_make_event_with_id (enum pk_mi_event_type type, pk_mi_id id)
+{
+ assert (id < 0);
+
+ pk_mi_msg msg = pk_mi_make_msg (PK_MI_MSG_EVENT, id);
PK_MI_MSG_EVENT_TYPE (msg) = type;
pk_mi_allocate_msg_args (msg, event_arginfo, type);
@@ -324,16 +342,16 @@ pk_mi_msg_kind (pk_mi_msg msg)
return PK_MI_MSG_KIND (msg);
}
-pk_mi_seqnum
-pk_mi_msg_number (pk_mi_msg msg)
+pk_mi_id
+pk_mi_msg_id (pk_mi_msg msg)
{
- return PK_MI_MSG_NUMBER (msg);
+ return PK_MI_MSG_ID (msg);
}
void
-pk_mi_set_msg_number (pk_mi_msg msg, pk_mi_seqnum number)
+pk_mi_set_msg_id (pk_mi_msg msg, pk_mi_id id)
{
- PK_MI_MSG_NUMBER (msg) = number;
+ PK_MI_MSG_ID (msg) = id;
}
enum pk_mi_req_type
@@ -354,10 +372,10 @@ pk_mi_msg_event_type (pk_mi_msg msg)
return PK_MI_MSG_EVENT_TYPE (msg);
}
-pk_mi_seqnum
-pk_mi_msg_resp_req_number (pk_mi_msg msg)
+pk_mi_id
+pk_mi_msg_resp_req_id (pk_mi_msg msg)
{
- return PK_MI_MSG_RESP_REQ_NUMBER (msg);
+ return PK_MI_MSG_RESP_REQ_ID (msg);
}
int
diff --git a/poke/pk-mi-msg.def b/poke/pk-mi-msg.def
index 42e5ab7b..ba8bdca1 100644
--- a/poke/pk-mi-msg.def
+++ b/poke/pk-mi-msg.def
@@ -106,14 +106,14 @@ PK_DEF_RESP (PRINTV, PK_DEF_ARGS (PK_DEF_ARG (string,
PK_STRING)))
Arguments:
- reqnum (uint)
- Sequence number of the invalid request.
+ reqid (uint)
+ ID of the invalid request.
errmsg (string)
Invalidity reason.
*/
PK_DEF_EVENT (INVREQ,
- PK_DEF_ARGS (PK_DEF_ARG (reqnum, PK_UINT),
+ PK_DEF_ARGS (PK_DEF_ARG (reqid, PK_INT),
PK_DEF_ARG (errmsg, PK_STRING)))
/* Cleanup. */
diff --git a/poke/pk-mi-msg.h b/poke/pk-mi-msg.h
index e2d90831..c820a67d 100644
--- a/poke/pk-mi-msg.h
+++ b/poke/pk-mi-msg.h
@@ -24,10 +24,14 @@
#include <libpoke.h> /* For pk_val */
-/* Each MI message contains a "sequence number". The protocol uses
- this number to univocally identify certain messages. */
+/* Each MI message contains an "id". Events have negative IDs.
+ Requests have odd ID values starting from 1, and responses have
+ even ID values starting from 2. ID "0" is a special case.
-typedef uint32_t pk_mi_seqnum;
+ The protocol uses this number to univocally identify certain
+ messages. */
+
+typedef int64_t pk_mi_id;
/* MI messages are of three kinds: requests, responses and events.
@@ -68,12 +72,13 @@ typedef struct pk_mi_msg *pk_mi_msg;
/* Build a new request message.
Return NULL in case there is an error. */
-pk_mi_msg pk_mi_make_req (enum pk_mi_req_type type);
+pk_mi_msg pk_mi_make_req (enum pk_mi_req_type type, pk_mi_id id);
/* Build a new response message.
- REQ_SEQNUM is the sequence number of the request that is answered
- by this response.
+ ID is the ID of the new response.
+
+ REQ_ID is the ID of the request that is answered by this response.
SUCCESS_P should be 0 if the requested operation couldn't be
performed for whatever reason.
@@ -85,7 +90,8 @@ pk_mi_msg pk_mi_make_req (enum pk_mi_req_type type);
Return NULL in case there is an error. */
pk_mi_msg pk_mi_make_resp (enum pk_mi_resp_type type,
- pk_mi_seqnum req_seqnum,
+ pk_mi_id id,
+ pk_mi_id req_id,
int success_p,
const char *errmsg);
@@ -93,6 +99,7 @@ pk_mi_msg pk_mi_make_resp (enum pk_mi_resp_type type,
Return NULL in case there is an error. */
pk_mi_msg pk_mi_make_event (enum pk_mi_event_type type);
+pk_mi_msg pk_mi_make_event_with_id (enum pk_mi_event_type type, pk_mi_id id);
/*** Getting and setting message attributes. */
@@ -100,10 +107,10 @@ pk_mi_msg pk_mi_make_event (enum pk_mi_event_type type);
enum pk_mi_msg_kind pk_mi_msg_kind (pk_mi_msg msg);
-/* Get and set the sequence number of a given message. */
+/* Get and set the ID of a given message. */
-pk_mi_seqnum pk_mi_msg_number (pk_mi_msg msg);
-void pk_mi_set_msg_number (pk_mi_msg msg, pk_mi_seqnum number);
+pk_mi_id pk_mi_msg_id (pk_mi_msg msg);
+void pk_mi_set_msg_id (pk_mi_msg msg, pk_mi_id id);
/* Get the type of a given message. Note that the given message
should be of the right kind, and this is not checked at
@@ -115,7 +122,7 @@ enum pk_mi_event_type pk_mi_msg_event_type (pk_mi_msg msg);
/* Get attributes of response messages. */
-pk_mi_seqnum pk_mi_msg_resp_req_number (pk_mi_msg msg);
+pk_mi_id pk_mi_msg_resp_req_id (pk_mi_msg msg);
int pk_mi_msg_resp_success_p (pk_mi_msg msg);
const char *pk_mi_msg_resp_errmsg (pk_mi_msg msg);
diff --git a/poke/pk-mi.c b/poke/pk-mi.c
index c0d4c5e3..d1194bde 100644
--- a/poke/pk-mi.c
+++ b/poke/pk-mi.c
@@ -273,13 +273,13 @@ pk_mi_send (pk_mi_msg msg)
static void
pk_mi_invalid_msg(pk_mi_msg msg, const char* errmsg)
{
- pk_mi_seqnum seq = msg ? pk_mi_msg_number (msg) : -1;
+ pk_mi_id id = msg ? pk_mi_msg_id (msg) : 0;
pk_mi_msg invreq_msg = pk_mi_make_event (PK_MI_EVENT_INVREQ);
if (errmsg == NULL)
errmsg = "";
- pk_mi_set_arg (invreq_msg, "reqnum", pk_make_uint (seq, 64));
+ pk_mi_set_arg (invreq_msg, "reqid", pk_make_int (id, 64));
pk_mi_set_arg (invreq_msg, "errmsg", pk_make_string (errmsg));
pk_mi_send (invreq_msg);
pk_mi_msg_free (invreq_msg);
@@ -299,9 +299,11 @@ pk_mi_dispatch_msg (pk_mi_msg msg)
{
case PK_MI_REQ_EXIT:
{
+ pk_mi_id id = pk_mi_msg_id (msg);
pk_mi_msg resp
= pk_mi_make_resp (PK_MI_RESP_EXIT,
- pk_mi_msg_number (msg),
+ id + 1,
+ id,
1 /* success_p */,
NULL /* errmsg */);
pk_mi_send (resp);
@@ -314,6 +316,7 @@ pk_mi_dispatch_msg (pk_mi_msg msg)
int ok;
pk_mi_msg resp;
pk_val arg, val;
+ pk_mi_id id = pk_mi_msg_id (msg);
arg = pk_mi_get_arg (msg, "value");
@@ -325,7 +328,7 @@ pk_mi_dispatch_msg (pk_mi_msg msg)
NULL, &val);
assert (ok == PK_OK);
- resp = pk_mi_make_resp (PK_MI_RESP_PRINTV, pk_mi_msg_number (msg),
+ resp = pk_mi_make_resp (PK_MI_RESP_PRINTV, id + 1, id,
1 /* success_p */, NULL /* errmsg */);
pk_mi_set_arg (resp, "string", val);
pk_mi_send (resp);
--
2.32.0