Browse Source

[Fix] Fix another locking issue in sqlite

tags/1.3.1
Vsevolod Stakhov 8 years ago
parent
commit
81de74b003
1 changed files with 5 additions and 14 deletions
  1. 5
    14
      src/libutil/sqlite_utils.c

+ 5
- 14
src/libutil/sqlite_utils.c View File

@@ -212,21 +212,13 @@ rspamd_sqlite3_wait (rspamd_mempool_t *pool, const gchar *lock)
.tv_nsec = 1000000
};

fd = open (lock, O_RDONLY);

if (fd == -1) {
while ((fd = open (lock, O_WRONLY|O_CREAT|O_EXCL, 00600)) == -1) {
if (errno != EBUSY && errno != EEXIST) {
msg_err_pool_check ("cannot open lock file %s: %s", lock,
strerror (errno));

if (errno == ENOENT) {
/* Lock is already released, so we can continue */
return TRUE;
return FALSE;
}

msg_err_pool_check ("cannot open lock file %s: %s", lock, strerror (errno));

return FALSE;
}

while (!rspamd_file_lock (fd, TRUE)) {
if (nanosleep (&sleep_ts, NULL) == -1 && errno != EINTR) {
close (fd);
msg_err_pool_check ("cannot sleep open lock file %s: %s", lock,
@@ -236,7 +228,6 @@ rspamd_sqlite3_wait (rspamd_mempool_t *pool, const gchar *lock)
}
}

rspamd_file_unlock (fd, FALSE);
unlink (lock);
close (fd);


Loading…
Cancel
Save