• Home
  • Raw
  • Download

Lines Matching refs:sdkctl

136     SDKCtlSocket*           sdkctl;  member
164 SDKCtlSocket* sdkctl; member
214 SDKCtlSocket* sdkctl; member
310 SDKCtlSocket* sdkctl; member
379 _sdkctl_socket_alloc_recycler(SDKCtlSocket* sdkctl, uint32_t size) in _sdkctl_socket_alloc_recycler() argument
383 if (sdkctl->recycler != NULL && size <= sdkctl->recycler_block_size) { in _sdkctl_socket_alloc_recycler()
384 assert(sdkctl->recycler_count > 0); in _sdkctl_socket_alloc_recycler()
386 block = sdkctl->recycler; in _sdkctl_socket_alloc_recycler()
387 sdkctl->recycler = block->next; in _sdkctl_socket_alloc_recycler()
388 block->size = sdkctl->recycler_block_size; in _sdkctl_socket_alloc_recycler()
389 sdkctl->recycler_count--; in _sdkctl_socket_alloc_recycler()
390 } else if (size <= sdkctl->recycler_block_size) { in _sdkctl_socket_alloc_recycler()
393 block = malloc(sdkctl->recycler_block_size); in _sdkctl_socket_alloc_recycler()
396 sdkctl->service_name, sdkctl->recycler_block_size); in _sdkctl_socket_alloc_recycler()
398 block->size = sdkctl->recycler_block_size; in _sdkctl_socket_alloc_recycler()
404 sdkctl->service_name, size); in _sdkctl_socket_alloc_recycler()
414 _sdkctl_socket_free_recycler(SDKCtlSocket* sdkctl, void* mem) in _sdkctl_socket_free_recycler() argument
418 if (block->size != sdkctl->recycler_block_size || in _sdkctl_socket_free_recycler()
419 sdkctl->recycler_count == sdkctl->recycler_max) { in _sdkctl_socket_free_recycler()
424 assert(sdkctl->recycler_count >= 0); in _sdkctl_socket_free_recycler()
425 block->next = sdkctl->recycler; in _sdkctl_socket_free_recycler()
426 sdkctl->recycler = block; in _sdkctl_socket_free_recycler()
427 sdkctl->recycler_count++; in _sdkctl_socket_free_recycler()
433 _sdkctl_socket_empty_recycler(SDKCtlSocket* sdkctl) in _sdkctl_socket_empty_recycler() argument
435 SDKCtlRecycled* block = sdkctl->recycler; in _sdkctl_socket_empty_recycler()
441 sdkctl->recycler = NULL; in _sdkctl_socket_empty_recycler()
442 sdkctl->recycler_count = 0; in _sdkctl_socket_empty_recycler()
457 SDKCtlSocket* const sdkctl = query->sdkctl; in _sdkctl_socket_add_query() local
458 if (sdkctl->query_head == NULL) { in _sdkctl_socket_add_query()
459 assert(sdkctl->query_tail == NULL); in _sdkctl_socket_add_query()
460 sdkctl->query_head = sdkctl->query_tail = query; in _sdkctl_socket_add_query()
462 sdkctl->query_tail->next = query; in _sdkctl_socket_add_query()
463 sdkctl->query_tail = query; in _sdkctl_socket_add_query()
482 SDKCtlSocket* const sdkctl = query->sdkctl; in _sdkctl_socket_remove_query() local
484 SDKCtlQuery* head = sdkctl->query_head; in _sdkctl_socket_remove_query()
487 if (sdkctl->io_dispatcher.current_query == query) { in _sdkctl_socket_remove_query()
489 sdkctl->io_dispatcher.current_query = NULL; in _sdkctl_socket_remove_query()
501 sdkctl->service_name, query); in _sdkctl_socket_remove_query()
507 assert(query == sdkctl->query_head); in _sdkctl_socket_remove_query()
508 sdkctl->query_head = query->next; in _sdkctl_socket_remove_query()
511 assert(query != sdkctl->query_head); in _sdkctl_socket_remove_query()
514 if (sdkctl->query_tail == query) { in _sdkctl_socket_remove_query()
517 sdkctl->query_tail = prev; in _sdkctl_socket_remove_query()
540 _sdkctl_socket_remove_query_id(SDKCtlSocket* sdkctl, int query_id) in _sdkctl_socket_remove_query_id() argument
544 SDKCtlQuery* head = sdkctl->query_head; in _sdkctl_socket_remove_query_id()
547 if (sdkctl->io_dispatcher.current_query != NULL && in _sdkctl_socket_remove_query_id()
548 sdkctl->io_dispatcher.current_query->header.query_id == query_id) { in _sdkctl_socket_remove_query_id()
550 query = sdkctl->io_dispatcher.current_query; in _sdkctl_socket_remove_query_id()
551 sdkctl->io_dispatcher.current_query = NULL; in _sdkctl_socket_remove_query_id()
562 sdkctl->service_name, query_id); in _sdkctl_socket_remove_query_id()
570 assert(query == sdkctl->query_head); in _sdkctl_socket_remove_query_id()
571 sdkctl->query_head = query->next; in _sdkctl_socket_remove_query_id()
574 assert(query != sdkctl->query_head); in _sdkctl_socket_remove_query_id()
577 if (sdkctl->query_tail == query) { in _sdkctl_socket_remove_query_id()
580 sdkctl->query_tail = prev; in _sdkctl_socket_remove_query_id()
595 _sdkctl_socket_pull_first_query(SDKCtlSocket* sdkctl) in _sdkctl_socket_pull_first_query() argument
597 SDKCtlQuery* const query = sdkctl->query_head; in _sdkctl_socket_pull_first_query()
600 sdkctl->query_head = query->next; in _sdkctl_socket_pull_first_query()
601 if (sdkctl->query_head == NULL) { in _sdkctl_socket_pull_first_query()
602 sdkctl->query_tail = NULL; in _sdkctl_socket_pull_first_query()
610 _sdkctl_socket_next_query_id(SDKCtlSocket* sdkctl) in _sdkctl_socket_next_query_id() argument
612 return ++sdkctl->next_query_id; in _sdkctl_socket_next_query_id()
621 _sdkctl_packet_new(SDKCtlSocket* sdkctl, uint32_t size, int type) in _sdkctl_packet_new() argument
625 _sdkctl_socket_alloc_recycler(sdkctl, sizeof(SDKCtlPacket) + size); in _sdkctl_packet_new()
627 packet->sdkctl = sdkctl; in _sdkctl_packet_new()
634 sdkctl_socket_reference(sdkctl); in _sdkctl_packet_new()
637 sdkctl->service_name, packet, type, size); in _sdkctl_packet_new()
646 SDKCtlSocket* const sdkctl = packet->sdkctl; in _sdkctl_packet_free() local
649 _sdkctl_socket_free_recycler(packet->sdkctl, packet); in _sdkctl_packet_free()
651 T("SDKCtl %s: Packet %p is freed.", sdkctl->service_name, packet); in _sdkctl_packet_free()
654 sdkctl_socket_release(sdkctl); in _sdkctl_packet_free()
702 packet->sdkctl->service_name, packet); in _on_sdkctl_packet_send_io()
707 packet->sdkctl->service_name, packet); in _on_sdkctl_packet_send_io()
712 packet->sdkctl->service_name, packet, errno, strerror(errno)); in _on_sdkctl_packet_send_io()
743 async_socket_write_rel(packet->sdkctl->as, &packet->header, packet->header.size, in _sdkctl_packet_transmit()
747 packet->sdkctl->service_name, packet, packet->header.size); in _sdkctl_packet_transmit()
755 sdkctl_direct_packet_new(SDKCtlSocket* sdkctl) in sdkctl_direct_packet_new() argument
758 _sdkctl_socket_alloc_recycler(sdkctl, sizeof(SDKCtlDirectPacket)); in sdkctl_direct_packet_new()
760 packet->sdkctl = sdkctl; in sdkctl_direct_packet_new()
764 sdkctl_socket_reference(packet->sdkctl); in sdkctl_direct_packet_new()
766 T("SDKCtl %s: Direct packet %p is allocated.", sdkctl->service_name, packet); in sdkctl_direct_packet_new()
775 SDKCtlSocket* const sdkctl = packet->sdkctl; in _sdkctl_direct_packet_free() local
778 _sdkctl_socket_free_recycler(packet->sdkctl, packet); in _sdkctl_direct_packet_free()
780 T("SDKCtl %s: Direct packet %p is freed.", sdkctl->service_name, packet); in _sdkctl_direct_packet_free()
783 sdkctl_socket_release(sdkctl); in _sdkctl_direct_packet_free()
832 packet->sdkctl->service_name, packet); in _on_sdkctl_direct_packet_send_io()
838 packet->sdkctl->service_name, packet); in _on_sdkctl_direct_packet_send_io()
844 packet->sdkctl->service_name, packet, errno, strerror(errno)); in _on_sdkctl_direct_packet_send_io()
878 async_socket_write_rel(packet->sdkctl->as, packet->packet, packet->packet->size, in sdkctl_direct_packet_send()
882 packet->sdkctl->service_name, packet, packet->packet->size); in sdkctl_direct_packet_send()
891 _sdkctl_message_new(SDKCtlSocket* sdkctl, uint32_t msg_size, int msg_type) in _sdkctl_message_new() argument
894 (SDKCtlMessage*)_sdkctl_packet_new(sdkctl, in _sdkctl_message_new()
915 sdkctl_message_send(SDKCtlSocket* sdkctl, in sdkctl_message_send() argument
920 SDKCtlMessage* const msg = _sdkctl_message_new(sdkctl, size, msg_type); in sdkctl_message_send()
955 SDKCtlSocket* const sdkctl = query->sdkctl; in _sdkctl_query_free() local
967 _sdkctl_socket_free_recycler(sdkctl, query); in _sdkctl_query_free()
969 T("SDKCtl %s: Query %p is freed.", sdkctl->service_name, query); in _sdkctl_query_free()
972 sdkctl_socket_release(sdkctl); in _sdkctl_query_free()
989 query->sdkctl->service_name, query, query->header.query_id, query->deadline); in _sdkctl_query_cancel_timeout()
1003 query->sdkctl->service_name, query, query->header.query_id); in _on_sdkctl_query_completed()
1036 query->sdkctl->service_name, query, query->header.query_id, in _on_skdctl_query_timeout()
1037 query->deadline, async_socket_deadline(query->sdkctl->as, 0)); in _on_skdctl_query_timeout()
1060 query->sdkctl->service_name, query->header.packet.size, query, in _on_sdkctl_query_sent()
1097 query->sdkctl->service_name, query, query->header.query_id); in _on_sdkctl_query_send_io()
1105 query->sdkctl->service_name, query, query->header.query_id, in _on_sdkctl_query_send_io()
1106 query->deadline, async_socket_deadline(query->sdkctl->as, 0)); in _on_sdkctl_query_send_io()
1117 query->sdkctl->service_name, query, query->header.query_id, in _on_sdkctl_query_send_io()
1148 sdkctl_query_new(SDKCtlSocket* sdkctl, int query_type, uint32_t in_data_size) in sdkctl_query_new() argument
1151 _sdkctl_socket_alloc_recycler(sdkctl, sizeof(SDKCtlQuery) + in_data_size); in sdkctl_query_new()
1153 query->sdkctl = sdkctl; in sdkctl_query_new()
1165 query->header.query_id = _sdkctl_socket_next_query_id(sdkctl); in sdkctl_query_new()
1169 loopTimer_init(query->timer, sdkctl->looper, _on_skdctl_query_timeout, query); in sdkctl_query_new()
1172 sdkctl_socket_reference(sdkctl); in sdkctl_query_new()
1175 query->sdkctl->service_name, query, query->header.query_id, in sdkctl_query_new()
1182 sdkctl_query_new_ex(SDKCtlSocket* sdkctl, in sdkctl_query_new_ex() argument
1191 SDKCtlQuery* const query = sdkctl_query_new(sdkctl, query_type, in_data_size); in sdkctl_query_new_ex()
1217 SDKCtlSocket* const sdkctl = query->sdkctl; in sdkctl_query_send() local
1220 query->deadline = async_socket_deadline(query->sdkctl->as, to); in sdkctl_query_send()
1230 async_socket_write_abs(sdkctl->as, &query->header, query->header.packet.size, in sdkctl_query_send()
1234 query->sdkctl->service_name, query, query->header.query_id, in sdkctl_query_send()
1239 sdkctl_query_build_and_send(SDKCtlSocket* sdkctl, in sdkctl_query_build_and_send() argument
1250 sdkctl_query_new_ex(sdkctl, query_type, in_data_size, in_data, in sdkctl_query_build_and_send()
1300 _on_sdkctl_packet_received(SDKCtlSocket* sdkctl, SDKCtlPacket* packet) in _on_sdkctl_packet_received() argument
1303 sdkctl->service_name, packet->header.size, packet->header.type); in _on_sdkctl_packet_received()
1311 sdkctl->port_status = SDKCTL_PORT_CONNECTED; in _on_sdkctl_packet_received()
1312 sdkctl->on_port_connection(sdkctl->opaque, sdkctl, in _on_sdkctl_packet_received()
1317 sdkctl->port_status = SDKCTL_PORT_DISCONNECTED; in _on_sdkctl_packet_received()
1318 sdkctl->on_port_connection(sdkctl->opaque, sdkctl, in _on_sdkctl_packet_received()
1323 sdkctl->port_status = SDKCTL_PORT_ENABLED; in _on_sdkctl_packet_received()
1324 sdkctl->on_port_connection(sdkctl->opaque, sdkctl, in _on_sdkctl_packet_received()
1329 sdkctl->port_status = SDKCTL_PORT_DISABLED; in _on_sdkctl_packet_received()
1330 sdkctl->on_port_connection(sdkctl->opaque, sdkctl, in _on_sdkctl_packet_received()
1337 sdkctl->on_message(sdkctl->opaque, sdkctl, msg, msg->msg_type, msg + 1, in _on_sdkctl_packet_received()
1343 sdkctl->service_name, packet->header.type, packet->header.size); in _on_sdkctl_packet_received()
1363 _sdkctl_io_dispatcher_start(SDKCtlSocket* sdkctl) { in _sdkctl_io_dispatcher_start() argument
1364 SDKCtlIODispatcher* const dispatcher = &sdkctl->io_dispatcher; in _sdkctl_io_dispatcher_start()
1367 dispatcher->sdkctl = sdkctl; in _sdkctl_io_dispatcher_start()
1372 async_socket_read_rel(dispatcher->sdkctl->as, &dispatcher->packet_header, in _sdkctl_io_dispatcher_start()
1379 _sdkctl_io_dispatcher_reset(SDKCtlSocket* sdkctl) { in _sdkctl_io_dispatcher_reset() argument
1380 SDKCtlIODispatcher* const dispatcher = &sdkctl->io_dispatcher; in _sdkctl_io_dispatcher_reset()
1399 T("SDKCtl %s: I/O Dispatcher is reset", sdkctl->service_name); in _sdkctl_io_dispatcher_reset()
1413 SDKCtlSocket* const sdkctl = dispatcher->sdkctl; in _on_io_dispatcher_io_failure() local
1416 sdkctl->service_name, errno, strerror(errno)); in _on_io_dispatcher_io_failure()
1420 sdkctl_socket_disconnect(sdkctl); in _on_io_dispatcher_io_failure()
1424 sdkctl->on_socket_connection(sdkctl->opaque, sdkctl, ASIO_STATE_FAILED); in _on_io_dispatcher_io_failure()
1432 T("SDKCtl %s: Dispatcher I/O cancelled.", dispatcher->sdkctl->service_name); in _on_io_dispatcher_io_cancelled()
1455 SDKCtlSocket* const sdkctl = dispatcher->sdkctl; in _on_io_dispatcher_packet_header() local
1458 dispatcher->sdkctl->service_name, dispatcher->packet_header.type, in _on_io_dispatcher_packet_header()
1464 sdkctl->service_name, dispatcher->packet_header.signature, in _on_io_dispatcher_packet_header()
1487 async_socket_read_rel(sdkctl->as, &dispatcher->query_reply_header.query_id, in _on_io_dispatcher_packet_header()
1496 _sdkctl_packet_new(sdkctl, dispatcher->packet_header.size, in _on_io_dispatcher_packet_header()
1499 async_socket_read_rel(sdkctl->as, dispatcher->packet + 1, in _on_io_dispatcher_packet_header()
1511 SDKCtlSocket* const sdkctl = dispatcher->sdkctl; in _on_io_dispatcher_packet() local
1516 dispatcher->sdkctl->service_name, dispatcher->packet_header.type, in _on_io_dispatcher_packet()
1519 _on_sdkctl_packet_received(sdkctl, packet); in _on_io_dispatcher_packet()
1524 async_socket_read_rel(sdkctl->as, &dispatcher->packet_header, sizeof(SDKCtlPacketHeader), in _on_io_dispatcher_packet()
1534 SDKCtlSocket* const sdkctl = dispatcher->sdkctl; in _on_io_dispatcher_query_reply_header() local
1538 dispatcher->sdkctl->service_name, dispatcher->query_reply_header.query_id); in _on_io_dispatcher_query_reply_header()
1543 _sdkctl_socket_remove_query_id(sdkctl, dispatcher->query_reply_header.query_id); in _on_io_dispatcher_query_reply_header()
1551 dispatcher->sdkctl->service_name, dispatcher->query_reply_header.query_id); in _on_io_dispatcher_query_reply_header()
1557 _sdkctl_packet_new(sdkctl, dispatcher->packet_header.size, in _on_io_dispatcher_query_reply_header()
1562 async_socket_read_rel(sdkctl->as, dispatcher->packet + 1, query_data_size, in _on_io_dispatcher_query_reply_header()
1574 sdkctl->service_name, query_data_size); in _on_io_dispatcher_query_reply_header()
1581 async_socket_read_rel(sdkctl->as, *query->response_buffer, in _on_io_dispatcher_query_reply_header()
1593 SDKCtlSocket* const sdkctl = dispatcher->sdkctl; in _on_io_dispatcher_query_reply() local
1600 sdkctl->service_name); in _on_io_dispatcher_query_reply()
1602 dispatcher->sdkctl->service_name, query, query->header.query_id, in _on_io_dispatcher_query_reply()
1619 async_socket_read_rel(sdkctl->as, &dispatcher->packet_header, sizeof(SDKCtlPacketHeader), in _on_io_dispatcher_query_reply()
1638 SDKCtlSocket* const sdkctl = dispatcher->sdkctl; in _on_sdkctl_io_dispatcher_io() local
1641 sdkctl_socket_reference(sdkctl); in _on_sdkctl_io_dispatcher_io()
1664 sdkctl->service_name); in _on_sdkctl_io_dispatcher_io()
1680 sdkctl->service_name, status); in _on_sdkctl_io_dispatcher_io()
1688 sdkctl_socket_release(sdkctl); in _on_sdkctl_io_dispatcher_io()
1718 sdkctl->service_name, dispatcher->state); in _on_sdkctl_io_dispatcher_io()
1722 sdkctl_socket_release(sdkctl); in _on_sdkctl_io_dispatcher_io()
1733 _sdkctl_socket_cancel_all_queries(SDKCtlSocket* sdkctl) in _sdkctl_socket_cancel_all_queries() argument
1735 SDKCtlIODispatcher* const dispatcher = &sdkctl->io_dispatcher; in _sdkctl_socket_cancel_all_queries()
1747 query = _sdkctl_socket_pull_first_query(sdkctl); in _sdkctl_socket_cancel_all_queries()
1752 query = _sdkctl_socket_pull_first_query(sdkctl); in _sdkctl_socket_cancel_all_queries()
1758 _sdkctl_socket_cancel_all_packets(SDKCtlSocket* sdkctl) in _sdkctl_socket_cancel_all_packets() argument
1764 _sdkctl_socket_cancel_all_io(SDKCtlSocket* sdkctl) in _sdkctl_socket_cancel_all_io() argument
1767 _sdkctl_socket_cancel_all_queries(sdkctl); in _sdkctl_socket_cancel_all_io()
1768 _sdkctl_socket_cancel_all_packets(sdkctl); in _sdkctl_socket_cancel_all_io()
1773 _sdkctl_socket_disconnect_socket(SDKCtlSocket* sdkctl) in _sdkctl_socket_disconnect_socket() argument
1775 if (sdkctl->as != NULL) { in _sdkctl_socket_disconnect_socket()
1777 async_socket_disconnect(sdkctl->as); in _sdkctl_socket_disconnect_socket()
1780 _sdkctl_socket_cancel_all_io(sdkctl); in _sdkctl_socket_disconnect_socket()
1783 _sdkctl_io_dispatcher_reset(sdkctl); in _sdkctl_socket_disconnect_socket()
1786 sdkctl->state = SDKCTL_SOCKET_DISCONNECTED; in _sdkctl_socket_disconnect_socket()
1787 sdkctl->port_status = SDKCTL_PORT_DISCONNECTED; in _sdkctl_socket_disconnect_socket()
1792 _sdkctl_socket_free(SDKCtlSocket* sdkctl) in _sdkctl_socket_free() argument
1794 if (sdkctl != NULL) { in _sdkctl_socket_free()
1795 T("SDKCtl %s: descriptor is destroing.", sdkctl->service_name); in _sdkctl_socket_free()
1798 if (sdkctl->as != NULL) { in _sdkctl_socket_free()
1799 async_socket_disconnect(sdkctl->as); in _sdkctl_socket_free()
1800 async_socket_release(sdkctl->as); in _sdkctl_socket_free()
1804 if (sdkctl->looper != NULL) { in _sdkctl_socket_free()
1805 looper_free(sdkctl->looper); in _sdkctl_socket_free()
1807 if (sdkctl->service_name != NULL) { in _sdkctl_socket_free()
1808 free(sdkctl->service_name); in _sdkctl_socket_free()
1810 _sdkctl_socket_empty_recycler(sdkctl); in _sdkctl_socket_free()
1812 AFREE(sdkctl); in _sdkctl_socket_free()
1821 static void _sdkctl_do_handshake(SDKCtlSocket* sdkctl);
1827 _on_async_socket_connected(SDKCtlSocket* sdkctl) in _on_async_socket_connected() argument
1829 D("SDKCtl %s: Socket is connected.", sdkctl->service_name); in _on_async_socket_connected()
1833 sdkctl->on_socket_connection(sdkctl->opaque, sdkctl, ASIO_STATE_SUCCEEDED); in _on_async_socket_connected()
1837 _sdkctl_io_dispatcher_start(sdkctl); in _on_async_socket_connected()
1840 _sdkctl_do_handshake(sdkctl); in _on_async_socket_connected()
1851 _on_async_socket_disconnected(SDKCtlSocket* sdkctl) in _on_async_socket_disconnected() argument
1853 D("SDKCtl %s: Socket has been disconnected.", sdkctl->service_name); in _on_async_socket_disconnected()
1855 _sdkctl_socket_disconnect_socket(sdkctl); in _on_async_socket_disconnected()
1857 AsyncIOAction action = sdkctl->on_socket_connection(sdkctl->opaque, sdkctl, in _on_async_socket_disconnected()
1864 sdkctl->state = SDKCTL_SOCKET_CONNECTING; in _on_async_socket_disconnected()
1880 SDKCtlSocket* const sdkctl = (SDKCtlSocket*)client_opaque; in _on_async_socket_connection() local
1883 sdkctl_socket_reference(sdkctl); in _on_async_socket_connection()
1887 sdkctl->state = SDKCTL_SOCKET_CONNECTED; in _on_async_socket_connection()
1888 _on_async_socket_connected(sdkctl); in _on_async_socket_connection()
1892 if (sdkctl->state == SDKCTL_SOCKET_CONNECTED) { in _on_async_socket_connection()
1894 action = _on_async_socket_disconnected(sdkctl); in _on_async_socket_connection()
1908 sdkctl_socket_release(sdkctl); in _on_async_socket_connection()
1925 SDKCtlSocket* sdkctl; in sdkctl_socket_new() local
1926 ANEW0(sdkctl); in sdkctl_socket_new()
1928 sdkctl->state = SDKCTL_SOCKET_DISCONNECTED; in sdkctl_socket_new()
1929 sdkctl->port_status = SDKCTL_PORT_DISCONNECTED; in sdkctl_socket_new()
1930 sdkctl->opaque = opaque; in sdkctl_socket_new()
1931 sdkctl->service_name = ASTRDUP(service_name); in sdkctl_socket_new()
1932 sdkctl->on_socket_connection = on_socket_connection; in sdkctl_socket_new()
1933 sdkctl->on_port_connection = on_port_connection; in sdkctl_socket_new()
1934 sdkctl->on_message = on_message; in sdkctl_socket_new()
1935 sdkctl->reconnect_to = reconnect_to; in sdkctl_socket_new()
1936 sdkctl->as = NULL; in sdkctl_socket_new()
1937 sdkctl->next_query_id = 0; in sdkctl_socket_new()
1938 sdkctl->query_head = sdkctl->query_tail = NULL; in sdkctl_socket_new()
1939 sdkctl->ref_count = 1; in sdkctl_socket_new()
1940 sdkctl->recycler = NULL; in sdkctl_socket_new()
1941 sdkctl->recycler_block_size = 0; in sdkctl_socket_new()
1942 sdkctl->recycler_max = 0; in sdkctl_socket_new()
1943 sdkctl->recycler_count = 0; in sdkctl_socket_new()
1945 T("SDKCtl %s: descriptor is created.", sdkctl->service_name); in sdkctl_socket_new()
1947 sdkctl->looper = looper_newCore(); in sdkctl_socket_new()
1948 if (sdkctl->looper == NULL) { in sdkctl_socket_new()
1951 on_socket_connection(opaque, sdkctl, ASIO_STATE_FAILED); in sdkctl_socket_new()
1952 _sdkctl_socket_free(sdkctl); in sdkctl_socket_new()
1956 return sdkctl; in sdkctl_socket_new()
1959 int sdkctl_socket_reference(SDKCtlSocket* sdkctl) in sdkctl_socket_reference() argument
1961 assert(sdkctl->ref_count > 0); in sdkctl_socket_reference()
1962 sdkctl->ref_count++; in sdkctl_socket_reference()
1963 return sdkctl->ref_count; in sdkctl_socket_reference()
1967 sdkctl_socket_release(SDKCtlSocket* sdkctl) in sdkctl_socket_release() argument
1969 assert(sdkctl->ref_count > 0); in sdkctl_socket_release()
1970 sdkctl->ref_count--; in sdkctl_socket_release()
1971 if (sdkctl->ref_count == 0) { in sdkctl_socket_release()
1973 _sdkctl_socket_free(sdkctl); in sdkctl_socket_release()
1976 return sdkctl->ref_count; in sdkctl_socket_release()
1980 sdkctl_init_recycler(SDKCtlSocket* sdkctl, in sdkctl_init_recycler() argument
1984 if (sdkctl->recycler != NULL) { in sdkctl_init_recycler()
1986 sdkctl->service_name); in sdkctl_init_recycler()
1993 sdkctl->recycler_block_size = data_size; in sdkctl_init_recycler()
1994 sdkctl->recycler_max = max_recycled_num; in sdkctl_init_recycler()
1995 sdkctl->recycler_count = 0; in sdkctl_init_recycler()
1999 sdkctl_socket_connect(SDKCtlSocket* sdkctl, int port, int retry_to) in sdkctl_socket_connect() argument
2002 sdkctl->service_name, port, retry_to); in sdkctl_socket_connect()
2004 sdkctl->state = SDKCTL_SOCKET_CONNECTING; in sdkctl_socket_connect()
2005 sdkctl->as = async_socket_new(port, sdkctl->reconnect_to, in sdkctl_socket_connect()
2006 _on_async_socket_connection, sdkctl, in sdkctl_socket_connect()
2007 sdkctl->looper); in sdkctl_socket_connect()
2008 if (sdkctl->as == NULL) { in sdkctl_socket_connect()
2010 sdkctl->service_name); in sdkctl_socket_connect()
2011 sdkctl->on_socket_connection(sdkctl->opaque, sdkctl, ASIO_STATE_FAILED); in sdkctl_socket_connect()
2013 async_socket_connect(sdkctl->as, retry_to); in sdkctl_socket_connect()
2018 sdkctl_socket_reconnect(SDKCtlSocket* sdkctl, int port, int retry_to) in sdkctl_socket_reconnect() argument
2021 sdkctl->service_name, port, retry_to); in sdkctl_socket_reconnect()
2023 _sdkctl_socket_disconnect_socket(sdkctl); in sdkctl_socket_reconnect()
2025 if (sdkctl->as == NULL) { in sdkctl_socket_reconnect()
2026 sdkctl_socket_connect(sdkctl, port, retry_to); in sdkctl_socket_reconnect()
2028 sdkctl->state = SDKCTL_SOCKET_CONNECTING; in sdkctl_socket_reconnect()
2029 async_socket_reconnect(sdkctl->as, retry_to); in sdkctl_socket_reconnect()
2034 sdkctl_socket_disconnect(SDKCtlSocket* sdkctl) in sdkctl_socket_disconnect() argument
2036 T("SDKCtl %s: Handling disconnect request.", sdkctl->service_name); in sdkctl_socket_disconnect()
2038 _sdkctl_socket_disconnect_socket(sdkctl); in sdkctl_socket_disconnect()
2042 sdkctl_socket_is_connected(SDKCtlSocket* sdkctl) in sdkctl_socket_is_connected() argument
2044 return (sdkctl->state == SDKCTL_SOCKET_CONNECTED) ? 1 : 0; in sdkctl_socket_is_connected()
2048 sdkctl_socket_is_port_ready(SDKCtlSocket* sdkctl) in sdkctl_socket_is_port_ready() argument
2050 return (sdkctl->port_status == SDKCTL_PORT_ENABLED) ? 1 : 0; in sdkctl_socket_is_port_ready()
2054 sdkctl_socket_get_port_status(SDKCtlSocket* sdkctl) in sdkctl_socket_get_port_status() argument
2056 return sdkctl->port_status; in sdkctl_socket_get_port_status()
2060 sdkctl_socket_is_handshake_ok(SDKCtlSocket* sdkctl) in sdkctl_socket_is_handshake_ok() argument
2062 switch (sdkctl->port_status) { in sdkctl_socket_is_handshake_ok()
2095 SDKCtlSocket* const sdkctl = (SDKCtlSocket*)query_opaque; in _on_handshake_io() local
2103 sdkctl->service_name); in _on_handshake_io()
2109 sdkctl->service_name); in _on_handshake_io()
2115 sdkctl->service_name); in _on_handshake_io()
2121 sdkctl->service_name); in _on_handshake_io()
2127 sdkctl->service_name, *res); in _on_handshake_io()
2131 sdkctl->port_status = handshake_status; in _on_handshake_io()
2132 sdkctl->on_port_connection(sdkctl->opaque, sdkctl, handshake_status); in _on_handshake_io()
2140 sdkctl->service_name, status, errno, strerror(errno)); in _on_handshake_io()
2141 sdkctl->on_socket_connection(sdkctl->opaque, sdkctl, in _on_handshake_io()
2156 SDKCtlSocket* const sdkctl = (SDKCtlSocket*)io_opaque; in _on_sdkctl_endianness_io() local
2160 D("SDKCtl %s: Sending handshake query...", sdkctl->service_name); in _on_sdkctl_endianness_io()
2162 sdkctl_query_build_and_send(sdkctl, SDKCTL_QUERY_HANDSHAKE, in _on_sdkctl_endianness_io()
2163 strlen(sdkctl->service_name), in _on_sdkctl_endianness_io()
2164 sdkctl->service_name, NULL, NULL, in _on_sdkctl_endianness_io()
2165 _on_handshake_io, sdkctl, 3000); in _on_sdkctl_endianness_io()
2175 sdkctl->service_name, status, errno, strerror(errno)); in _on_sdkctl_endianness_io()
2176 sdkctl->on_socket_connection(sdkctl->opaque, sdkctl, ASIO_STATE_FAILED); in _on_sdkctl_endianness_io()
2187 _sdkctl_do_handshake(SDKCtlSocket* sdkctl) in _sdkctl_do_handshake() argument
2195 D("SDKCtl %s: Sending endianness: %d", sdkctl->service_name, _host_end); in _sdkctl_do_handshake()
2199 async_socket_write_rel(sdkctl->as, &_host_end, 1, in _sdkctl_do_handshake()
2200 _on_sdkctl_endianness_io, sdkctl, 3000); in _sdkctl_do_handshake()