unsigned int connected:1;
unsigned int destroying:1;
unsigned int disconnecting:1;
+ unsigned int num_waiting_connections_updated:1;
};
static struct login_proxy_state *proxy_state;
}
i_assert(proxy->state_rec->num_waiting_connections > 0);
proxy->state_rec->num_waiting_connections--;
- proxy->state_rec = NULL;
+ proxy->num_waiting_connections_updated = TRUE;
}
static void
return;
}
proxy->connected = TRUE;
+ proxy->num_waiting_connections_updated = TRUE;
proxy->state_rec->last_success = ioloop_timeval;
i_assert(proxy->state_rec->num_waiting_connections > 0);
proxy->state_rec->num_waiting_connections--;
- proxy->state_rec = NULL;
if ((proxy->ssl_flags & PROXY_SSL_FLAG_YES) != 0 &&
(proxy->ssl_flags & PROXY_SSL_FLAG_STARTTLS) == 0) {
static int login_proxy_connect(struct login_proxy *proxy)
{
- struct login_proxy_record *rec;
+ struct login_proxy_record *rec = proxy->state_rec;
- rec = login_proxy_state_get(proxy_state, &proxy->ip, proxy->port);
if (rec->last_success.tv_sec == 0) {
/* first connect to this IP. don't start immediately failing
the check below. */
proxy_connect_timeout, proxy);
}
+ proxy->num_waiting_connections_updated = FALSE;
proxy->state_rec = rec;
proxy->state_rec->num_waiting_connections++;
return 0;
proxy->connect_timeout_msecs = set->connect_timeout_msecs;
proxy->notify_refresh_secs = set->notify_refresh_secs;
proxy->ssl_flags = set->ssl_flags;
+ proxy->state_rec = login_proxy_state_get(proxy_state, &proxy->ip,
+ proxy->port);
client_ref(client);
if (set->ip.family == 0 &&
if (proxy->to_notify != NULL)
timeout_remove(&proxy->to_notify);
- if (proxy->state_rec != NULL) {
+ if (!proxy->num_waiting_connections_updated) {
i_assert(proxy->state_rec->num_waiting_connections > 0);
proxy->state_rec->num_waiting_connections--;
}