int *methodp, int freeit, void *arg)
{
struct smbldap_state *ldap_state = arg;
+ struct timespec ts;
/** @TODO Should we be doing something to check what servers we rebind to?
Could we get a referral to a machine that we don't want to give our
*methodp = LDAP_AUTH_SIMPLE;
}
- GetTimeOfDay(&ldap_state->last_rebind);
+ clock_gettime_mono(&ts);
+ ldap_state->last_rebind = convert_timespec_to_timeval(ts);
return 0;
}
struct smbldap_state *ldap_state =
(struct smbldap_state *)arg;
int rc;
+ struct timespec ts;
int version;
DEBUG(5,("rebindproc_connect_with_state: Rebinding to %s as \"%s\"\n",
DEBUG(10,("rebindproc_connect_with_state: "
"setting last_rebind timestamp "
"(req: 0x%02x)\n", (unsigned int)request));
- GetTimeOfDay(&ldap_state->last_rebind);
+ clock_gettime_mono(&ts);
+ ldap_state->last_rebind = convert_timespec_to_timeval(ts);
break;
default:
ZERO_STRUCT(ldap_state->last_rebind);
static void smbldap_idle_fn(struct event_context *event_ctx,
struct timed_event *te,
- struct timeval now,
+ struct timeval now_abs,
void *private_data);
/**********************************************************************
bool reopen = False;
SMB_ASSERT(ldap_state);
- if ((ldap_state->ldap_struct != NULL) && ((ldap_state->last_ping + SMBLDAP_DONT_PING_TIME) < time(NULL))) {
+ if ((ldap_state->ldap_struct != NULL) && ((ldap_state->last_ping + SMBLDAP_DONT_PING_TIME) < time_mono(NULL))) {
#ifdef HAVE_UNIXSOCKET
struct sockaddr_un addr;
ldap_state->ldap_struct = NULL;
ldap_state->last_ping = (time_t)0;
} else {
- ldap_state->last_ping = time(NULL);
+ ldap_state->last_ping = time_mono(NULL);
}
}
}
- ldap_state->last_ping = time(NULL);
+ ldap_state->last_ping = time_mono(NULL);
ldap_state->pid = sys_getpid();
TALLOC_FREE(ldap_state->idle_event);
static int another_ldap_try(struct smbldap_state *ldap_state, int *rc,
int *attempts, time_t endtime)
{
- time_t now = time(NULL);
+ time_t now = time_mono(NULL);
int open_rc = LDAP_SERVER_DOWN;
if (*rc != LDAP_SERVER_DOWN)
int rc = LDAP_SERVER_DOWN;
int attempts = 0;
char *utf8_filter;
- time_t endtime = time(NULL)+lp_ldap_timeout();
+ time_t endtime = time_mono(NULL)+lp_ldap_timeout();
struct timeval timeout;
size_t converted_size;
if (ldap_state->last_rebind.tv_sec > 0) {
struct timeval tval;
+ struct timespec ts;
int64_t tdiff = 0;
int sleep_time = 0;
- ZERO_STRUCT(tval);
- GetTimeOfDay(&tval);
+ clock_gettime_mono(&ts);
+ tval = convert_timespec_to_timeval(ts);
tdiff = usec_time_diff(&tval, &ldap_state->last_rebind);
tdiff /= 1000; /* Convert to milliseconds. */
int rc = LDAP_SERVER_DOWN;
int attempts = 0;
char *utf8_dn;
- time_t endtime = time(NULL)+lp_ldap_timeout();
+ time_t endtime = time_mono(NULL)+lp_ldap_timeout();;
size_t converted_size;
SMB_ASSERT(ldap_state);
int rc = LDAP_SERVER_DOWN;
int attempts = 0;
char *utf8_dn;
- time_t endtime = time(NULL)+lp_ldap_timeout();
+ time_t endtime = time_mono(NULL)+lp_ldap_timeout();;
size_t converted_size;
SMB_ASSERT(ldap_state);
int rc = LDAP_SERVER_DOWN;
int attempts = 0;
char *utf8_dn;
- time_t endtime = time(NULL)+lp_ldap_timeout();
+ time_t endtime = time_mono(NULL)+lp_ldap_timeout();;
size_t converted_size;
SMB_ASSERT(ldap_state);
{
int rc = LDAP_SERVER_DOWN;
int attempts = 0;
- time_t endtime = time(NULL)+lp_ldap_timeout();
+ time_t endtime = time_mono(NULL)+lp_ldap_timeout();
if (!ldap_state)
return (-1);
static void smbldap_idle_fn(struct event_context *event_ctx,
struct timed_event *te,
- struct timeval now,
+ struct timeval now_abs,
void *private_data)
{
struct smbldap_state *state = (struct smbldap_state *)private_data;
return;
}
- if ((state->last_use+SMBLDAP_IDLE_TIME) > now.tv_sec) {
+ if ((state->last_use+SMBLDAP_IDLE_TIME) > time_mono(NULL)) {
DEBUG(10,("ldap connection not idle...\n"));
+ /* this needs to be made monotonic clock aware inside tevent: */
state->idle_event = event_add_timed(
event_ctx, NULL,
- timeval_add(&now, SMBLDAP_IDLE_TIME, 0),
+ timeval_add(&now_abs, SMBLDAP_IDLE_TIME, 0),
smbldap_idle_fn,
private_data);
return;