diff options
Diffstat (limited to 'src/or/router.c')
-rw-r--r-- | src/or/router.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/or/router.c b/src/or/router.c index 612e23b3a1..7bf40d69d0 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -2073,28 +2073,41 @@ router_get_my_routerinfo,(void)) return desc_routerinfo; } -/** Set <b>ri</b> to routerinfo of this OR. Rebuild it from - * scratch if needed. Return 0 on success or an appropriate - * TOR_ROUTERINFO_ERROR_* value on failure. +/** Return routerinfo of this OR. Rebuild it from + * scratch if needed. Set <b>*err</b> to 0 on success or to + * appropriate TOR_ROUTERINFO_ERROR_* value on failure. */ -MOCK_IMPL(int, -router_get_my_routerinfo_with_err,(routerinfo_t **ri)) +MOCK_IMPL(const routerinfo_t *, +router_get_my_routerinfo_with_err,(int *err)) { - if (!server_mode(get_options())) - return TOR_ROUTERINFO_ERROR_NOT_A_SERVER; + if (!server_mode(get_options())) { + if (err) + *err = TOR_ROUTERINFO_ERROR_NOT_A_SERVER; + + return NULL; + } if (!desc_clean_since) { - int err = router_rebuild_descriptor(0); - if (err < 0) - return err; + int rebuild_err = router_rebuild_descriptor(0); + if (rebuild_err < 0) { + if (err) + *err = rebuild_err; + + return NULL; + } } - if (!desc_routerinfo) - return TOR_ROUTERINFO_ERROR_NOT_SO_FAST; + if (!desc_routerinfo) { + if (err) + *err = TOR_ROUTERINFO_ERROR_NOT_SO_FAST; - if (ri) - *ri = desc_routerinfo; - return 0; + return NULL; + } + + if (err) + *err = 0; + + return desc_routerinfo; } /** OR only: Return a signed server descriptor for this OR, rebuilding a fresh |