current jcc.c,1.466,1.467

Fabian Keil via ijbswa-commits <[email protected]> Mon, 26 Jun 2017 12:18:23 +0000
Newsgroups gmane.comp.web.privoxy.cvs
Message-ID <[email protected]>
Update of /cvsroot/ijbswa/current
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv22160

Modified Files:
	jcc.c 
Log Message:
listen_loop(): Reuse a single thread attribute object

The object doesn't change and creating a new one for
every thread is a waste of (cpu) time.

Sponsored by: Robert Klemme


Index: jcc.c
===================================================================
RCS file: /cvsroot/ijbswa/current/jcc.c,v
retrieving revision 1.466
retrieving revision 1.467
diff -C2 -d -r1.466 -r1.467
*** jcc.c	26 Jun 2017 12:17:57 -0000	1.466
--- jcc.c	26 Jun 2017 12:18:21 -0000	1.467
***************
*** 4297,4300 ****
--- 4297,4306 ----
     struct configuration_spec *config;
     unsigned int active_threads = 0;
+ #if defined(FEATURE_PTHREAD)
+    pthread_attr_t attrs;
+ 
+    pthread_attr_init(&attrs);
+    pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
+ #endif
  
     config = load_config();
***************
*** 4452,4463 ****
           {
              pthread_t the_thread;
-             pthread_attr_t attrs;
  
-             pthread_attr_init(&attrs);
-             pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
              errno = pthread_create(&the_thread, &attrs,
                 (void * (*)(void *))serve, csp);
              child_id = errno ? -1 : 0;
-             pthread_attr_destroy(&attrs);
           }
  #endif
--- 4458,4465 ----
***************
*** 4624,4627 ****
--- 4626,4633 ----
     }
  
+ #if defined(FEATURE_PTHREAD)
+    pthread_attr_destroy(&attrs);
+ #endif
+ 
     /* NOTREACHED unless FEATURE_GRACEFUL_TERMINATION is defined */
  


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot