| 689 | } |
| 690 | |
| 691 | static void client_open(ACL_EVENT *event, acl_pthread_pool_t *threads, |
| 692 | ACL_SOCKET fd, const char *remote, const char *local) |
| 693 | { |
| 694 | ACL_VSTREAM *stream; |
| 695 | READ_CTX *ctx; |
| 696 | |
| 697 | #ifdef ACL_UNIX |
| 698 | acl_close_on_exec(fd, ACL_CLOSE_ON_EXEC); |
| 699 | #endif |
| 700 | |
| 701 | increase_client_counter(); |
| 702 | |
| 703 | __use_count++; |
| 704 | |
| 705 | stream = acl_vstream_fdopen(fd, O_RDWR, acl_var_threads_buf_size, |
| 706 | acl_var_threads_rw_timeout, ACL_VSTREAM_TYPE_SOCK); |
| 707 | if (remote) { |
| 708 | acl_vstream_set_peer(stream, remote); |
| 709 | } |
| 710 | if (local) { |
| 711 | acl_vstream_set_local(stream, local); |
| 712 | } |
| 713 | |
| 714 | /** |
| 715 | * when the stream is closed, the callback will be called |
| 716 | * to decrease the counter |
| 717 | */ |
| 718 | acl_vstream_add_close_handle(stream, decrease_counter_callback, NULL); |
| 719 | |
| 720 | /* create one job running in one thread*/ |
| 721 | ctx = create_job(event, threads, stream); |
| 722 | if (ctx->serv_accept != NULL |
| 723 | && ctx->serv_accept(ctx->serv_arg, stream) < 0) { |
| 724 | |
| 725 | if (ctx->serv_close != NULL) { |
| 726 | ctx->serv_close(ctx->serv_arg, stream); |
| 727 | } |
| 728 | acl_vstream_close(stream); |
| 729 | } else { |
| 730 | ctx->event_type = ACL_EVENT_ACCEPT; |
| 731 | acl_pthread_pool_add_job(ctx->threads, ctx->job); |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | void acl_threads_server_enable_read(ACL_EVENT *event, |
| 736 | acl_pthread_pool_t *threads, ACL_VSTREAM *stream) |
no test coverage detected
searching dependent graphs…