]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: test-http-payload - Move global initialization to main_init/deinit().
authorStephan Bosch <stephan.bosch@open-xchange.com>
Sat, 4 Apr 2020 10:40:26 +0000 (12:40 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 22 May 2020 08:42:33 +0000 (08:42 +0000)
src/lib-http/test-http-payload.c

index 0d1ff45454c5f098cf6567be59f32270e743d8a8..69ef541010a352398635eb3015f0ea904875c31d 100644 (file)
@@ -2258,12 +2258,8 @@ static void test_atexit(void)
        test_server_kill();
 }
 
-int main(int argc, char *argv[])
+static void main_init(void)
 {
-       int c;
-       int ret;
-
-       lib_init();
        lib_signals_init();
 #ifdef HAVE_OPENSSL
        ssl_iostream_openssl_init();
@@ -2276,6 +2272,24 @@ int main(int argc, char *argv[])
        lib_signals_set_handler(SIGINT, 0, test_signal_handler, NULL);
        lib_signals_set_handler(SIGSEGV, 0, test_signal_handler, NULL);
        lib_signals_set_handler(SIGABRT, 0, test_signal_handler, NULL);
+}
+
+static void main_deinit(void)
+{
+       ssl_iostream_context_cache_free();
+#ifdef HAVE_OPENSSL
+       ssl_iostream_openssl_deinit();
+#endif
+       lib_signals_deinit();
+}
+
+int main(int argc, char *argv[])
+{
+       int c;
+       int ret;
+
+       lib_init();
+       main_init();
 
        while ((c = getopt(argc, argv, "DS")) > 0) {
                switch (c) {
@@ -2297,11 +2311,7 @@ int main(int argc, char *argv[])
 
        ret = test_run(test_functions);
 
-       ssl_iostream_context_cache_free();
-#ifdef HAVE_OPENSSL
-       ssl_iostream_openssl_deinit();
-#endif
-       lib_signals_deinit();
+       main_deinit();
        lib_deinit();
        return ret;
 }