- struct slap_csn_entry *pending;
-
- if ( csn == NULL )
- return LDAP_OTHER;
-
- csn->bv_len = lutil_csnstr( csnbuf, len, 0, 0 );
- csn->bv_val = csnbuf;
-
- if ( manage_ctxcsn ) {
- pending = (struct slap_csn_entry *) ch_calloc( 1, sizeof( struct slap_csn_entry ));
- ldap_pvt_thread_mutex_lock( &op->o_bd->be_pcl_mutex );
- ber_dupbv( &op->o_sync_csn, csn );
- pending->csn = ber_dupbv( NULL, csn );
- pending->connid = op->o_connid;
- pending->opid = op->o_opid;
- pending->state = SLAP_CSN_PENDING;
- LDAP_TAILQ_INSERT_TAIL( &op->o_bd->be_pending_csn_list, pending, csn_link );
- ldap_pvt_thread_mutex_unlock( &op->o_bd->be_pcl_mutex );
- }
+ if ( csn == NULL ) return LDAP_OTHER;
+
+#ifndef HAVE_GMTIME_R
+ ldap_pvt_thread_mutex_lock( &gmtime_mutex );
+#endif
+ csn->bv_len = lutil_csnstr( csn->bv_val, csn->bv_len, 0, 0 );
+#ifndef HAVE_GMTIME_R
+ ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+#endif
+
+ if ( manage_ctxcsn )
+ slap_queue_csn( op, csn );