diff options
-rw-r--r-- | changes/bug14802 | 4 | ||||
-rw-r--r-- | src/common/compat.c | 2 | ||||
-rw-r--r-- | src/or/cpuworker.c | 4 | ||||
-rw-r--r-- | src/or/or.h | 3 | ||||
-rw-r--r-- | src/test/test_address.c | 13 |
5 files changed, 17 insertions, 9 deletions
diff --git a/changes/bug14802 b/changes/bug14802 new file mode 100644 index 0000000000..fc7cfd1873 --- /dev/null +++ b/changes/bug14802 @@ -0,0 +1,4 @@ + o Minor bugfix: + - Make an educated guess about how much memory the system has when our + detection functionality fails on some operating system. Fixes bug 14802; + bugfix on 0.2.5.4-alpha. diff --git a/src/common/compat.c b/src/common/compat.c index 5575316b2b..fde65d9d15 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -3161,7 +3161,7 @@ get_total_system_memory_impl(void) size_t len = sizeof(memsize); int mib[2] = {CTL_HW, HW_USERMEM}; if (sysctl(mib,2,&memsize,&len,NULL,0)) - return -1; + return 0; return memsize; diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index 5e8b32d780..c5e78ed716 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -556,8 +556,8 @@ cpuworker_cancel_circ_handshake(or_circuit_t *circ) tor_free(job); tor_assert(total_pending_tasks > 0); --total_pending_tasks; + /* if (!job), this is done in cpuworker_onion_handshake_replyfn. */ + circ->workqueue_entry = NULL; } - - circ->workqueue_entry = NULL; } diff --git a/src/or/or.h b/src/or/or.h index 520b7dba89..5d70798d8e 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3126,7 +3126,8 @@ typedef struct or_circuit_t { * chance to give an onionskin to a cpuworker. Used only in onion.c */ struct onion_queue_t *onionqueue_entry; /** Pointer to a workqueue entry, if this circuit has given an onionskin to - * a cpuworker and is waiting for a response. Used only in cpuworker.c */ + * a cpuworker and is waiting for a response. Used to decide whether it is + * safe to free a circuit or if it is still in use by a cpuworker. */ struct workqueue_entry_s *workqueue_entry; /** The circuit_id used in the previous (backward) hop of this circuit. */ diff --git a/src/test/test_address.c b/src/test/test_address.c index f98cc12b62..7f7347fa88 100644 --- a/src/test/test_address.c +++ b/src/test/test_address.c @@ -207,9 +207,10 @@ test_address_ifaddrs_to_smartlist(void *arg) tor_free(ifa_ipv4); tor_free(ifa_ipv6); tor_free(sockaddr_to_check); - SMARTLIST_FOREACH(smartlist, tor_addr_t *, t, tor_free(t)); - smartlist_free(smartlist); - + if (smartlist) { + SMARTLIST_FOREACH(smartlist, tor_addr_t *, t, tor_free(t)); + smartlist_free(smartlist); + } return; } @@ -442,8 +443,10 @@ test_address_get_if_addrs_ioctl(void *arg) tt_assert(smartlist_contains_localhost_tor_addr(result)); done: - SMARTLIST_FOREACH(result, tor_addr_t *, t, tor_free(t)); - smartlist_free(result); + if (result) { + SMARTLIST_FOREACH(result, tor_addr_t *, t, tor_free(t)); + smartlist_free(result); + } return; } |