Diff for /freem/src/global_bltin.c between versions 1.19 and 1.20

version 1.19, 2025/04/11 16:52:05 version 1.20, 2025/04/11 18:24:32
Line 24 Line 24
  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.   *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
  *   *
  *   $Log$   *   $Log$
    *   Revision 1.20  2025/04/11 18:24:32  snw
    *   Fix bug in memory cache
    *
  *   Revision 1.19  2025/04/11 16:52:05  snw   *   Revision 1.19  2025/04/11 16:52:05  snw
  *   Fix indentation in global handler   *   Fix indentation in global handler
  *   *
Line 499  int gbl_read_block(global_handle *g, uns Line 502  int gbl_read_block(global_handle *g, uns
   
     g->use_count++;      g->use_count++;
   
     fstat (g->fd, &gstat);      
     if (!g->locked) gbl_lock (g, 1);      if (!g->locked) gbl_lock (g, 1);
                   fstat (g->fd, &gstat);                
           
     if ((g->last_block == blocknum) &&      if ((g->last_block == blocknum) &&
         (g->have_cached_block) &&          (g->have_cached_block) &&
Line 509  int gbl_read_block(global_handle *g, uns Line 511  int gbl_read_block(global_handle *g, uns
         (gstat.st_mtime < g->last_read_time)) {                  (gstat.st_mtime < g->last_read_time)) {        
         /* the global has not been modified since the last read; grab from memory */          /* the global has not been modified since the last read; grab from memory */
         g->memory_reads++;          g->memory_reads++;
         g->last_read_time = time (0L);  
         memcpy (block, g->last_block_accessed, g->header.block_size);                memcpy (block, g->last_block_accessed, g->header.block_size);      
     }      }
     else {      else {
Line 520  int gbl_read_block(global_handle *g, uns Line 521  int gbl_read_block(global_handle *g, uns
         /* update cache */          /* update cache */
         memcpy (g->last_block_accessed, block, g->header.block_size);          memcpy (g->last_block_accessed, block, g->header.block_size);
         g->have_cached_block = TRUE;          g->have_cached_block = TRUE;
         g->last_read_time = time (0L);          g->cached_block_num = blocknum;        
         g->cached_block_num = blocknum;  
           
         g->last_block = blocknum;          g->last_block = blocknum;
         g->use_count++;  
         g->read_ops++;          g->read_ops++;
     }      }
           
       g->last_read_time = time (0L);
       g->use_count++;
       
     if (g->locked) gbl_unlock (g);      if (g->locked) gbl_unlock (g);
   
     return TRUE;          return TRUE;    
Line 1158  reopen: Line 1159  reopen:
   
     if (action == get_sym) {      if (action == get_sym) {
   
     tfast0:  tfast0:
         gbl_lock (g, 3);          gbl_lock (g, 3);
                   
         if (g->fast_path > 0) goto tfast1;              /* try again last block */          if (g->fast_path > 0) goto tfast1;              /* try again last block */
Line 1168  reopen: Line 1169  reopen:
         for (;;) {          for (;;) {
   
   
         tfast1:  tfast1:
             gbl_read_block (g, blknbr, block);              gbl_read_block (g, blknbr, block);
   
 /* temporarily disabled  /* temporarily disabled
Line 2604  s10: Line 2605  s10:
         }          }
   
         case killone:          case killone:
   
         {          {
             if (found == 2) goto killo;         /* entry found use normal kill routine */              if (found == 2) goto killo;         /* entry found use normal kill routine */
                                   
             goto quit;              goto quit;
         }          }
   
         case merge_sym:  
   
             printf("MERGE NOT IMPLEMENTED FOR GLOBALS\n");  
   
 #ifdef DEBUG_GBL       
       
             int loop;  
       
             printf ("DEBUG MERGE: ");  
             printf ("[key] is [");  
       
             for (loop = 0; key[loop] != EOL; loop++) printf ("%c", (key[loop] == DELIM) ? '!' : key[loop]);  
       
             printf ("]\r\n");  
             printf ("[data] is [");  
       
             for(loop = 0; data[loop] != EOL; loop++) printf ("%c", (data[loop] == DELIM) ? '!' : data[loop]);  
       
             printf("]\r\n");      
   
 #endif  
             return;  
   
         default:          default:
           
             merr_raise (INVREF);                        /* accidental call with wrong action code (v22-stuff) */              merr_raise (INVREF);                        /* accidental call with wrong action code (v22-stuff) */

Removed from v.1.19  
changed lines
  Added in v.1.20


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>