/ Check-in [af7abebe]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enhancements to the vfslog.c module to show all change-counter changes and to show the hostname and pid of the process that creates each log file.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: af7abebeb1f70466833bc766d294d721eaef746f
User & Date: drh 2013-10-10 15:04:52
Context
2013-10-10
17:33
Add a rule to the main.mk makefile for building showdb. check-in: fc5552da user: drh tags: trunk
15:04
Enhancements to the vfslog.c module to show all change-counter changes and to show the hostname and pid of the process that creates each log file. check-in: af7abebe user: drh tags: trunk
13:41
Another fix to the hash signature algorithm in vfslog.c. check-in: 34212aa8 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/misc/vfslog.c.

   235    235   ** Open a VLogLog object on the given file
   236    236   */
   237    237   static VLogLog *vlogLogOpen(const char *zFilename){
   238    238     int nName = (int)strlen(zFilename);
   239    239     int isJournal = 0;
   240    240     sqlite3_mutex *pMutex;
   241    241     VLogLog *pLog, *pTemp;
          242  +  sqlite3_int64 tNow = 0;
   242    243     if( nName>4 && strcmp(zFilename+nName-4,"-wal")==0 ){
   243    244       return 0;  /* Do not log wal files */
   244    245     }else
   245    246     if( nName>8 && strcmp(zFilename+nName-8,"-journal")==0 ){
   246    247       nName -= 8;
   247    248       isJournal = 1;
   248    249     }else if( nName>12 
................................................................................
   259    260       }
   260    261     }
   261    262     if( pLog==0 ){
   262    263       pLog = pTemp;
   263    264       pTemp = 0;
   264    265       memset(pLog, 0, sizeof(*pLog)*2);
   265    266       pLog->zFilename = (char*)&pLog[2];
          267  +    tNow = vlog_time();
   266    268       sqlite3_snprintf(nName+60, pLog->zFilename, "%.*s-debuglog-%lld",
   267         -                     nName, zFilename, vlog_time());
          269  +                     nName, zFilename, tNow);
   268    270       pLog->out = fopen(pLog->zFilename, "a");
   269    271       if( pLog->out==0 ){
   270    272         sqlite3_mutex_leave(pMutex);
   271    273         sqlite3_free(pLog);
   272    274         return 0;
   273    275       }
   274    276       pLog->nFilename = nName;
................................................................................
   275    277       pLog[1].out = pLog[0].out;
   276    278       pLog->ppPrev = &allLogs;
   277    279       if( allLogs ) allLogs->ppPrev = &pLog->pNext;
   278    280       pLog->pNext = allLogs;
   279    281       allLogs = pLog;
   280    282     }
   281    283     sqlite3_mutex_leave(pMutex);
   282         -  sqlite3_free(pTemp);
          284  +  if( pTemp ){
          285  +    sqlite3_free(pTemp);
          286  +  }else{
          287  +    char zHost[200];
          288  +    zHost[0] = 0;
          289  +    gethostname(zHost, sizeof(zHost)-1);
          290  +    zHost[sizeof(zHost)-1] = 0;
          291  +    vlogLogPrint(pLog, tNow, 0, "IDENT", getpid(), -1, zHost, 0);
          292  +  }
   283    293     if( pLog && isJournal ) pLog++;
   284    294     pLog->nRef++;
   285    295     return pLog;
   286    296   }
   287    297   
   288    298   
   289    299   /*
................................................................................
   350    360     tElapse = vlog_time() - tStart;
   351    361     if( rc==SQLITE_OK ){
   352    362       vlogSignature(zBuf, iAmt, zSig);
   353    363     }else{
   354    364       zSig[0] = 0;
   355    365     }
   356    366     vlogLogPrint(p->pLog, tStart, tElapse, "READ", iAmt, iOfst, zSig, rc);
          367  +  if( rc==SQLITE_OK
          368  +   && p->pLog
          369  +   && p->pLog->zFilename
          370  +   && iOfst<=24
          371  +   && iOfst+iAmt>=28
          372  +  ){
          373  +    unsigned char *x = ((unsigned char*)zBuf)+(24-iOfst);
          374  +    unsigned iCtr;
          375  +    iCtr = (x[0]<<24) + (x[1]<<16) + (x[2]<<8) + x[3];
          376  +    vlogLogPrint(p->pLog, tStart, 0, "CHNGCTR-READ", iCtr, -1, 0, 0);
          377  +  }
   357    378     return rc;
   358    379   }
   359    380   
   360    381   /*
   361    382   ** Write data to an vlog-file.
   362    383   */
   363    384   static int vlogWrite(
................................................................................
   372    393     char zSig[40];
   373    394   
   374    395     tStart = vlog_time();
   375    396     vlogSignature((unsigned char*)z, iAmt, zSig);
   376    397     rc = p->pReal->pMethods->xWrite(p->pReal, z, iAmt, iOfst);
   377    398     tElapse = vlog_time() - tStart;
   378    399     vlogLogPrint(p->pLog, tStart, tElapse, "WRITE", iAmt, iOfst, zSig, rc);
          400  +  if( rc==SQLITE_OK
          401  +   && p->pLog
          402  +   && p->pLog->zFilename
          403  +   && iOfst<=24
          404  +   && iOfst+iAmt>=28
          405  +  ){
          406  +    unsigned char *x = ((unsigned char*)z)+(24-iOfst);
          407  +    unsigned iCtr;
          408  +    iCtr = (x[0]<<24) + (x[1]<<16) + (x[2]<<8) + x[3];
          409  +    vlogLogPrint(p->pLog, tStart, 0, "CHNGCTR-WRITE", iCtr, -1, 0, 0);
          410  +  }
   379    411     return rc;
   380    412   }
   381    413   
   382    414   /*
   383    415   ** Truncate an vlog-file.
   384    416   */
   385    417   static int vlogTruncate(sqlite3_file *pFile, sqlite_int64 size){