Commit bfe79b9d authored by Michael Gray's avatar Michael Gray
Browse files

Z:Protocol->zircon_connection_request() now replies with same timestamp in header and message.

parent 533f4484
......@@ -155,7 +155,7 @@ sub _server_callback {
$self->zircon_trace('start (req %d/%d, collision: %s)', $request_id, $attempt, $collision_result // 'none');
$self->zircon_trace("request: '%s'", $request);
my $reply;
my ($reply, $headers);
my $rrid = $self->remote_request_id;
if ($attempt > 1 and $rrid and $rrid == $request_id and $self->last_reply) {
......@@ -165,14 +165,14 @@ sub _server_callback {
} else {
# Not seen this request before
warn "Out of sequence: last ${rrid}, this ${request_id}" if ($rrid and $request_id <= $rrid);
$reply = $self->handler->zircon_connection_request($request, $collision_result);
($reply, $headers) = $self->handler->zircon_connection_request($request, $collision_result);
$self->remote_request_id($request_id);
$self->last_reply($reply);
}
$self->zircon_trace('finish');
return $reply;
return ($reply, $headers);
}
# endpoints
......
......@@ -235,10 +235,16 @@ sub _process_server_request {
my $request_header = $self->_parse_request_header;
my $reply = $self->_request_callback->($self->_request_body, $request_header, $collision_result);
my ($reply, $headers) = $self->_request_callback->($self->_request_body, $request_header, $collision_result);
$self->zircon_trace("reply: '%s'", $reply // '<undef>');
my $timestamp = Zircon::Timestamp->timestamp;
my $timestamp = {};
if (exists $headers->{clock_sec} and exists $headers->{clock_usec}) {
map { $timestamp->{$_} = $headers->{$_} } qw( clock_sec clock_usec );
} else {
$timestamp = Zircon::Timestamp->timestamp;
}
my $reply_header = {
msg_type => 'REPLY',
request_id => $request_header->{request_id},
......
......@@ -188,11 +188,16 @@ sub send_command {
sub zircon_connection_request {
my ($self, $raw_request) = @_;
my ($request_id, $app_id, $command, $view, $request) =
@{$self->serialiser->parse_request($raw_request)};
my $reply = $self->_request($command, $view, $request, $app_id);
my $serialised = $self->serialiser->serialise_reply($request_id, $command, $reply);
return $serialised;
my $timestamp = Zircon::Timestamp->timestamp;
my $serialised = $self->serialiser->serialise_reply($request_id, $command, $reply, $timestamp);
return ($serialised, $timestamp);
}
sub _request {
......
......@@ -81,7 +81,7 @@ sub serialise_request {
}
sub serialise_reply {
my ($self, $request_id, $command, $reply) = @_;
my ($self, $request_id, $command, $reply, $timestamp) = @_;
my ($status, @reply_body) = @{$reply};
my ($return_code, $reason) =
defined $status ? @{$status} : ( 'ok' );
......@@ -109,7 +109,7 @@ sub serialise_reply {
'app_id' => $app_id,
'socket_id' => $socket_id,
'request_id' => $request_id,
$self->_timestamp,
$self->_timestamp($timestamp),
}, $reply_element);
return $self->finalise_element($protocol_element);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment