Commit 7b29d09d authored by Michael Gray's avatar Michael Gray
Browse files

Prep work for optionally passing timestamp down through stack from Protocol to Context.

parent e6461588
......@@ -90,21 +90,21 @@ sub close {
# client
sub send {
my ($self, $request, $request_id) = @_;
my ($self, $request, $header) = @_;
if ($request_id) {
if (my $request_id = $header->{request_id}) {
$request_id >= $self->my_request_id
or die sprintf('request_id [%d] out of sync, exp [%d]', $request_id, $self->my_request_id);
$self->my_request_id($request_id);
} else {
$request_id = $self->my_request_id;
$header->{request_id} = $self->my_request_id;
}
$self->zircon_trace("start");
my $reply;
my ($rv, $collision) = $self->context->send($request, \$reply, $request_id);
$self->my_request_id(++$request_id); # it either worked or failed hard (maybe timed out after retries)
my ($rv, $collision) = $self->context->send($request, \$reply, $header);
$self->my_request_id(++$header->{request_id}); # it either worked or failed hard (maybe timed out after retries)
my $collision_result = 'clear';
if ($collision) {
......
......@@ -259,7 +259,7 @@ sub _process_server_request {
sub platform { return 'ZMQ'; }
sub _collision_handler {
my ($self, $my_sec, $my_usec) = @_;
my ($self, $our_header) = @_;
$self->zircon_trace("collision detected!");
......@@ -269,10 +269,10 @@ sub _collision_handler {
return;
}
my $h = $self->_parse_request_header;
my $cmp = ($my_sec <=> $h->{clock_sec}
my $their_header = $self->_parse_request_header;
my $cmp = ($our_header->{clock_sec} <=> $their_header->{clock_sec}
||
$my_usec <=> $h->{clock_usec}
$our_header->{clock_usec} <=> $their_header->{clock_usec}
||
$self->local_endpoint cmp $self->remote_endpoint);
if ($cmp < 0) {
......@@ -286,15 +286,15 @@ sub _collision_handler {
}
sub send {
my ($self, $request, $reply_ref, $request_id) = @_;
my ($self, $request, $reply_ref, $conn_header) = @_;
my $error = 'unset';
my $zerr;
my ($sec, $usec) = gettimeofday;
my $header = {
%$conn_header,
msg_type => 'REQUEST',
request_id => $request_id,
clock_sec => $sec,
clock_usec => $usec,
};
......@@ -327,8 +327,8 @@ sub send {
socket => $requester,
events => ZMQ_POLLIN,
callback => sub {
my ($header, $error);
($header, $reply_msg, $error) = $self->_get_two_part($requester);
my ($reply_header, $error);
($reply_header, $reply_msg, $error) = $self->_get_two_part($requester);
warn "Zircon::Context::ZMQ::send: zmq_recvmsg failed: $error" if $error;
return;
},
......@@ -336,7 +336,7 @@ sub send {
my %server_request_pollitem = (
socket => $responder,
events => ZMQ_POLLIN,
callback => sub { return $self->_collision_handler($sec, $usec); },
callback => sub { return $self->_collision_handler($header); },
);
$self->zircon_trace('waiting for reply');
......
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