• Home
  • Raw
  • Download

Lines Matching refs:con

116 static void tipc_conn_delete_sub(struct tipc_conn *con, struct tipc_subscr *s);
118 static bool connected(struct tipc_conn *con) in connected() argument
120 return con && test_bit(CF_CONNECTED, &con->flags); in connected()
125 struct tipc_conn *con = container_of(kref, struct tipc_conn, kref); in tipc_conn_kref_release() local
126 struct tipc_topsrv *s = con->server; in tipc_conn_kref_release()
130 idr_remove(&s->conn_idr, con->conid); in tipc_conn_kref_release()
133 if (con->sock) in tipc_conn_kref_release()
134 sock_release(con->sock); in tipc_conn_kref_release()
136 spin_lock_bh(&con->outqueue_lock); in tipc_conn_kref_release()
137 list_for_each_entry_safe(e, safe, &con->outqueue, list) { in tipc_conn_kref_release()
141 spin_unlock_bh(&con->outqueue_lock); in tipc_conn_kref_release()
142 kfree(con); in tipc_conn_kref_release()
145 static void conn_put(struct tipc_conn *con) in conn_put() argument
147 kref_put(&con->kref, tipc_conn_kref_release); in conn_put()
150 static void conn_get(struct tipc_conn *con) in conn_get() argument
152 kref_get(&con->kref); in conn_get()
155 static void tipc_conn_close(struct tipc_conn *con) in tipc_conn_close() argument
157 struct sock *sk = con->sock->sk; in tipc_conn_close()
161 disconnect = test_and_clear_bit(CF_CONNECTED, &con->flags); in tipc_conn_close()
165 tipc_conn_delete_sub(con, NULL); in tipc_conn_close()
174 kernel_sock_shutdown(con->sock, SHUT_RDWR); in tipc_conn_close()
176 conn_put(con); in tipc_conn_close()
181 struct tipc_conn *con; in tipc_conn_alloc() local
184 con = kzalloc(sizeof(*con), GFP_ATOMIC); in tipc_conn_alloc()
185 if (!con) in tipc_conn_alloc()
188 kref_init(&con->kref); in tipc_conn_alloc()
189 INIT_LIST_HEAD(&con->outqueue); in tipc_conn_alloc()
190 INIT_LIST_HEAD(&con->sub_list); in tipc_conn_alloc()
191 spin_lock_init(&con->outqueue_lock); in tipc_conn_alloc()
192 spin_lock_init(&con->sub_lock); in tipc_conn_alloc()
193 INIT_WORK(&con->swork, tipc_conn_send_work); in tipc_conn_alloc()
194 INIT_WORK(&con->rwork, tipc_conn_recv_work); in tipc_conn_alloc()
197 ret = idr_alloc(&s->conn_idr, con, 0, 0, GFP_ATOMIC); in tipc_conn_alloc()
199 kfree(con); in tipc_conn_alloc()
203 con->conid = ret; in tipc_conn_alloc()
206 set_bit(CF_CONNECTED, &con->flags); in tipc_conn_alloc()
207 con->server = s; in tipc_conn_alloc()
208 con->sock = sock; in tipc_conn_alloc()
209 conn_get(con); in tipc_conn_alloc()
212 return con; in tipc_conn_alloc()
217 struct tipc_conn *con; in tipc_conn_lookup() local
220 con = idr_find(&s->conn_idr, conid); in tipc_conn_lookup()
221 if (!connected(con) || !kref_get_unless_zero(&con->kref)) in tipc_conn_lookup()
222 con = NULL; in tipc_conn_lookup()
224 return con; in tipc_conn_lookup()
230 static void tipc_conn_delete_sub(struct tipc_conn *con, struct tipc_subscr *s) in tipc_conn_delete_sub() argument
232 struct tipc_net *tn = tipc_net(con->server->net); in tipc_conn_delete_sub()
233 struct list_head *sub_list = &con->sub_list; in tipc_conn_delete_sub()
236 spin_lock_bh(&con->sub_lock); in tipc_conn_delete_sub()
245 spin_unlock_bh(&con->sub_lock); in tipc_conn_delete_sub()
248 static void tipc_conn_send_to_sock(struct tipc_conn *con) in tipc_conn_send_to_sock() argument
250 struct list_head *queue = &con->outqueue; in tipc_conn_send_to_sock()
251 struct tipc_topsrv *srv = con->server; in tipc_conn_send_to_sock()
259 spin_lock_bh(&con->outqueue_lock); in tipc_conn_send_to_sock()
264 spin_unlock_bh(&con->outqueue_lock); in tipc_conn_send_to_sock()
267 tipc_conn_delete_sub(con, &evt->s); in tipc_conn_send_to_sock()
275 if (con->sock) { in tipc_conn_send_to_sock()
276 ret = kernel_sendmsg(con->sock, &msg, &iov, in tipc_conn_send_to_sock()
282 return tipc_conn_close(con); in tipc_conn_send_to_sock()
293 spin_lock_bh(&con->outqueue_lock); in tipc_conn_send_to_sock()
297 spin_unlock_bh(&con->outqueue_lock); in tipc_conn_send_to_sock()
302 struct tipc_conn *con = container_of(work, struct tipc_conn, swork); in tipc_conn_send_work() local
304 if (connected(con)) in tipc_conn_send_work()
305 tipc_conn_send_to_sock(con); in tipc_conn_send_work()
307 conn_put(con); in tipc_conn_send_work()
318 struct tipc_conn *con; in tipc_topsrv_queue_evt() local
320 con = tipc_conn_lookup(srv, conid); in tipc_topsrv_queue_evt()
321 if (!con) in tipc_topsrv_queue_evt()
324 if (!connected(con)) in tipc_topsrv_queue_evt()
332 spin_lock_bh(&con->outqueue_lock); in tipc_topsrv_queue_evt()
333 list_add_tail(&e->list, &con->outqueue); in tipc_topsrv_queue_evt()
334 spin_unlock_bh(&con->outqueue_lock); in tipc_topsrv_queue_evt()
336 if (queue_work(srv->send_wq, &con->swork)) in tipc_topsrv_queue_evt()
339 conn_put(con); in tipc_topsrv_queue_evt()
348 struct tipc_conn *con; in tipc_conn_write_space() local
351 con = sk->sk_user_data; in tipc_conn_write_space()
352 if (connected(con)) { in tipc_conn_write_space()
353 conn_get(con); in tipc_conn_write_space()
354 if (!queue_work(con->server->send_wq, &con->swork)) in tipc_conn_write_space()
355 conn_put(con); in tipc_conn_write_space()
361 struct tipc_conn *con, in tipc_conn_rcv_sub() argument
370 tipc_conn_delete_sub(con, s); in tipc_conn_rcv_sub()
377 sub = tipc_sub_subscribe(srv->net, s, con->conid); in tipc_conn_rcv_sub()
381 spin_lock_bh(&con->sub_lock); in tipc_conn_rcv_sub()
382 list_add(&sub->sub_list, &con->sub_list); in tipc_conn_rcv_sub()
383 spin_unlock_bh(&con->sub_lock); in tipc_conn_rcv_sub()
387 static int tipc_conn_rcv_from_sock(struct tipc_conn *con) in tipc_conn_rcv_from_sock() argument
389 struct tipc_topsrv *srv = con->server; in tipc_conn_rcv_from_sock()
390 struct sock *sk = con->sock->sk; in tipc_conn_rcv_from_sock()
400 ret = sock_recvmsg(con->sock, &msg, MSG_DONTWAIT); in tipc_conn_rcv_from_sock()
406 if (likely(connected(con))) in tipc_conn_rcv_from_sock()
407 ret = tipc_conn_rcv_sub(srv, con, &s); in tipc_conn_rcv_from_sock()
413 tipc_conn_close(con); in tipc_conn_rcv_from_sock()
419 struct tipc_conn *con = container_of(work, struct tipc_conn, rwork); in tipc_conn_recv_work() local
422 while (connected(con)) { in tipc_conn_recv_work()
423 if (tipc_conn_rcv_from_sock(con)) in tipc_conn_recv_work()
432 conn_put(con); in tipc_conn_recv_work()
440 struct tipc_conn *con; in tipc_conn_data_ready() local
443 con = sk->sk_user_data; in tipc_conn_data_ready()
444 if (connected(con)) { in tipc_conn_data_ready()
445 conn_get(con); in tipc_conn_data_ready()
446 if (!queue_work(con->server->rcv_wq, &con->rwork)) in tipc_conn_data_ready()
447 conn_put(con); in tipc_conn_data_ready()
456 struct tipc_conn *con; in tipc_topsrv_accept() local
472 con = tipc_conn_alloc(srv, newsock); in tipc_topsrv_accept()
473 if (IS_ERR(con)) { in tipc_topsrv_accept()
474 ret = PTR_ERR(con); in tipc_topsrv_accept()
483 newsk->sk_user_data = con; in tipc_topsrv_accept()
488 conn_put(con); in tipc_topsrv_accept()
572 struct tipc_conn *con; in tipc_topsrv_kern_subscr() local
582 con = tipc_conn_alloc(tipc_topsrv(net), NULL); in tipc_topsrv_kern_subscr()
583 if (IS_ERR(con)) in tipc_topsrv_kern_subscr()
586 *conid = con->conid; in tipc_topsrv_kern_subscr()
587 rc = tipc_conn_rcv_sub(tipc_topsrv(net), con, &sub); in tipc_topsrv_kern_subscr()
589 conn_put(con); in tipc_topsrv_kern_subscr()
591 conn_put(con); in tipc_topsrv_kern_subscr()
597 struct tipc_conn *con; in tipc_topsrv_kern_unsubscr() local
599 con = tipc_conn_lookup(tipc_topsrv(net), conid); in tipc_topsrv_kern_unsubscr()
600 if (!con) in tipc_topsrv_kern_unsubscr()
603 test_and_clear_bit(CF_CONNECTED, &con->flags); in tipc_topsrv_kern_unsubscr()
604 tipc_conn_delete_sub(con, NULL); in tipc_topsrv_kern_unsubscr()
605 conn_put(con); in tipc_topsrv_kern_unsubscr()
606 conn_put(con); in tipc_topsrv_kern_unsubscr()
695 struct tipc_conn *con; in tipc_topsrv_stop() local
700 con = idr_find(&srv->conn_idr, id); in tipc_topsrv_stop()
701 if (con) { in tipc_topsrv_stop()
703 tipc_conn_close(con); in tipc_topsrv_stop()