diff options
-rw-r--r-- | source3/include/local.h | 2 | ||||
-rw-r--r-- | source3/lib/smbldap.c | 23 | ||||
-rw-r--r-- | source3/printing/notify.c | 2 | ||||
-rw-r--r-- | source3/smbd/utmp.c | 4 | ||||
-rw-r--r-- | source3/torture/torture.c | 4 |
5 files changed, 18 insertions, 17 deletions
diff --git a/source3/include/local.h b/source3/include/local.h index ee8d672553..7ac2e25612 100644 --- a/source3/include/local.h +++ b/source3/include/local.h @@ -233,4 +233,6 @@ /* Number of microseconds to wait before a sharing violation. */ #define SHARING_VIOLATION_USEC_WAIT 950000 +#define MAX_LDAP_REPLICATION_SLEEP_TIME 5000 /* In milliseconds. */ + #endif diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c index 6e233fe990..d058613f00 100644 --- a/source3/lib/smbldap.c +++ b/source3/lib/smbldap.c @@ -676,7 +676,7 @@ static int rebindproc_with_state (LDAP * ld, char **whop, char **credp, *methodp = LDAP_AUTH_SIMPLE; } - gettimeofday(&(ldap_state->last_rebind),NULL); + GetTimeOfDay(&ldap_state->last_rebind); return 0; } @@ -704,7 +704,7 @@ static int rebindproc_connect_with_state (LDAP *ldap_struct, rc = ldap_simple_bind_s(ldap_struct, ldap_state->bind_dn, ldap_state->bind_secret); - gettimeofday(&(ldap_state->last_rebind),NULL); + GetTimeOfDay(&ldap_state->last_rebind); return rc; } @@ -755,8 +755,7 @@ static int smbldap_connect_system(struct smbldap_state *ldap_state, LDAP * ldap_ char *ldap_secret; /* get the password */ - if (!fetch_ldap_pw(&ldap_dn, &ldap_secret)) - { + if (!fetch_ldap_pw(&ldap_dn, &ldap_secret)) { DEBUG(0, ("ldap_connect_system: Failed to retrieve password from secrets.tdb\n")); return LDAP_INVALID_CREDENTIALS; } @@ -854,7 +853,7 @@ static int smbldap_open(struct smbldap_state *ldap_state) ldap_state->last_ping = time(NULL); - DEBUG(4,("The LDAP server is succesful connected\n")); + DEBUG(4,("The LDAP server is succesfully connected\n")); return LDAP_SUCCESS; } @@ -933,25 +932,25 @@ int smbldap_search(struct smbldap_state *ldap_state, if (ldap_state->last_rebind.tv_sec > 0) { struct timeval tval; - int tdiff = 0; + SMB_BIG_INT tdiff = 0; int sleep_time = 0; ZERO_STRUCT(tval); + GetTimeOfDay(&tval); - gettimeofday(&tval,NULL); - - tdiff = 1000000 *(tval.tv_sec - ldap_state->last_rebind.tv_sec) + - (tval.tv_usec - ldap_state->last_rebind.tv_usec); + tdiff = usec_time_diff(&tval, &ldap_state->last_rebind.tv_sec); + tdiff /= 1000; /* Convert to milliseconds. */ - sleep_time = ((1000*lp_ldap_replication_sleep())-tdiff)/1000; + sleep_time = lp_ldap_replication_sleep()-(int)tdiff; + sleep_time = MIN(sleep_time, MAX_LDAP_REPLICATION_SLEEP_TIME); if (sleep_time > 0) { /* we wait for the LDAP replication */ DEBUG(5,("smbldap_search: waiting %d milliseconds for LDAP replication.\n",sleep_time)); smb_msleep(sleep_time); DEBUG(5,("smbldap_search: go on!\n")); - ZERO_STRUCT(ldap_state->last_rebind); } + ZERO_STRUCT(ldap_state->last_rebind); } if (push_utf8_allocate(&utf8_filter, filter) == (size_t)-1) { diff --git a/source3/printing/notify.c b/source3/printing/notify.c index 26ef191f87..8d5be13607 100644 --- a/source3/printing/notify.c +++ b/source3/printing/notify.c @@ -278,7 +278,7 @@ in notify_queue\n", msg->type, msg->field, msg->printer)); return; } copy_notify2_msg(pnqueue->msg, msg); - gettimeofday(&pnqueue->tv, NULL); + GetTimeOfDay(&pnqueue->tv); pnqueue->buf = NULL; pnqueue->buflen = 0; diff --git a/source3/smbd/utmp.c b/source3/smbd/utmp.c index a521d0113d..b1735dfcc4 100644 --- a/source3/smbd/utmp.c +++ b/source3/smbd/utmp.c @@ -514,10 +514,10 @@ static BOOL sys_utmp_fill(struct utmp *u, * But note that we do the more precise ut_tv as the final assignment. */ #if defined(HAVE_UT_UT_TIME) - gettimeofday(&timeval, NULL); + GetTimeOfDay(&timeval); u->ut_time = timeval.tv_sec; #elif defined(HAVE_UT_UT_TV) - gettimeofday(&timeval, NULL); + GetTimeOfDay(&timeval); u->ut_tv = timeval; #else #error "with-utmp must have UT_TIME or UT_TV" diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 161aa2cd73..cd797c5a8f 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -45,12 +45,12 @@ static struct timeval tp1,tp2; void start_timer(void) { - gettimeofday(&tp1,NULL); + GetTimeOfDay(&tp1 } double end_timer(void) { - gettimeofday(&tp2,NULL); + GetTimeOfDay(&tp2); return((tp2.tv_sec - tp1.tv_sec) + (tp2.tv_usec - tp1.tv_usec)*1.0e-6); } |