Update to latest git, drop merged #686 patch

f38
Adam Williamson 8 years ago
parent 5b79c317d5
commit 728bfd1b7f

1
.gitignore vendored

@ -13,3 +13,4 @@
/os-autoinst-db6d2ef529c4cb61ca88f1730798fdb365fb462f.tar.gz
/os-autoinst-3050cfaa60c3d8d3a222fcb6526ade02dc735177.tar.gz
/os-autoinst-26171f41d6cab38e8707f2109663cb14e82a8e9a.tar.gz
/os-autoinst-84d91e68eb2d54f4967ccedb56f85a332ffbcbf3.tar.gz

@ -1,57 +0,0 @@
From 93bda02b786f73acc8c109aa7f1616872980b735 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Wed, 4 Jan 2017 09:46:28 -0800
Subject: [PATCH] Use `flock` not `fcntl` locking for portability (POO #13822)
The structure used by `fcntl` to define the type, location, and
length of the desired lock uses integer types - `off_t` and
`pid_t` - that are platform dependent. When writing C you can
just create a structure using those types, but when writing perl,
there doesn't seem to be any terribly easy way to find out what
`off_t` and `pid_t` actually are, in `pack()` terms. There's a
fairly good discussion here:
https://www.perlmonks.org/bare/index.pl?node_id=920008
The code we currently have will work only on platforms where
`off_t` happens to be a signed quad and `pid_t` happens to be
a signed long. This seems to be the case for Fedora and SUSE
64-bit arches, but certainly isn't the case for Fedora 32-bit
arches (where `off_t` is a signed long instead), and it may
differ in other scenarios too.
So I suggest we just use perl `flock` to lock the file before
writing instead. I've looked into it quite a lot, and AFAICS,
none of the differences between `fcntl` and `flock` should be a
problem for us. I don't think `vars.json` is ever likely to be
on an NFS share (`flock` doesn't work over NFS), we don't need
to lock a specific area of the file, and the fact that flock is
an advisory file descriptor lock rather than a filesystem lock
record should not be a problem, as AFAICS, this is the *only*
code we ever use to write to `vars.json`, and it will certainly
respect its own lock.
---
bmwqemu.pm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/bmwqemu.pm b/bmwqemu.pm
index 4f12b30..e07b5ae 100755
--- a/bmwqemu.pm
+++ b/bmwqemu.pm
@@ -19,6 +19,7 @@ use strict;
use warnings;
use Time::HiRes qw(sleep gettimeofday);
use IO::Socket;
+use Fcntl ':flock';
use Thread::Queue;
use POSIX;
@@ -80,7 +81,7 @@ sub save_vars() {
my $fn = "vars.json";
unlink "vars.json" if -e "vars.json";
open(my $fd, ">", $fn);
- fcntl($fd, F_SETLKW, pack('ssqql', F_WRLCK, 0, 0, 0, $$)) or die "cannot lock vars.json: $!\n";
+ flock($fd, LOCK_EX) or die "cannot lock vars.json: $!\n";
truncate($fd, 0) or die "cannot truncate vars.json: $!\n";
# make sure the JSON is sorted

@ -24,24 +24,20 @@
%global github_owner os-autoinst
%global github_name os-autoinst
%global github_version 4.4
%global github_commit 26171f41d6cab38e8707f2109663cb14e82a8e9a
%global github_commit 84d91e68eb2d54f4967ccedb56f85a332ffbcbf3
# if set, will be a post-release snapshot build, otherwise a 'normal' build
%global github_date 20170103
%global github_date 20170104
%global shortcommit %(c=%{github_commit}; echo ${c:0:7})
Name: os-autoinst
Version: %{github_version}
Release: 11%{?github_date:.%{github_date}git%{shortcommit}}%{?dist}
Release: 12%{?github_date:.%{github_date}git%{shortcommit}}%{?dist}
Summary: OS-level test automation
License: GPLv2+
Group: Development/System
URL: https://os-autoinst.github.io/openQA/
Source0: https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{github_name}-%{github_commit}.tar.gz
# Use portable flock not platform-specific fcntl locking
# Fixes for 32-bit arches
Patch0: https://github.com/os-autoinst/os-autoinst/pull/686.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: gcc-c++
@ -202,6 +198,9 @@ make check VERBOSE=1
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/org.opensuse.os_autoinst.switch.conf
%changelog
* Wed Jan 04 2017 Adam Williamson <awilliam@redhat.com> - 4.4-12.20170104git84d91e6
- Update to latest git, drop merged #686 patch
* Wed Jan 04 2017 Adam Williamson <awilliam@redhat.com> - 4.4-11.20170103git26171f4
- Backport #686 to fix os-autoinst on 32-bit arches, re-enable them

@ -1 +1 @@
SHA512 (os-autoinst-26171f41d6cab38e8707f2109663cb14e82a8e9a.tar.gz) = 42be0bd2dc60f2e61b1408c3889a65793349baa9ae8bb9b32e21df9c50c6c8c778e20ecc721ebd9afdb80a798908438262ea7f3206274f41537859f0c36d5911
SHA512 (os-autoinst-84d91e68eb2d54f4967ccedb56f85a332ffbcbf3.tar.gz) = 3bc5de67678cc6a071097bd0d0805e335eac2e8d88684b5a89d16b967a7f59a43221d0acdb72b361091bdd78512bf799395081f481a90bb65dab685bace0d89d

Loading…
Cancel
Save