[Swift-commit] cog r3456
swift at ci.uchicago.edu
swift at ci.uchicago.edu
Fri Aug 17 14:55:45 CDT 2012
------------------------------------------------------------------------
r3456 | hategan | 2012-08-17 14:49:16 -0500 (Fri, 17 Aug 2012) | 1 line
make sure queued data is sent on shutdown (otherwise shutdown acknowledgements never make it to the service)
------------------------------------------------------------------------
Index: modules/provider-coaster/resources/worker.pl
===================================================================
--- modules/provider-coaster/resources/worker.pl (revision 3455)
+++ modules/provider-coaster/resources/worker.pl (working copy)
@@ -966,27 +966,32 @@
if ($wset && @$wset) {
# can write
wlog(DEBUG, "Can write\n");
- my $wouldBlock;
- # if last write didn't finish, try to finish it now
- $wouldBlock = resumeSend();
-
- if (!$wouldBlock) {
- my $cmd;
- # send whatever is now queued; don't clear the queue, since
- # things may be added to it while stuff is being sent
- my $sz = scalar(@SENDQ);
- wlog(DEBUG, "SENDQ size: $sz\n");
- for (my $i = 0; $i < $sz; $i++) {
- $cmd = shift(@SENDQ);
- $wouldBlock = sendInternal(@$cmd);
- if ($wouldBlock) {
- last;
- }
+ sendQueued();
+ }
+}
+
+sub sendQueued {
+ my $wouldBlock;
+ # if last write didn't finish, try to finish it now
+ $wouldBlock = resumeSend();
+
+ if (!$wouldBlock) {
+ my $cmd;
+ # send whatever is now queued; don't clear the queue, since
+ # things may be added to it while stuff is being sent
+ my $sz = scalar(@SENDQ);
+ wlog(DEBUG, "SENDQ size: $sz\n");
+ for (my $i = 0; $i < $sz; $i++) {
+ $cmd = shift(@SENDQ);
+ $wouldBlock = sendInternal(@$cmd);
+ if ($wouldBlock) {
+ last;
}
}
}
}
+
sub printreply {
my ($tag, $timeout, $err, $fin, $reply) = @_;
if ($timeout) {
@@ -1072,15 +1077,17 @@
my ($tag, $timeout, $msgs) = @_;
wlog DEBUG, "Shutdown command received\n";
queueReply($tag, ("OK"));
+ sendQueued();
wlog INFO, "Acknowledged shutdown.\n";
wlog INFO, "Ran a total of $JOB_COUNT jobs\n";
if ($PROFILE) {
push(@PROFILE_EVENTS, "STOP", "N/A", time());
}
writeprofile();
+
select(undef, undef, undef, 1);
wlog INFO, "Exiting\n";
-
+
exit 0;
}
More information about the Swift-commit
mailing list