mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
r7029@Kushana: nickm | 2006-08-04 14:08:41 -0700
Remove now-spurious size and data arguments from tor_mmap_file svn:r6987
This commit is contained in:
parent
dbac3fb481
commit
7c596c166b
@ -110,7 +110,7 @@ const char compat_c_id[] =
|
||||
|
||||
#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 @@ tor_mmap_file(const char *filename, const char **data, size_t *size_out)
|
||||
size_t size;
|
||||
|
||||
tor_assert(filename);
|
||||
tor_assert(size_out);
|
||||
|
||||
fd = open(filename, O_RDONLY, 0);
|
||||
if (fd<0) {
|
||||
@ -143,8 +142,8 @@ tor_mmap_file(const char *filename, const char **data, size_t *size_out)
|
||||
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 @@ typedef struct win_mmap_t {
|
||||
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 @@ tor_mmap_file(const char *filename, const char **data, size_t *size)
|
||||
if (!res->data)
|
||||
goto err;
|
||||
|
||||
*size = res->size;
|
||||
*data = res->data;
|
||||
|
||||
return &(res->base);
|
||||
err:
|
||||
tor_munmap_file(res);
|
||||
@ -209,15 +205,15 @@ tor_munmap_file(tor_mmap_t *handle)
|
||||
}
|
||||
#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
|
||||
|
@ -120,8 +120,7 @@ typedef struct tor_mmap_t {
|
||||
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, ...)
|
||||
|
@ -1018,9 +1018,7 @@ typedef struct {
|
||||
* 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
|
||||
|
@ -276,12 +276,10 @@ router_rebuild_store(int force)
|
||||
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_reload_router_list(void)
|
||||
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 @@ signed_descriptor_get_body(signed_descriptor_t *desc)
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user