Lines Matching defs:conn_data
48 struct sdap_id_conn_data *conn_data;
84 static void sdap_id_release_conn_data(struct sdap_id_conn_data *conn_data);
85 static int sdap_id_conn_data_destroy(struct sdap_id_conn_data *conn_data);
86 static bool sdap_is_connection_expired(struct sdap_id_conn_data *conn_data, int timeout);
87 static bool sdap_can_reuse_connection(struct sdap_id_conn_data *conn_data);
92 static int sdap_id_conn_data_set_expire_timer(struct sdap_id_conn_data *conn_data);
94 static void sdap_id_op_hook_conn_data(struct sdap_id_op *op, struct sdap_id_conn_data *conn_data);
169 static void sdap_id_release_conn_data(struct sdap_id_conn_data *conn_data)
172 if (!conn_data || conn_data->ops || conn_data->notify_lock) {
177 conn_cache = conn_data->conn_cache;
178 if (conn_data == conn_cache->cached_connection) {
184 DLIST_REMOVE(conn_cache->connections, conn_data);
185 talloc_zfree(conn_data);
189 static int sdap_id_conn_data_destroy(struct sdap_id_conn_data *conn_data)
194 while ((op = conn_data->ops) != NULL) {
195 op->conn_data = NULL;
196 DLIST_REMOVE(conn_data->ops, op);
203 static bool sdap_is_connection_expired(struct sdap_id_conn_data *conn_data, int timeout)
206 if (!conn_data || !conn_data->sh || !conn_data->sh->connected) {
210 expire_time = conn_data->sh->expire_time;
219 static bool sdap_can_reuse_connection(struct sdap_id_conn_data *conn_data)
223 if (!conn_data || !conn_data->sh ||
224 !conn_data->sh->connected || conn_data->disconnecting) {
228 timeout = dp_opt_get_int(conn_data->conn_cache->id_conn->id_ctx->opts->basic,
230 return !sdap_is_connection_expired(conn_data, timeout);
234 static int sdap_id_conn_data_set_expire_timer(struct sdap_id_conn_data *conn_data)
241 tv.tv_sec = conn_data->sh->expire_time;
246 timeout = dp_opt_get_int(conn_data->conn_cache->id_conn->id_ctx->opts->basic,
256 talloc_zfree(conn_data->expire_timer);
258 conn_data->expire_timer =
259 tevent_add_timer(conn_data->conn_cache->id_conn->id_ctx->be->ev,
260 conn_data, tv,
262 conn_data);
263 if (!conn_data->expire_timer) {
276 struct sdap_id_conn_data *conn_data = talloc_get_type(pvt,
278 struct sdap_id_conn_cache *conn_cache = conn_data->conn_cache;
283 if (conn_cache->cached_connection == conn_data) {
286 sdap_id_release_conn_data(conn_data);
305 static void sdap_id_op_hook_conn_data(struct sdap_id_op *op, struct sdap_id_conn_data *conn_data)
312 struct sdap_id_conn_data *current = op->conn_data;
313 if (conn_data == current) {
321 op->conn_data = conn_data;
323 if (conn_data) {
324 DLIST_ADD_END(conn_data->ops, op, struct sdap_id_op*);
337 if (op->conn_data) {
422 if (op->conn_data) {
438 } else if (op->conn_data && !op->conn_data->connect_req) {
460 struct sdap_id_conn_data *conn_data;
464 conn_data = conn_cache->cached_connection;
465 if (conn_data) {
466 if (conn_data->connect_req) {
468 sdap_id_op_hook_conn_data(op, conn_data);
472 if (sdap_can_reuse_connection(conn_data)) {
474 sdap_id_op_hook_conn_data(op, conn_data);
480 sdap_id_release_conn_data(conn_data);
485 conn_data = talloc_zero(conn_cache, struct sdap_id_conn_data);
486 if (!conn_data) {
491 talloc_set_destructor(conn_data, sdap_id_conn_data_destroy);
493 conn_data->conn_cache = conn_cache;
494 subreq = sdap_cli_connect_send(conn_data, state->ev,
505 tevent_req_set_callback(subreq, sdap_id_op_connect_done, conn_data);
506 conn_data->connect_req = subreq;
508 DLIST_ADD(conn_cache->connections, conn_data);
509 conn_cache->cached_connection = conn_data;
511 sdap_id_op_hook_conn_data(op, conn_data);
514 if (ret != EOK && conn_data) {
515 sdap_id_release_conn_data(conn_data);
530 struct sdap_id_conn_data *conn_data =
532 struct sdap_id_conn_cache *conn_cache = conn_data->conn_cache;
541 ret = sdap_cli_connect_recv(subreq, conn_data, &can_retry,
542 &conn_data->sh, &srv_opts);
543 conn_data->connect_req = NULL;
546 conn_data->notify_lock++;
553 if (ret == EOK && (!conn_data->sh || !conn_data->sh->connected)) {
594 ret = sdap_id_conn_data_set_expire_timer(conn_data);
636 if (ret == EOK && !conn_data->sh->connected) {
641 DLIST_FOR_EACH(op, conn_data->ops) {
654 if (ret != EOK || !conn_data->sh->connected) {
659 if (conn_cache->cached_connection == conn_data) {
715 if (conn_data->notify_lock > 0) {
716 conn_data->notify_lock--;
720 conn_data->sh->connected &&
724 conn_cache->cached_connection = conn_data;
731 if (conn_cache->cached_connection == conn_data) {
735 sdap_id_release_conn_data(conn_data);
822 struct sdap_id_conn_data *current_conn = op->conn_data;
891 return op && op->conn_data ? op->conn_data->sh : NULL;