Acquire/release a POSIX file lock on repository archives.

- xbps_repo_open() accepts a third argument (bool) to acquire a POSIX file
lock on the repository archive.
- xbps_repo_close() accepts a second argument (bool) to release a POSIX file
lock on the repository archive.

This avoids the issue of multiple xbps-rindex(8) processes being blocked
even for different repositories on the same architecture, resulting in
unnecessary contention.
This commit is contained in:
Juan RP
2014-09-05 12:26:42 +02:00
parent 551555690d
commit 013731c502
13 changed files with 70 additions and 174 deletions

34
configure vendored
View File

@@ -340,40 +340,6 @@ echo "CPPFLAGS += -I\$(TOPDIR)/lib/portableproplib/prop" >>$CONFIG_MK
echo "LDFLAGS += -lpthread" >>$CONFIG_MK
echo "STATIC_LIBS += -lpthread" >>$CONFIG_MK
#
# Check for POSIX semaphores.
#
printf "Checking for POSIX semaphores ... "
func=psem
cat <<EOF > _$func.c
#include <fcntl.h>
#include <sys/stat.h>
#include <semaphore.h>
int main(void) {
sem_t *sem;
sem = sem_open("/xbps0000test", 0644, O_CREAT, 1);
sem_wait(sem);
sem_post(sem);
sem_close(sem);
sem_unlink("/xbps0000test");
return 0;
}
EOF
if $XCC -pthread -lrt _$func.c -o _$func 2>/dev/null; then
POSIXSEM=yes
echo yes.
fi
rm -f _$func.c _$func
if [ -z "$POSIXSEM" ]; then
echo "no! POSIX semaphores are required, exiting..."
exit 1
fi
echo "LDFLAGS += -lrt" >>$CONFIG_MK
echo "STATIC_LIBS += -lrt" >>$CONFIG_MK
#
# Check for vasprintf().
#