start time, or the start time of the most recent flight which refers
to them.
-Flights can be protected (preserved) by allocating them somehow:
+Flights can be protected (preserved) by allocating them with
+./mg-allocate F/<flight>.
+
Flights are represented by restype='share-flight' entries in the
-resources table.
+resources table. Conventionally, the shareix is the owning taskid.
+This allows multiple tasks to lock a single flight. There is no
+corresponding entry with restype='flight', nor a resource_sharing
+entry. mg-allocate will create and clean up share-flight entries as
+needed.
DETAILED PROTOCOL NOTES
# <resource-spec> syntax:
# [!][<type>/]<name>[/<share>] type defaults to 'host'
# type=='S' means 'shared-host'
+# type=='F' means 'shared-flight'
# share defaults to *
# "!" prefix means deallocate
# name=option|option|... means
$restype= 'share-host' if $restype eq 'S';
my $resname= $3;
my $shareix= $4;
+
+ if ($restype eq 'F') {
+ die unless $resname =~ m/^\d+$/;
+ die unless $resname eq $resname+0;
+ die if defined $shareix;
+ die if $donate_spec;
+ die if @steal_specs;
+ $restype = 'share-flight';
+ $shareix = $tid;
+ }
+
$shareix= defined($shareix) ? $shareix+0 : '*';
my $shareixcond = $shareix eq '*' ? '' : "AND shareix = $shareix";
my ($res, $rescand) = @_;
my ($allocate, $restype, $resname, $shareix, $shareixcond) = @$rescand;
+ if ($allocate && $restype eq 'share-flight' && $shareix == $tid) {
+ $dbh_tests->do(<<END,{},
+ INSERT INTO resources
+ (SELECT ? AS restype,
+ ? AS resname,
+ ? AS shareix,
+ ? AS owntaskid
+ WHERE NOT EXISTS
+ (SELECT 1 FROM resources
+ WHERE restype=?
+ AND resname=?
+ AND shareix=?))
+END
+ $restype,$resname,$shareix, $magictask{idle},
+ $restype,$resname,$shareix);
+ }
+
my $resq= $dbh_tests->prepare(<<END);
SELECT * FROM resources r
JOIN tasks t
logm("$desc: freeing");
}
$setres->($donate_taskid // $magictask{idle});
+ if ($restype eq 'share-flight' && $shareix == $tid) {
+ $dbh_tests->do(<<END,{},
+ DELETE FROM resources
+ WHERE restype = ?
+ AND resname = ?
+ AND shareix = ?
+ AND owntaskid = ?
+END
+ $restype,$resname,$shareix, $magictask{idle});
+ }
}
if ($isshared) {