Bladeren bron

libdpkg: Change file_unlock() to act directly on its new arguments

This switches the function from unlocking the file via the popped
cleanup to do the action itself.
Guillem Jover 15 jaren geleden
bovenliggende
commit
943de6c0e0
3 gewijzigde bestanden met toevoegingen van 14 en 12 verwijderingen
  1. 2 1
      lib/dpkg/dbmodify.c
  2. 11 10
      lib/dpkg/file.c
  3. 1 1
      lib/dpkg/file.h

+ 2 - 1
lib/dpkg/dbmodify.c

@@ -196,7 +196,8 @@ modstatdb_lock(const char *admindir)
 void
 void
 modstatdb_unlock(void)
 modstatdb_unlock(void)
 {
 {
-  file_unlock();
+  /* Unlock. */
+  pop_cleanup(ehflag_normaltidy);
 }
 }
 
 
 enum modstatdb_rw
 enum modstatdb_rw

+ 11 - 10
lib/dpkg/file.c

@@ -69,11 +69,12 @@ file_lock_setup(struct flock *fl, short type)
 	fl->l_pid = 0;
 	fl->l_pid = 0;
 }
 }
 
 
-static void
-file_unlock_cleanup(int argc, void **argv)
+/**
+ * Unlock a previously locked file.
+ */
+void
+file_unlock(int lockfd, const char *lock_desc)
 {
 {
-	int lockfd = *(int*)argv[0];
-	const char *lock_desc = argv[1];
 	struct flock fl;
 	struct flock fl;
 
 
 	assert(lockfd >= 0);
 	assert(lockfd >= 0);
@@ -84,13 +85,13 @@ file_unlock_cleanup(int argc, void **argv)
 		ohshite(_("unable to unlock %s"), lock_desc);
 		ohshite(_("unable to unlock %s"), lock_desc);
 }
 }
 
 
-/**
- * Unlock a previously locked file.
- */
-void
-file_unlock(void)
+static void
+file_unlock_cleanup(int argc, void **argv)
 {
 {
-	pop_cleanup(ehflag_normaltidy); /* Calls file_unlock_cleanup. */
+	int lockfd = *(int *)argv[0];
+	const char *lock_desc = argv[1];
+
+	file_unlock(lockfd, lock_desc);
 }
 }
 
 
 /**
 /**

+ 1 - 1
lib/dpkg/file.h

@@ -46,7 +46,7 @@ enum file_lock_flags {
 bool file_is_locked(int lockfd, const char *filename);
 bool file_is_locked(int lockfd, const char *filename);
 void file_lock(int *lockfd, enum file_lock_flags flags, const char *filename,
 void file_lock(int *lockfd, enum file_lock_flags flags, const char *filename,
                const char *desc);
                const char *desc);
-void file_unlock(void);
+void file_unlock(int fd, const char *desc);
 
 
 DPKG_END_DECLS
 DPKG_END_DECLS