Important bug fix for OVDB

Heath Kehoe heath.kehoe at intermec.com
Sun May 21 16:52:30 UTC 2000


How about this?

-h



diff -rc ../inn-BETA-20000518/include/ov.h ./include/ov.h
*** ../inn-BETA-20000518/include/ov.h	Fri Nov 26 10:51:20 1999
--- ./include/ov.h	Sun May 21 11:32:41 2000
***************
*** 10,16 ****
  #define OV_READ  1
  #define OV_WRITE 2
  
! typedef enum {OVSPACE, OVSORT, OVCUTOFFLOW, OVGROUPBASEDEXPIRE} OVCTLTYPE;
  #define OV_NOSPACE 100
  typedef enum {OVNEWSGROUP, OVARRIVED} OVSORTTYPE;
  
--- 10,16 ----
  #define OV_READ  1
  #define OV_WRITE 2
  
! typedef enum {OVSPACE, OVSORT, OVCUTOFFLOW, OVGROUPBASEDEXPIRE, OVSTATICSEARCH} OVCTLTYPE;
  #define OV_NOSPACE 100
  typedef enum {OVNEWSGROUP, OVARRIVED} OVSORTTYPE;
  
diff -rc ../inn-BETA-20000518/nnrpd/article.c ./nnrpd/article.c
*** ../inn-BETA-20000518/nnrpd/article.c	Thu May 18 05:04:58 2000
--- ./nnrpd/article.c	Sun May 21 11:43:35 2000
***************
*** 911,917 ****
      ARTNUM		artnum;
      void		*handle;
      char		*data;
!     int			len;
      TOKEN		token;
  
      if (!PERMcanread) {
--- 911,917 ----
      ARTNUM		artnum;
      void		*handle;
      char		*data;
!     int			len, useIOb = 0;
      TOKEN		token;
  
      if (!PERMcanread) {
***************
*** 956,961 ****
--- 956,967 ----
      (void)fflush(stdout);
      if (PERMaccessconf->nnrpdoverstats)
  	gettimeofday(&stv, NULL);
+ 
+     /* If OVSTATICSEARCH is true, then the data returned by OVsearch is only
+        valid until the next call to OVsearch.  In this case, we must use
+        SendIOb because it copies the data. */
+     OVctl(OVSTATICSEARCH, &useIOb);
+ 
      while (OVsearch(handle, &artnum, &data, &len, &token, NULL)) {
  	if (PERMaccessconf->nnrpdoverstats) {
  	    gettimeofday(&etv, NULL);
***************
*** 973,979 ****
  	    OVERhit++;
  	    OVERsize += len;
  	}
! 	SendIOv(data, len);
  	if (PERMaccessconf->nnrpdoverstats)
  	    gettimeofday(&stv, NULL);
      }
--- 979,988 ----
  	    OVERhit++;
  	    OVERsize += len;
  	}
! 	if(useIOb)
! 	    SendIOb(data, len);
! 	else
! 	    SendIOv(data, len);
  	if (PERMaccessconf->nnrpdoverstats)
  	    gettimeofday(&stv, NULL);
      }
***************
*** 982,989 ****
          OVERtime+=(etv.tv_sec - stv.tv_sec) * 1000;
          OVERtime+=(etv.tv_usec - stv.tv_usec) / 1000;
      }
!     SendIOv(".\r\n", 3);
!     PushIOv();
      if (PERMaccessconf->nnrpdoverstats)
  	gettimeofday(&stv, NULL);
      OVclosesearch(handle);
--- 991,1003 ----
          OVERtime+=(etv.tv_sec - stv.tv_sec) * 1000;
          OVERtime+=(etv.tv_usec - stv.tv_usec) / 1000;
      }
!     if(useIOb) {
! 	SendIOb(".\r\n", 3);
! 	PushIOb();
!     } else {
! 	SendIOv(".\r\n", 3);
! 	PushIOv();
!     }
      if (PERMaccessconf->nnrpdoverstats)
  	gettimeofday(&stv, NULL);
      OVclosesearch(handle);
diff -rc ../inn-BETA-20000518/storage/buffindexed/buffindexed.c ./storage/buffindexed/buffindexed.c
*** ../inn-BETA-20000518/storage/buffindexed/buffindexed.c	Thu May 18 05:05:13 2000
--- ./storage/buffindexed/buffindexed.c	Sun May 21 11:34:17 2000
***************
*** 1904,1909 ****
--- 1904,1913 ----
    case OVCUTOFFLOW:
      Cutofflow = *(BOOL *)val;
      return TRUE;
+   case OVSTATICSEARCH:
+     i = (int *)val;
+     *i = FALSE;
+     return TRUE;
    default:
      return FALSE;
    }
diff -rc ../inn-BETA-20000518/storage/ov3/ov3.c ./storage/ov3/ov3.c
*** ../inn-BETA-20000518/storage/ov3/ov3.c	Thu May 18 05:05:15 2000
--- ./storage/ov3/ov3.c	Sun May 21 11:34:55 2000
***************
*** 1218,1223 ****
--- 1218,1227 ----
        case OVCUTOFFLOW:
  	Cutofflow = *(BOOL *)val;
  	return TRUE;
+     case OVSTATICSEARCH:
+ 	i = (int *)val;
+ 	*i = FALSE;
+ 	return TRUE;
      default:
  	return FALSE;
      }
diff -rc ../inn-BETA-20000518/storage/ovdb/ovdb.c ./storage/ovdb/ovdb.c
*** ../inn-BETA-20000518/storage/ovdb/ovdb.c	Thu May 18 05:05:16 2000
--- ./storage/ovdb/ovdb.c	Sun May 21 11:46:04 2000
***************
*** 147,154 ****
      time_t expires;
  };
  
- #define SEARCHQUEUELEN  (IOV_MAX+5)
- 
  struct ovdbsearch {
      DB *db;
      DBC *cursor;
--- 147,152 ----
***************
*** 155,163 ****
      struct datakey lokey;
      struct datakey hikey;
      int state;
-     void *queue[SEARCHQUEUELEN];
-     int queuelen;
-     int queuehead;
  };
  
  
--- 153,158 ----
***************
*** 1224,1231 ****
      s->hikey.groupnum = gno;
      s->hikey.artnum = htonl(high);
      s->state = 0;
-     s->queuelen = 0;
-     s->queuehead = 0;
  
      return (void *)s;
  }
--- 1219,1224 ----
***************
*** 1241,1247 ****
  
      memset(&key, 0, sizeof key);
      memset(&val, 0, sizeof val);
-     val.flags = DB_DBT_MALLOC;
  
      switch(s->state) {
      case 0:
--- 1234,1239 ----
***************
*** 1280,1292 ****
  
      if(key.size != sizeof(struct datakey)) {
  	s->state = 2;
- 	free(val.data);
  	return FALSE;
      }
  
      if(memcmp(key.data, &(s->hikey), sizeof(struct datakey)) > 0) {
  	s->state = 2;
- 	free(val.data);
  	return FALSE;
      }
  
--- 1272,1282 ----
***************
*** 1294,1300 ****
  	|| ((token || arrived) && val.size < sizeof(struct ovdata)) ) {
  	syslog(L_ERROR, "OVDB: search: bad value length");
  	s->state = 2;
- 	free(val.data);
  	return FALSE;
      }
  
--- 1284,1289 ----
***************
*** 1311,1341 ****
  
      if(len)
  	*len = val.size - sizeof(struct ovdata);
!     if(data) {
  	*data = (char *)val.data + sizeof(struct ovdata);
! 	if(s->queuelen < SEARCHQUEUELEN) {
! 	    s->queuelen++;
! 	} else {
! 	    free(s->queue[s->queuehead]);
! 	}
! 	s->queue[s->queuehead] = val.data;
! 	s->queuehead = (1 + s->queuehead) % SEARCHQUEUELEN;
!     } else {
! 	free(val.data);
!     }
      return TRUE;
  }
  
  void ovdb_closesearch(void *handle)
  {
-     int i;
      struct ovdbsearch *s = (struct ovdbsearch *)handle;
  
      s->cursor->c_close(s->cursor);
     
-     for(i = 0; i < s->queuelen; i++)
- 	free(s->queue[i]);
- 
      DISPOSE(s);
  }
  
--- 1300,1317 ----
  
      if(len)
  	*len = val.size - sizeof(struct ovdata);
!     if(data)
  	*data = (char *)val.data + sizeof(struct ovdata);
! 
      return TRUE;
  }
  
  void ovdb_closesearch(void *handle)
  {
      struct ovdbsearch *s = (struct ovdbsearch *)handle;
  
      s->cursor->c_close(s->cursor);
     
      DISPOSE(s);
  }
  
***************
*** 1618,1623 ****
--- 1594,1603 ----
      case OVCUTOFFLOW:
          Cutofflow = *(BOOL *)val;
          return TRUE;
+     case OVSTATICSEARCH:
+ 	i = (int *)val;
+ 	*i = TRUE;
+ 	return TRUE;
      default:
          return FALSE;
      }





More information about the inn-workers mailing list