From 5ea4706f57e15de23a5fd36eff3bc4619aeac224 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 28 Feb 2011 10:43:36 -0600 Subject: Move locking functions to where they are needed We only call these from the transaction init and teardown, so move them to that file, mark them static, and push more of the logic of handle manipulation into these functions. Signed-off-by: Dan McGee --- lib/libalpm/util.c | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'lib/libalpm/util.c') diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 149a7f80..9281f0e6 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -210,45 +209,6 @@ char *_alpm_strtrim(char *str) return(str); } -/* Create a lock file */ -FILE *_alpm_lckmk(void) -{ - int fd; - char *dir, *ptr; - const char *file = alpm_option_get_lockfile(); - - /* create the dir of the lockfile first */ - dir = strdup(file); - ptr = strrchr(dir, '/'); - if(ptr) { - *ptr = '\0'; - } - _alpm_makepath(dir); - FREE(dir); - - do { - fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0000); - } while (fd == -1 && errno == EINTR); - if(fd > 0) { - FILE *f = fdopen(fd, "w"); - fprintf(f, "%ld\n", (long)getpid()); - fflush(f); - fsync(fd); - return(f); - } - return(NULL); -} - -/* Remove a lock file */ -int _alpm_lckrm(void) -{ - const char *file = alpm_option_get_lockfile(); - if(unlink(file) == -1 && errno != ENOENT) { - return(-1); - } - return(0); -} - /* Compression functions */ /** -- cgit v1.2.3-24-g4f1b