statefile.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2013, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #define STATEFILE_PRIVATE
  7. #include "or.h"
  8. #include "circuitstats.h"
  9. #include "config.h"
  10. #include "confparse.h"
  11. #include "entrynodes.h"
  12. #include "hibernate.h"
  13. #include "rephist.h"
  14. #include "router.h"
  15. #include "sandbox.h"
  16. #include "statefile.h"
  17. /** A list of state-file "abbreviations," for compatibility. */
  18. static config_abbrev_t state_abbrevs_[] = {
  19. { "AccountingBytesReadInterval", "AccountingBytesReadInInterval", 0, 0 },
  20. { "HelperNode", "EntryGuard", 0, 0 },
  21. { "HelperNodeDownSince", "EntryGuardDownSince", 0, 0 },
  22. { "HelperNodeUnlistedSince", "EntryGuardUnlistedSince", 0, 0 },
  23. { "EntryNode", "EntryGuard", 0, 0 },
  24. { "EntryNodeDownSince", "EntryGuardDownSince", 0, 0 },
  25. { "EntryNodeUnlistedSince", "EntryGuardUnlistedSince", 0, 0 },
  26. { NULL, NULL, 0, 0},
  27. };
  28. /*XXXX these next two are duplicates or near-duplicates from config.c */
  29. #define VAR(name,conftype,member,initvalue) \
  30. { name, CONFIG_TYPE_ ## conftype, STRUCT_OFFSET(or_state_t, member), \
  31. initvalue }
  32. /** As VAR, but the option name and member name are the same. */
  33. #define V(member,conftype,initvalue) \
  34. VAR(#member, conftype, member, initvalue)
  35. /** Array of "state" variables saved to the ~/.tor/state file. */
  36. static config_var_t state_vars_[] = {
  37. /* Remember to document these in state-contents.txt ! */
  38. V(AccountingBytesReadInInterval, MEMUNIT, NULL),
  39. V(AccountingBytesWrittenInInterval, MEMUNIT, NULL),
  40. V(AccountingExpectedUsage, MEMUNIT, NULL),
  41. V(AccountingIntervalStart, ISOTIME, NULL),
  42. V(AccountingSecondsActive, INTERVAL, NULL),
  43. V(AccountingSecondsToReachSoftLimit,INTERVAL, NULL),
  44. V(AccountingSoftLimitHitAt, ISOTIME, NULL),
  45. V(AccountingBytesAtSoftLimit, MEMUNIT, NULL),
  46. VAR("EntryGuard", LINELIST_S, EntryGuards, NULL),
  47. VAR("EntryGuardDownSince", LINELIST_S, EntryGuards, NULL),
  48. VAR("EntryGuardUnlistedSince", LINELIST_S, EntryGuards, NULL),
  49. VAR("EntryGuardAddedBy", LINELIST_S, EntryGuards, NULL),
  50. VAR("EntryGuardPathBias", LINELIST_S, EntryGuards, NULL),
  51. VAR("EntryGuardPathUseBias", LINELIST_S, EntryGuards, NULL),
  52. V(EntryGuards, LINELIST_V, NULL),
  53. VAR("TransportProxy", LINELIST_S, TransportProxies, NULL),
  54. V(TransportProxies, LINELIST_V, NULL),
  55. V(BWHistoryReadEnds, ISOTIME, NULL),
  56. V(BWHistoryReadInterval, UINT, "900"),
  57. V(BWHistoryReadValues, CSV, ""),
  58. V(BWHistoryReadMaxima, CSV, ""),
  59. V(BWHistoryWriteEnds, ISOTIME, NULL),
  60. V(BWHistoryWriteInterval, UINT, "900"),
  61. V(BWHistoryWriteValues, CSV, ""),
  62. V(BWHistoryWriteMaxima, CSV, ""),
  63. V(BWHistoryDirReadEnds, ISOTIME, NULL),
  64. V(BWHistoryDirReadInterval, UINT, "900"),
  65. V(BWHistoryDirReadValues, CSV, ""),
  66. V(BWHistoryDirReadMaxima, CSV, ""),
  67. V(BWHistoryDirWriteEnds, ISOTIME, NULL),
  68. V(BWHistoryDirWriteInterval, UINT, "900"),
  69. V(BWHistoryDirWriteValues, CSV, ""),
  70. V(BWHistoryDirWriteMaxima, CSV, ""),
  71. V(TorVersion, STRING, NULL),
  72. V(LastRotatedOnionKey, ISOTIME, NULL),
  73. V(LastWritten, ISOTIME, NULL),
  74. V(TotalBuildTimes, UINT, NULL),
  75. V(CircuitBuildAbandonedCount, UINT, "0"),
  76. VAR("CircuitBuildTimeBin", LINELIST_S, BuildtimeHistogram, NULL),
  77. VAR("BuildtimeHistogram", LINELIST_V, BuildtimeHistogram, NULL),
  78. { NULL, CONFIG_TYPE_OBSOLETE, 0, NULL }
  79. };
  80. #undef VAR
  81. #undef V
  82. static int or_state_validate(or_state_t *state, char **msg);
  83. static int or_state_validate_cb(void *old_options, void *options,
  84. void *default_options,
  85. int from_setconf, char **msg);
  86. /** Magic value for or_state_t. */
  87. #define OR_STATE_MAGIC 0x57A73f57
  88. /** "Extra" variable in the state that receives lines we can't parse. This
  89. * lets us preserve options from versions of Tor newer than us. */
  90. static config_var_t state_extra_var = {
  91. "__extra", CONFIG_TYPE_LINELIST, STRUCT_OFFSET(or_state_t, ExtraLines), NULL
  92. };
  93. /** Configuration format for or_state_t. */
  94. static const config_format_t state_format = {
  95. sizeof(or_state_t),
  96. OR_STATE_MAGIC,
  97. STRUCT_OFFSET(or_state_t, magic_),
  98. state_abbrevs_,
  99. state_vars_,
  100. or_state_validate_cb,
  101. &state_extra_var,
  102. };
  103. /** Persistent serialized state. */
  104. static or_state_t *global_state = NULL;
  105. /** Return the persistent state struct for this Tor. */
  106. MOCK_IMPL(or_state_t *,
  107. get_or_state, (void))
  108. {
  109. tor_assert(global_state);
  110. return global_state;
  111. }
  112. /** Return true iff we have loaded the global state for this Tor */
  113. int
  114. or_state_loaded(void)
  115. {
  116. return global_state != NULL;
  117. }
  118. /** Return true if <b>line</b> is a valid state TransportProxy line.
  119. * Return false otherwise. */
  120. static int
  121. state_transport_line_is_valid(const char *line)
  122. {
  123. smartlist_t *items = NULL;
  124. char *addrport=NULL;
  125. tor_addr_t addr;
  126. uint16_t port = 0;
  127. int r;
  128. items = smartlist_new();
  129. smartlist_split_string(items, line, NULL,
  130. SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, -1);
  131. if (smartlist_len(items) != 2) {
  132. log_warn(LD_CONFIG, "state: Not enough arguments in TransportProxy line.");
  133. goto err;
  134. }
  135. addrport = smartlist_get(items, 1);
  136. if (tor_addr_port_lookup(addrport, &addr, &port) < 0) {
  137. log_warn(LD_CONFIG, "state: Could not parse addrport.");
  138. goto err;
  139. }
  140. if (!port) {
  141. log_warn(LD_CONFIG, "state: Transport line did not contain port.");
  142. goto err;
  143. }
  144. r = 1;
  145. goto done;
  146. err:
  147. r = 0;
  148. done:
  149. SMARTLIST_FOREACH(items, char*, s, tor_free(s));
  150. smartlist_free(items);
  151. return r;
  152. }
  153. /** Return 0 if all TransportProxy lines in <b>state</b> are well
  154. * formed. Otherwise, return -1. */
  155. static int
  156. validate_transports_in_state(or_state_t *state)
  157. {
  158. int broken = 0;
  159. config_line_t *line;
  160. for (line = state->TransportProxies ; line ; line = line->next) {
  161. tor_assert(!strcmp(line->key, "TransportProxy"));
  162. if (!state_transport_line_is_valid(line->value))
  163. broken = 1;
  164. }
  165. if (broken)
  166. log_warn(LD_CONFIG, "state: State file seems to be broken.");
  167. return 0;
  168. }
  169. static int
  170. or_state_validate_cb(void *old_state, void *state, void *default_state,
  171. int from_setconf, char **msg)
  172. {
  173. /* We don't use these; only options do. Still, we need to match that
  174. * signature. */
  175. (void) from_setconf;
  176. (void) default_state;
  177. (void) old_state;
  178. return or_state_validate(state, msg);
  179. }
  180. /** Return 0 if every setting in <b>state</b> is reasonable, and a
  181. * permissible transition from <b>old_state</b>. Else warn and return -1.
  182. * Should have no side effects, except for normalizing the contents of
  183. * <b>state</b>.
  184. */
  185. static int
  186. or_state_validate(or_state_t *state, char **msg)
  187. {
  188. if (entry_guards_parse_state(state, 0, msg)<0)
  189. return -1;
  190. if (validate_transports_in_state(state)<0)
  191. return -1;
  192. return 0;
  193. }
  194. /** Replace the current persistent state with <b>new_state</b> */
  195. static int
  196. or_state_set(or_state_t *new_state)
  197. {
  198. char *err = NULL;
  199. int ret = 0;
  200. tor_assert(new_state);
  201. config_free(&state_format, global_state);
  202. global_state = new_state;
  203. if (entry_guards_parse_state(global_state, 1, &err)<0) {
  204. log_warn(LD_GENERAL,"%s",err);
  205. tor_free(err);
  206. ret = -1;
  207. }
  208. if (rep_hist_load_state(global_state, &err)<0) {
  209. log_warn(LD_GENERAL,"Unparseable bandwidth history state: %s",err);
  210. tor_free(err);
  211. ret = -1;
  212. }
  213. if (circuit_build_times_parse_state(
  214. get_circuit_build_times_mutable(),global_state) < 0) {
  215. ret = -1;
  216. }
  217. return ret;
  218. }
  219. /**
  220. * Save a broken state file to a backup location.
  221. */
  222. static void
  223. or_state_save_broken(char *fname)
  224. {
  225. int i, res;
  226. file_status_t status;
  227. char *fname2 = NULL;
  228. for (i = 0; i < 100; ++i) {
  229. tor_asprintf(&fname2, "%s.%d", fname, i);
  230. status = file_status(fname2);
  231. if (status == FN_NOENT)
  232. break;
  233. tor_free(fname2);
  234. }
  235. if (i == 100) {
  236. log_warn(LD_BUG, "Unable to parse state in \"%s\"; too many saved bad "
  237. "state files to move aside. Discarding the old state file.",
  238. fname);
  239. res = unlink(fname);
  240. if (res != 0) {
  241. log_warn(LD_FS,
  242. "Also couldn't discard old state file \"%s\" because "
  243. "unlink() failed: %s",
  244. fname, strerror(errno));
  245. }
  246. } else {
  247. log_warn(LD_BUG, "Unable to parse state in \"%s\". Moving it aside "
  248. "to \"%s\". This could be a bug in Tor; please tell "
  249. "the developers.", fname, fname2);
  250. if (tor_rename(fname, fname2) < 0) {//XXXX sandbox prohibits
  251. log_warn(LD_BUG, "Weirdly, I couldn't even move the state aside. The "
  252. "OS gave an error of %s", strerror(errno));
  253. }
  254. }
  255. tor_free(fname2);
  256. }
  257. /** Reload the persistent state from disk, generating a new state as needed.
  258. * Return 0 on success, less than 0 on failure.
  259. */
  260. int
  261. or_state_load(void)
  262. {
  263. or_state_t *new_state = NULL;
  264. char *contents = NULL, *fname;
  265. char *errmsg = NULL;
  266. int r = -1, badstate = 0;
  267. fname = get_datadir_fname("state");
  268. switch (file_status(fname)) {
  269. case FN_FILE:
  270. if (!(contents = read_file_to_str(fname, 0, NULL))) {
  271. log_warn(LD_FS, "Unable to read state file \"%s\"", fname);
  272. goto done;
  273. }
  274. break;
  275. case FN_NOENT:
  276. break;
  277. case FN_ERROR:
  278. case FN_DIR:
  279. default:
  280. log_warn(LD_GENERAL,"State file \"%s\" is not a file? Failing.", fname);
  281. goto done;
  282. }
  283. new_state = tor_malloc_zero(sizeof(or_state_t));
  284. new_state->magic_ = OR_STATE_MAGIC;
  285. config_init(&state_format, new_state);
  286. if (contents) {
  287. config_line_t *lines=NULL;
  288. int assign_retval;
  289. if (config_get_lines(contents, &lines, 0)<0)
  290. goto done;
  291. assign_retval = config_assign(&state_format, new_state,
  292. lines, 0, 0, &errmsg);
  293. config_free_lines(lines);
  294. if (assign_retval<0)
  295. badstate = 1;
  296. if (errmsg) {
  297. log_warn(LD_GENERAL, "%s", errmsg);
  298. tor_free(errmsg);
  299. }
  300. }
  301. if (!badstate && or_state_validate(new_state, &errmsg) < 0)
  302. badstate = 1;
  303. if (errmsg) {
  304. log_warn(LD_GENERAL, "%s", errmsg);
  305. tor_free(errmsg);
  306. }
  307. if (badstate && !contents) {
  308. log_warn(LD_BUG, "Uh oh. We couldn't even validate our own default state."
  309. " This is a bug in Tor.");
  310. goto done;
  311. } else if (badstate && contents) {
  312. or_state_save_broken(fname);
  313. tor_free(contents);
  314. config_free(&state_format, new_state);
  315. new_state = tor_malloc_zero(sizeof(or_state_t));
  316. new_state->magic_ = OR_STATE_MAGIC;
  317. config_init(&state_format, new_state);
  318. } else if (contents) {
  319. log_info(LD_GENERAL, "Loaded state from \"%s\"", fname);
  320. } else {
  321. log_info(LD_GENERAL, "Initialized state");
  322. }
  323. if (or_state_set(new_state) == -1) {
  324. or_state_save_broken(fname);
  325. }
  326. new_state = NULL;
  327. if (!contents) {
  328. global_state->next_write = 0;
  329. or_state_save(time(NULL));
  330. }
  331. r = 0;
  332. done:
  333. tor_free(fname);
  334. tor_free(contents);
  335. if (new_state)
  336. config_free(&state_format, new_state);
  337. return r;
  338. }
  339. /** Did the last time we tried to write the state file fail? If so, we
  340. * should consider disabling such features as preemptive circuit generation
  341. * to compute circuit-build-time. */
  342. static int last_state_file_write_failed = 0;
  343. /** Return whether the state file failed to write last time we tried. */
  344. int
  345. did_last_state_file_write_fail(void)
  346. {
  347. return last_state_file_write_failed;
  348. }
  349. /** If writing the state to disk fails, try again after this many seconds. */
  350. #define STATE_WRITE_RETRY_INTERVAL 3600
  351. /** If we're a relay, how often should we checkpoint our state file even
  352. * if nothing else dirties it? This will checkpoint ongoing stats like
  353. * bandwidth used, per-country user stats, etc. */
  354. #define STATE_RELAY_CHECKPOINT_INTERVAL (12*60*60)
  355. /** Write the persistent state to disk. Return 0 for success, <0 on failure. */
  356. int
  357. or_state_save(time_t now)
  358. {
  359. char *state, *contents;
  360. char tbuf[ISO_TIME_LEN+1];
  361. char *fname;
  362. tor_assert(global_state);
  363. if (global_state->next_write > now)
  364. return 0;
  365. /* Call everything else that might dirty the state even more, in order
  366. * to avoid redundant writes. */
  367. entry_guards_update_state(global_state);
  368. rep_hist_update_state(global_state);
  369. circuit_build_times_update_state(get_circuit_build_times(), global_state);
  370. if (accounting_is_enabled(get_options()))
  371. accounting_run_housekeeping(now);
  372. global_state->LastWritten = now;
  373. tor_free(global_state->TorVersion);
  374. tor_asprintf(&global_state->TorVersion, "Tor %s", get_version());
  375. state = config_dump(&state_format, NULL, global_state, 1, 0);
  376. format_local_iso_time(tbuf, now);
  377. tor_asprintf(&contents,
  378. "# Tor state file last generated on %s local time\n"
  379. "# Other times below are in UTC\n"
  380. "# You *do not* need to edit this file.\n\n%s",
  381. tbuf, state);
  382. tor_free(state);
  383. fname = get_datadir_fname("state");
  384. if (write_str_to_file(fname, contents, 0)<0) {
  385. log_warn(LD_FS, "Unable to write state to file \"%s\"; "
  386. "will try again later", fname);
  387. last_state_file_write_failed = 1;
  388. tor_free(fname);
  389. tor_free(contents);
  390. /* Try again after STATE_WRITE_RETRY_INTERVAL (or sooner, if the state
  391. * changes sooner). */
  392. global_state->next_write = now + STATE_WRITE_RETRY_INTERVAL;
  393. return -1;
  394. }
  395. last_state_file_write_failed = 0;
  396. log_info(LD_GENERAL, "Saved state to \"%s\"", fname);
  397. tor_free(fname);
  398. tor_free(contents);
  399. if (server_mode(get_options()))
  400. global_state->next_write = now + STATE_RELAY_CHECKPOINT_INTERVAL;
  401. else
  402. global_state->next_write = TIME_MAX;
  403. return 0;
  404. }
  405. /** Return the config line for transport <b>transport</b> in the current state.
  406. * Return NULL if there is no config line for <b>transport</b>. */
  407. STATIC config_line_t *
  408. get_transport_in_state_by_name(const char *transport)
  409. {
  410. or_state_t *or_state = get_or_state();
  411. config_line_t *line;
  412. config_line_t *ret = NULL;
  413. smartlist_t *items = NULL;
  414. for (line = or_state->TransportProxies ; line ; line = line->next) {
  415. tor_assert(!strcmp(line->key, "TransportProxy"));
  416. items = smartlist_new();
  417. smartlist_split_string(items, line->value, NULL,
  418. SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, -1);
  419. if (smartlist_len(items) != 2) /* broken state */
  420. goto done;
  421. if (!strcmp(smartlist_get(items, 0), transport)) {
  422. ret = line;
  423. goto done;
  424. }
  425. SMARTLIST_FOREACH(items, char*, s, tor_free(s));
  426. smartlist_free(items);
  427. items = NULL;
  428. }
  429. done:
  430. if (items) {
  431. SMARTLIST_FOREACH(items, char*, s, tor_free(s));
  432. smartlist_free(items);
  433. }
  434. return ret;
  435. }
  436. /** Return string containing the address:port part of the
  437. * TransportProxy <b>line</b> for transport <b>transport</b>.
  438. * If the line is corrupted, return NULL. */
  439. static const char *
  440. get_transport_bindaddr(const char *line, const char *transport)
  441. {
  442. char *line_tmp = NULL;
  443. if (strlen(line) < strlen(transport) + 2) {
  444. goto broken_state;
  445. } else {
  446. /* line should start with the name of the transport and a space.
  447. (for example, "obfs2 127.0.0.1:47245") */
  448. tor_asprintf(&line_tmp, "%s ", transport);
  449. if (strcmpstart(line, line_tmp))
  450. goto broken_state;
  451. tor_free(line_tmp);
  452. return (line+strlen(transport)+1);
  453. }
  454. broken_state:
  455. tor_free(line_tmp);
  456. return NULL;
  457. }
  458. /** Return a string containing the address:port that a proxy transport
  459. * should bind on. The string is stored on the heap and must be freed
  460. * by the caller of this function. */
  461. char *
  462. get_stored_bindaddr_for_server_transport(const char *transport)
  463. {
  464. char *default_addrport = NULL;
  465. const char *stored_bindaddr = NULL;
  466. config_line_t *line = NULL;
  467. {
  468. /* See if the user explicitly asked for a specific listening
  469. address for this transport. */
  470. char *conf_bindaddr = get_transport_bindaddr_from_config(transport);
  471. if (conf_bindaddr)
  472. return conf_bindaddr;
  473. }
  474. line = get_transport_in_state_by_name(transport);
  475. if (!line) /* Found no references in state for this transport. */
  476. goto no_bindaddr_found;
  477. stored_bindaddr = get_transport_bindaddr(line->value, transport);
  478. if (stored_bindaddr) /* found stored bindaddr in state file. */
  479. return tor_strdup(stored_bindaddr);
  480. no_bindaddr_found:
  481. /** If we didn't find references for this pluggable transport in the
  482. state file, we should instruct the pluggable transport proxy to
  483. listen on INADDR_ANY on a random ephemeral port. */
  484. tor_asprintf(&default_addrport, "%s:%s", fmt_addr32(INADDR_ANY), "0");
  485. return default_addrport;
  486. }
  487. /** Save <b>transport</b> listening on <b>addr</b>:<b>port</b> to
  488. state */
  489. void
  490. save_transport_to_state(const char *transport,
  491. const tor_addr_t *addr, uint16_t port)
  492. {
  493. or_state_t *state = get_or_state();
  494. char *transport_addrport=NULL;
  495. /** find where to write on the state */
  496. config_line_t **next, *line;
  497. /* see if this transport is already stored in state */
  498. config_line_t *transport_line =
  499. get_transport_in_state_by_name(transport);
  500. if (transport_line) { /* if transport already exists in state... */
  501. const char *prev_bindaddr = /* get its addrport... */
  502. get_transport_bindaddr(transport_line->value, transport);
  503. transport_addrport = tor_strdup(fmt_addrport(addr, port));
  504. /* if transport in state has the same address as this one, life is good */
  505. if (!strcmp(prev_bindaddr, transport_addrport)) {
  506. log_info(LD_CONFIG, "Transport seems to have spawned on its usual "
  507. "address:port.");
  508. goto done;
  509. } else { /* if addrport in state is different than the one we got */
  510. log_info(LD_CONFIG, "Transport seems to have spawned on different "
  511. "address:port. Let's update the state file with the new "
  512. "address:port");
  513. tor_free(transport_line->value); /* free the old line */
  514. /* replace old addrport line with new line */
  515. tor_asprintf(&transport_line->value, "%s %s", transport,
  516. fmt_addrport(addr, port));
  517. }
  518. } else { /* never seen this one before; save it in state for next time */
  519. log_info(LD_CONFIG, "It's the first time we see this transport. "
  520. "Let's save its address:port");
  521. next = &state->TransportProxies;
  522. /* find the last TransportProxy line in the state and point 'next'
  523. right after it */
  524. line = state->TransportProxies;
  525. while (line) {
  526. next = &(line->next);
  527. line = line->next;
  528. }
  529. /* allocate space for the new line and fill it in */
  530. *next = line = tor_malloc_zero(sizeof(config_line_t));
  531. line->key = tor_strdup("TransportProxy");
  532. tor_asprintf(&line->value, "%s %s", transport, fmt_addrport(addr, port));
  533. next = &(line->next);
  534. }
  535. if (!get_options()->AvoidDiskWrites)
  536. or_state_mark_dirty(state, 0);
  537. done:
  538. tor_free(transport_addrport);
  539. }
  540. void
  541. or_state_free_all(void)
  542. {
  543. config_free(&state_format, global_state);
  544. global_state = NULL;
  545. }