[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r6987: Remove now-spurious size and data arguments from tor_mmap_fi (in tor/trunk: . src/common src/or)



Author: nickm
Date: 2006-08-05 13:53:21 -0400 (Sat, 05 Aug 2006)
New Revision: 6987

Modified:
   tor/trunk/
   tor/trunk/src/common/compat.c
   tor/trunk/src/common/compat.h
   tor/trunk/src/or/or.h
   tor/trunk/src/or/routerlist.c
Log:
 r7029@Kushana:  nickm | 2006-08-04 14:08:41 -0700
 Remove now-spurious size and data arguments from tor_mmap_file



Property changes on: tor/trunk
___________________________________________________________________
Name: svk:merge
   - 1f724f9b-111a-0410-b636-93f1a77c1813:/local/or/tor/trunk:8207
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:7014
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/mmap:7028
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950
   + 1f724f9b-111a-0410-b636-93f1a77c1813:/local/or/tor/trunk:8207
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:7014
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/mmap:7029
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950

Modified: tor/trunk/src/common/compat.c
===================================================================
--- tor/trunk/src/common/compat.c	2006-08-05 17:53:08 UTC (rev 6986)
+++ tor/trunk/src/common/compat.c	2006-08-05 17:53:21 UTC (rev 6987)
@@ -110,7 +110,7 @@
 
 #ifdef HAVE_SYS_MMAN_H
 tor_mmap_t *
-tor_mmap_file(const char *filename, const char **data, size_t *size_out)
+tor_mmap_file(const char *filename)
 {
   int fd; /* router file */
   char *string;
@@ -119,7 +119,6 @@
   size_t size;
 
   tor_assert(filename);
-  tor_assert(size_out);
 
   fd = open(filename, O_RDONLY, 0);
   if (fd<0) {
@@ -143,8 +142,8 @@
   close(fd);
 
   res = tor_malloc_zero(sizeof(tor_mmap_t));
-  *data = res->data = string;
-  *size_out = res->size = size;
+  res->data = string;
+  res->size = size;
 
   return res;
 }
@@ -160,7 +159,7 @@
   HANDLE mmap_handle;
 } tor_mmap_impl_t;
 tor_mmap_t *
-tor_mmap_file(const char *filename, const char **data, size_t *size)
+tor_mmap_file(const char *filename)
 {
   win_mmap_t *res = tor_malloc_zero(sizeof(win_mmap_t));
   res->mmap_handle = res->file_handle = INVALID_HANDLE_VALUE;
@@ -186,9 +185,6 @@
   if (!res->data)
     goto err;
 
-  *size = res->size;
-  *data = res->data;
-
   return &(res->base);
  err:
   tor_munmap_file(res);
@@ -209,15 +205,15 @@
 }
 #else
 tor_mmap_t *
-tor_mmap_file(const char *filename, const char **data, size_t *size)
+tor_mmap_file(const char *filename)
 {
   char *res = read_file_to_str(filename, 1);
   tor_mmap_t *handle;
   if (! res)
     return NULL;
   handle = tor_malloc_zero(sizeof(tor_mmap_t));
-  *data = handle->data = res;
-  *size = handle->size = strlen(res) + 1;
+  handle->data = res;
+  handle->size = strlen(res) + 1;
   return handle;
 }
 void

Modified: tor/trunk/src/common/compat.h
===================================================================
--- tor/trunk/src/common/compat.h	2006-08-05 17:53:08 UTC (rev 6986)
+++ tor/trunk/src/common/compat.h	2006-08-05 17:53:21 UTC (rev 6987)
@@ -120,8 +120,7 @@
   size_t size;
 } tor_mmap_t;
 
-tor_mmap_t *tor_mmap_file(const char *filename,
-                          const char **data, size_t *size);
+tor_mmap_t *tor_mmap_file(const char *filename);
 void tor_munmap_file(tor_mmap_t *handle);
 
 int tor_snprintf(char *str, size_t size, const char *format, ...)

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2006-08-05 17:53:08 UTC (rev 6986)
+++ tor/trunk/src/or/or.h	2006-08-05 17:53:21 UTC (rev 6987)
@@ -1018,9 +1018,7 @@
    * caching. */
   smartlist_t *old_routers;
   /** DOCDOC */
-  const char *mmap_descriptors;
-  size_t mmap_descriptors_len;
-  tor_mmap_t *mmap_handle;
+  tor_mmap_t *mmap_descriptors;
 } routerlist_t;
 
 /** Information on router used when extending a circuit.  (We don't need a

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2006-08-05 17:53:08 UTC (rev 6986)
+++ tor/trunk/src/or/routerlist.c	2006-08-05 17:53:21 UTC (rev 6987)
@@ -276,12 +276,10 @@
     goto done;
   }
   /* Our mmap is now invalid. */
-  if (routerlist->mmap_handle) {
-    tor_munmap_file(routerlist->mmap_handle);
-    routerlist->mmap_handle = tor_mmap_file(fname,
-                                            &routerlist->mmap_descriptors,
-                                            &routerlist->mmap_descriptors_len);
-    if (! routerlist->mmap_handle)
+  if (routerlist->mmap_descriptors) {
+    tor_munmap_file(routerlist->mmap_descriptors);
+    routerlist->mmap_descriptors = tor_mmap_file(fname);
+    if (! routerlist->mmap_descriptors)
       log_warn(LD_FS, "Unable to mmap new descriptor file at '%s'.",fname);
   }
 
@@ -340,12 +338,10 @@
   router_journal_len = router_store_len = 0;
 
   tor_snprintf(fname, fname_len, "%s/cached-routers", options->DataDirectory);
-  routerlist->mmap_handle = tor_mmap_file(fname,
-                                          &routerlist->mmap_descriptors,
-                                          &routerlist->mmap_descriptors_len);
+  routerlist->mmap_descriptors = tor_mmap_file(fname);
   if (routerlist->mmap_descriptors) {
-    router_store_len = routerlist->mmap_descriptors_len;
-    router_load_routers_from_string(routerlist->mmap_descriptors,
+    router_store_len = routerlist->mmap_descriptors->size;
+    router_load_routers_from_string(routerlist->mmap_descriptors->data,
                                     SAVED_IN_CACHE, NULL);
   }
 
@@ -1159,8 +1155,8 @@
   tor_assert(len > 32);
   if (desc->saved_location == SAVED_IN_CACHE && routerlist &&
       routerlist->mmap_descriptors) {
-    tor_assert(desc->saved_offset + len <= routerlist->mmap_descriptors_len);
-    r = routerlist->mmap_descriptors + desc->saved_offset;
+    tor_assert(desc->saved_offset + len <= routerlist->mmap_descriptors->size);
+    r = routerlist->mmap_descriptors->data + desc->saved_offset;
   } else {
     r = desc->signed_descriptor_body;
   }