summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/handle.c1
-rw-r--r--lib/libalpm/handle.h2
-rw-r--r--lib/libalpm/trans.c13
-rw-r--r--lib/libalpm/util.c7
-rw-r--r--lib/libalpm/util.h2
5 files changed, 10 insertions, 15 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 8872ed0a..d4ebe82a 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -49,7 +49,6 @@ pmhandle_t *_alpm_handle_new()
ALPM_LOG_FUNC;
CALLOC(handle, 1, sizeof(pmhandle_t), RET_ERR(PM_ERR_MEMORY, NULL));
- handle->lckfd = -1;
return(handle);
}
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index fa29d112..2d962fe6 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -34,7 +34,7 @@ typedef struct _pmhandle_t {
pmdb_t *db_local; /* local db pointer */
alpm_list_t *dbs_sync; /* List of (pmdb_t *) */
FILE *logstream; /* log file stream pointer */
- int lckfd; /* lock file descriptor if one exists */
+ FILE *lckstream; /* lock file stream pointer if one exists */
pmtrans_t *trans;
/* callback functions */
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 9d582df3..9f617967 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -73,8 +73,8 @@ int SYMEXPORT alpm_trans_init(pmtransflag_t flags,
/* lock db */
if(!(flags & PM_TRANS_FLAG_NOLOCK)) {
- handle->lckfd = _alpm_lckmk();
- if(handle->lckfd == -1) {
+ handle->lckstream = _alpm_lckmk();
+ if(handle->lckstream == NULL) {
RET_ERR(PM_ERR_HANDLE_LOCK, -1);
}
}
@@ -260,12 +260,9 @@ int SYMEXPORT alpm_trans_release()
/* unlock db */
if(!nolock_flag) {
- if(handle->lckfd != -1) {
- int fd;
- do {
- fd = close(handle->lckfd);
- } while(fd == -1 && errno == EINTR);
- handle->lckfd = -1;
+ if(handle->lckstream != NULL) {
+ fclose(handle->lckstream);
+ handle->lckstream = NULL;
}
if(_alpm_lckrm()) {
_alpm_log(PM_LOG_WARNING, _("could not remove lock file %s\n"),
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 458f750a..149a7f80 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -211,7 +211,7 @@ char *_alpm_strtrim(char *str)
}
/* Create a lock file */
-int _alpm_lckmk(void)
+FILE *_alpm_lckmk(void)
{
int fd;
char *dir, *ptr;
@@ -234,10 +234,9 @@ int _alpm_lckmk(void)
fprintf(f, "%ld\n", (long)getpid());
fflush(f);
fsync(fd);
- fclose(f);
- return(fd);
+ return(f);
}
- return(-1);
+ return(NULL);
}
/* Remove a lock file */
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 015e9bf5..930503b7 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -80,7 +80,7 @@ int _alpm_makepath(const char *path);
int _alpm_makepath_mode(const char *path, mode_t mode);
int _alpm_copyfile(const char *src, const char *dest);
char *_alpm_strtrim(char *str);
-int _alpm_lckmk(void);
+FILE *_alpm_lckmk(void);
int _alpm_lckrm(void);
int _alpm_unpack_single(const char *archive, const char *prefix, const char *fn);
int _alpm_unpack(const char *archive, const char *prefix, alpm_list_t *list, int breakfirst);