mirror of https://github.com/schoebel/mars
infra: make Lamport exchange more generic
This commit is contained in:
parent
8a062ee2db
commit
e551b6d89f
|
@ -1202,6 +1202,9 @@ int mars_send_cmd(struct mars_socket *msock, struct mars_cmd *cmd, bool cork)
|
|||
int status;
|
||||
|
||||
cmd->cmd_proto = MARS_PROTO_LEVEL;
|
||||
if (!cork || !msock->s_pos)
|
||||
get_lamport(NULL, &cmd->cmd_stamp);
|
||||
|
||||
status = desc_send_struct(msock, cmd, mars_cmd_meta, cork);
|
||||
return status;
|
||||
}
|
||||
|
@ -1214,6 +1217,8 @@ int _mars_recv_cmd(struct mars_socket *msock, struct mars_cmd *cmd, int line)
|
|||
if (status >= 0) {
|
||||
msock->s_remote_proto_level = cmd->cmd_proto;
|
||||
msock->s_common_proto_level = min(cmd->cmd_proto, MARS_PROTO_LEVEL);
|
||||
if (cmd->cmd_stamp.tv_sec)
|
||||
set_lamport_nonstrict(&cmd->cmd_stamp);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
@ -1250,9 +1255,6 @@ int _mars_send_mref(struct mars_socket *msock,
|
|||
int seq = 0;
|
||||
int status;
|
||||
|
||||
if (!cork || !msock->s_pos)
|
||||
get_lamport(NULL, &cmd->cmd_stamp);
|
||||
|
||||
if ((cmd->cmd_code & CMD_FLAG_HAS_DATA) &&
|
||||
(mref->ref_flags & MREF_COMPRESS_ANY)) {
|
||||
compr_buf = brick_mem_alloc(mref->ref_len + compress_overhead);
|
||||
|
@ -1365,9 +1367,6 @@ int mars_recv_mref(struct mars_socket *msock, struct mref_object *mref, struct m
|
|||
/* compatibility to old protocol */
|
||||
_recv_deprecated(mref);
|
||||
|
||||
if (cmd->cmd_stamp.tv_sec)
|
||||
set_lamport_nonstrict(&cmd->cmd_stamp);
|
||||
|
||||
if (cmd->cmd_compr_flags && cmd->cmd_compr_len) {
|
||||
void *decompr_buf;
|
||||
|
||||
|
|
Loading…
Reference in New Issue