X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=keydb_db4.c;h=369788ea6133c06f92d2b4567be8693f65a8984e;hb=b2f2bc60555e2d953069c40d8d3cdecfcec9ac29;hp=b36ce3f65dba9e18408c0b86c6e6f35c72600f6b;hpb=1a084272fd5c603f318d2c4dc0c70b2de0606f04;p=onak.git diff --git a/keydb_db4.c b/keydb_db4.c index b36ce3f..369788e 100644 --- a/keydb_db4.c +++ b/keydb_db4.c @@ -169,6 +169,7 @@ static int db4_upgradedb(struct onak_db4_dbctx *privctx) char buf[1024]; int lockfile_fd; struct stat statbuf; + ssize_t written; snprintf(buf, sizeof(buf) - 1, "%s/%s", config.db_dir, DB4_UPGRADE_FILE); @@ -184,8 +185,16 @@ static int db4_upgradedb(struct onak_db4_dbctx *privctx) } } snprintf(buf, sizeof(buf) - 1, "%d", getpid()); - write(lockfile_fd, buf, strlen(buf)); + written = write(lockfile_fd, buf, strlen(buf)); close(lockfile_fd); + if (written != strlen(buf)) { + logthing(LOGTHING_CRITICAL, "Couldn't write PID to lockfile: " + "%s", strerror(errno)); + snprintf(buf, sizeof(buf) - 1, "%s/%s", config.db_dir, + DB4_UPGRADE_FILE); + unlink(buf); + return -1; + } logthing(LOGTHING_NOTICE, "Upgrading DB4 database"); ret = db_env_create(&privctx->dbenv, 0);