[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-bugs] #4282 [Tor Relay]: Extract common "make private stats dir" code from rephist.c, geoip.c
#4282: Extract common "make private stats dir" code from rephist.c, geoip.c
-----------------------+----------------------------------------------------
Reporter: nickm | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: Tor Relay | Version:
Keywords: | Parent:
Points: | Actualpoints:
-----------------------+----------------------------------------------------
In several places in rephist.c and geoip.c, we do:
{{{
/* Try to write to disk. */
statsdir = get_datadir_fname("stats");
if (check_private_dir(statsdir, CPD_CREATE, get_options()->User) < 0) {
log_warn(LD_HIST, "Unable to create stats/ directory!");
goto done;
}
filename = get_datadir_fname2("stats", "buffer-stats");
if (write_str_to_file(filename, str, 0) < 0)
log_warn(LD_HIST, "Unable to write buffer stats to disk!");
}}}
Duplicated code is stupid. Some or all of this should get extracted into
a new function or two. I'd suggest a function to "create the datadir and
a subdirectory of the datadir as needed" and another function to write a
file to a subdirectory of the datadir, creating that subdirectory as
needed.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/4282>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs