From 6fb3c6f193c0d8210f48ff0584bbf02caa5c0d94 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Mon, 16 Feb 2015 18:12:45 -0500 Subject: [PATCH] Wait with curl init until the first connection comes in this should save a bunch of memory for the common case --- src/server.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/server.c b/src/server.c index 4aebc2a..cb5bf82 100644 --- a/src/server.c +++ b/src/server.c @@ -222,11 +222,11 @@ int main(int argc, char **argv) int sockfd; struct sockaddr_un sun; int ret; + int curl_done = 0; if (argc < -1) (void)argv; - curl_global_init(CURL_GLOBAL_ALL); signal(SIGPIPE,SIG_IGN); @@ -235,7 +235,6 @@ int main(int argc, char **argv) if (access("/var/cache/debuginfo/src/", F_OK)) system("mkdir -p /var/cache/debuginfo/src/ &> /dev/null"); - sockfd = socket(AF_UNIX, SOCK_STREAM, 0); if (sockfd < 0) return EXIT_FAILURE; @@ -261,6 +260,11 @@ int main(int argc, char **argv) pthread_t thread; clientsock = accept(sockfd, NULL, NULL); + + if (!curl_done) { + curl_global_init(CURL_GLOBAL_ALL); + curl_done = 1; + } pthread_create(&thread, NULL, server_thread, (void *)(unsigned long)clientsock); pthread_detach(thread);