conn: Stop writing when our write bandwidth limist is exhausted
[tor.git] / src / or / tor_main.c
blob703669ac9972605223f5fa58e1b857eacd344e6f
1 /* Copyright 2001-2004 Roger Dingledine.
2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3 * Copyright (c) 2007-2017, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
6 #include "orconfig.h"
7 #ifdef ENABLE_RESTART_DEBUGGING
8 #include <stdlib.h>
9 #endif
11 /**
12 * \file tor_main.c
13 * \brief Stub module containing a main() function.
15 * We keep the main function in a separate module so that the unit
16 * tests, which have their own main()s, can link against main.c.
17 **/
19 int tor_main(int argc, char *argv[]);
21 /** We keep main() in a separate file so that our unit tests can use
22 * functions from main.c.
24 int
25 main(int argc, char *argv[])
27 int r;
28 #ifdef ENABLE_RESTART_DEBUGGING
29 int restart_count = getenv("TOR_DEBUG_RESTART") ? 1 : 0;
30 again:
31 #endif
32 r = tor_main(argc, argv);
33 if (r < 0 || r > 255)
34 return 1;
35 #ifdef ENABLE_RESTART_DEBUGGING
36 else if (r == 0 && restart_count--)
37 goto again;
38 #endif
39 else
40 return r;