Changeset 866


Ignore:
Timestamp:
May 22, 2014, 12:01:24 PM (11 years ago)
Author:
Silvan Scherrer
Message:

SambaServer: better version for creating AL files

Location:
trunk/server/lib/tdb/common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/lib/tdb/common/io.c

    r857 r866  
    110110                upgradeLockRC = tdb_brlock(tdb, F_WRLCK, off, len, TDB_LOCK_NOWAIT);
    111111        }
     112        // no need to log a successful upgrade
     113        if (upgradeLockRC != 0)
    112114        TDB_LOG((tdb, TDB_DEBUG_TRACE,"upgrading lock at %d len=%d "
    113115                "before writing %s (rc=%d).\n", off, len,
  • trunk/server/lib/tdb/common/open.c

    r865 r866  
    304304
    305305#ifdef __OS2__
    306         if (os2_crtActiveLock(tdb, name, 1, mode) != 0)
     306        if (os2_crtActiveLock(tdb, name, "tdb_open_ex") != 0)
    307307                goto fail;
    308308#endif
     
    623623        tdb->hActiveLock = -1;
    624624
    625         if (os2_crtActiveLock(tdb, tdb->name, 0, 0) != 0)
     625        if (os2_crtActiveLock(tdb, tdb->name, "tdb_reopen") != 0)
    626626                goto fail;
    627627#endif
     
    680680}
    681681#ifdef __OS2__
    682 int os2_crtActiveLock(struct tdb_context *tdb, const char *name, const int truncate, const int mode)
     682int os2_crtActiveLock(struct tdb_context *tdb, const char *name, const char *origin)
    683683{
    684684        // name could be null, so handle it
     
    686686                return 0;
    687687
     688        struct stat st;
     689        bool emptytdb = false;
    688690        char activeLockName[_MAX_PATH];
     691        char *emptyString = "used for active lock\n\0";
    689692        sprintf(activeLockName, "%s_AL", name);
     693
     694        if ((stat(activeLockName, &st) == -1) || (st.st_size < strlen(emptyString)))
     695                emptytdb = true;
     696
    690697        tdb->hActiveLock = open(activeLockName, tdb->open_flags | O_CREAT, 0777);
    691698        if (tdb->hActiveLock == -1) {
    692699                TDB_LOG((tdb, TDB_DEBUG_ERROR, "os2_crtActiveLock: cannot create activeLock %s called from %s %s\n",
    693                         activeLockName, truncate?"tdb_open_ex":"tdb_reopen", strerror(errno)));
     700                        activeLockName, origin, strerror(errno)));
    694701                errno = EINVAL;
    695702                return -1;
     
    698705        // we try to truncate the db when called from tdb_open_ex
    699706        // but if it's not working it's ok as well
    700         if (truncate) {
    701                 if (lseek(tdb->hActiveLock, 0, SEEK_SET) == -1)
    702                         return 0;
    703 
    704                 if (ftruncate(tdb->hActiveLock, 0) == -1)
    705                         return 0;
    706 
    707                 tdb_write_all(tdb->hActiveLock, "used for active lock\n", 21);
    708         }
     707        if (emptytdb)
     708                tdb_write_all(tdb->hActiveLock, emptyString, strlen(emptyString));
    709709
    710710        return 0;
Note: See TracChangeset for help on using the changeset viewer.