update.sh: pre-compute list of changed refs before nc_openbsd
commitbb78563d07240b8a87850e567e300f75b0045522
authorKyle J. McKay <mackyle@gmail.com>
Tue, 6 Oct 2015 23:47:00 +0000 (6 16:47 -0700)
committerKyle J. McKay <mackyle@gmail.com>
Tue, 6 Oct 2015 23:47:00 +0000 (6 16:47 -0700)
tree2862867a45644a3da6ef77e1f2098c9155b8e466
parent3bef9bf124c676c71e64456f75b9e84d0820f345
update.sh: pre-compute list of changed refs before nc_openbsd

For some repositories with many refs (some might consider that many
refs an abuse of Git -- I'm looking at YOU Gerrit), the process of
joining the before refs and after refs files and reading all the
results (even though many lines may show no ref change) can actually
take several seconds to complete.

With the recent change to send the refs to taskd.pl all in one go
using one "ref-changes" message instead of individual "ref-change"
messages, it's possible for the join + read delay to exceed the
timeout given to nc_openbsd resulting in a prematurely closed
connection and failure to send out those ref updates.

Instead of arbitrarily increasing the timeout delay (which will only
stave off the problem until an even more abusive repository comes
along), pre-compute the change list before opening the connection
to the socket.

Additionally, use sed to filter out the unchanged refs (which it can
do substantially faster than the shell script) to further decrease
the processing time.

Also switch the refs files delimiter from tab to space to make the
files easier to deal with since a literal tab is awkward and not
obvious in the quoted strings used with git and sed.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
jobd/update.sh