summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2014-08-05 09:27:15 -0400
committerAnthony G. Basile <blueness@gentoo.org>2014-08-05 09:27:15 -0400
commit96f70f054ef7148a4f952cdb62bf57c8a5486f1f (patch)
treebb537ceacb878e6e47da4035349239bf07338065
parent60728b7c1262b5f1ea4307e3b22597ef8eb869a9 (diff)
src/collect/collect.c: remove excessive error reporting
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
-rw-r--r--src/collect/collect.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/collect/collect.c b/src/collect/collect.c
index 05d6517a54..323d56a82d 100644
--- a/src/collect/collect.c
+++ b/src/collect/collect.c
@@ -87,8 +87,6 @@ static void usage(void)
* prepare
*
* Prepares the database file
- * returns file descriptor on success
- * returns errno on failure
*/
static int prepare(char *dir, char *filename)
{
@@ -102,22 +100,21 @@ static int prepare(char *dir, char *filename)
snprintf(buf, sizeof(buf), "%s/%s", dir, filename);
fd = open(buf,O_RDWR|O_CREAT|O_CLOEXEC, S_IRUSR|S_IWUSR);
- if (fd < 0) {
+ if (fd < 0)
fprintf(stderr, "Cannot open %s: %m\n", buf);
- return errno;
- }
+
if (lockf(fd,F_TLOCK,0) < 0) {
if (debug)
- fprintf(stderr, "Lock aquisition failed, retry in %d seconds\n"
- , UDEV_ALARM_TIMEOUT);
- alarm(UDEV_ALARM_TIMEOUT);
- if(lockf(fd, F_LOCK, 0)<0){
+ fprintf(stderr, "Lock taken, wait for %d seconds\n", UDEV_ALARM_TIMEOUT);
+ if (errno == EAGAIN || errno == EACCES) {
+ alarm(UDEV_ALARM_TIMEOUT);
+ lockf(fd, F_LOCK, 0);
+ if (debug)
+ fprintf(stderr, "Acquired lock on %s\n", buf);
+ } else {
if (debug)
fprintf(stderr, "Could not get lock on %s: %m\n", buf);
- return errno;
- }
- if (debug)
- fprintf(stderr, "Acquired lock on %s\n", buf);
+ }
}
return fd;
@@ -483,16 +480,10 @@ int main(int argc, char **argv)
kickout();
lseek(fd, 0, SEEK_SET);
- if(ftruncate(fd, 0)!=0) {
- ret = errno;
- goto out;
- }
+ ftruncate(fd, 0);
ret = missing(fd);
- if(lockf(fd, F_ULOCK, 0) !=0 ) {
- ret = errno;
- goto out;
- }
+ lockf(fd, F_ULOCK, 0);
close(fd);
out:
if (debug)