]> git.sur5r.net Git - openldap/commitdiff
Use gmtime_r() if HAVE_GMTIME_R is defined (need to add autoconf check)
authorLuke Howard <lukeh@openldap.org>
Sat, 6 Dec 2003 05:37:00 +0000 (05:37 +0000)
committerLuke Howard <lukeh@openldap.org>
Sat, 6 Dec 2003 05:37:00 +0000 (05:37 +0000)
servers/slapd/init.c
servers/slapd/modify.c
servers/slapd/proto-slap.h
servers/slapd/schema.c

index d44220bb08c07ffb511c8c4eb1d757d125275e00..6ab72623220e8579b275ff378ea5b78a3545cc0f 100644 (file)
@@ -65,7 +65,9 @@ struct berval NoAttrs = BER_BVC( LDAP_NO_ATTRS );
  */
 ldap_pvt_thread_pool_t connection_pool;
 int                    connection_pool_max = SLAP_MAX_WORKER_THREADS;
+#ifndef HAVE_GMTIME_R
 ldap_pvt_thread_mutex_t        gmtime_mutex;
+#endif
 #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
 ldap_pvt_thread_mutex_t        passwd_mutex;
 #endif
@@ -153,7 +155,9 @@ slap_init( int mode, const char *name )
                        }
 #endif
 
+#ifndef HAVE_GMTIME_R
                        ldap_pvt_thread_mutex_init( &gmtime_mutex );
+#endif
 #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
                        ldap_pvt_thread_mutex_init( &passwd_mutex );
 #endif
index 3f620179491055cae9ab3ea9b69f514ff44b8ec4..1211979cb3f8f007192cde7cc4e8e890fa988f97 100644 (file)
@@ -801,15 +801,24 @@ int slap_mods_opattrs(
 
        if ( SLAP_LASTMOD( op->o_bd )) {
                struct tm *ltm;
+#ifdef HAVE_GMTIME_R
+               struct tm ltm_buf;
+#endif
                time_t now = slap_get_time();
 
+#ifdef HAVE_GMTIME_R
+               ltm = gmtime_r( &now, &ltm_buf );
+#else
                ldap_pvt_thread_mutex_lock( &gmtime_mutex );
                ltm = gmtime( &now );
+#endif /* HAVE_GMTIME_R */
                lutil_gentime( timebuf, sizeof(timebuf), ltm );
 
                slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, 1 );
 
+#ifndef HAVE_GMTIME_R
                ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+#endif
 
                timestamp.bv_val = timebuf;
                timestamp.bv_len = strlen(timebuf);
index fe119359ad04375e77da2363ee72d168911d8b36..bc178d040f15f92a5d3408f71e8f27afff28bc84 100644 (file)
@@ -1242,7 +1242,9 @@ LDAP_SLAPD_V (ldap_pvt_thread_mutex_t)    replog_mutex;
 #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
 LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) passwd_mutex;
 #endif
+#ifndef HAVE_GMTIME_R
 LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) gmtime_mutex;
+#endif
 
 LDAP_SLAPD_V (AccessControl *) global_acl;
 
index f99fb5d37dfd62624de89eaeaa1cb9b0da8453dd..12c2cfcf9fdf77100182cee6b116fcd4d741d039 100644 (file)
@@ -132,6 +132,9 @@ schema_info( Entry **entry, const char **text )
 
        {
                struct          tm *ltm;
+#ifdef HAVE_GMTIME_R
+               struct          tm ltm_buf;
+#endif
                char            timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
 
                /*
@@ -145,10 +148,16 @@ schema_info( Entry **entry, const char **text )
                 * AND modified at server startup time ...
                 */
 
+#ifdef HAVE_GMTIME_R
+               ltm = gmtime_r( &starttime, &ltm_buf );
+#else
                ldap_pvt_thread_mutex_lock( &gmtime_mutex );
                ltm = gmtime( &starttime );
+#endif /* HAVE_GMTIME_R */
                lutil_gentime( timebuf, sizeof(timebuf), ltm );
+#ifndef HAVE_GMTIME_R
                ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+#endif
 
                vals[0].bv_val = timebuf;
                vals[0].bv_len = strlen( timebuf );