| 747 | } |
| 748 | |
| 749 | static int rpmsg_socket_connect_internal(FAR struct socket *psock) |
| 750 | { |
| 751 | FAR struct rpmsg_socket_conn_s *conn = psock->s_conn; |
| 752 | int ret; |
| 753 | |
| 754 | ret = circbuf_resize(&conn->recvbuf, conn->recvsize); |
| 755 | if (ret < 0) |
| 756 | { |
| 757 | return ret; |
| 758 | } |
| 759 | |
| 760 | ret = rpmsg_register_callback(conn, |
| 761 | rpmsg_socket_device_created, |
| 762 | NULL, |
| 763 | NULL, |
| 764 | NULL); |
| 765 | if (ret < 0) |
| 766 | { |
| 767 | return ret; |
| 768 | } |
| 769 | |
| 770 | nxmutex_lock(&conn->sendlock); |
| 771 | if (conn->sendsize == 0) |
| 772 | { |
| 773 | nxmutex_unlock(&conn->sendlock); |
| 774 | if (_SS_ISNONBLOCK(conn->sconn.s_flags)) |
| 775 | { |
| 776 | return -EINPROGRESS; |
| 777 | } |
| 778 | |
| 779 | ret = net_sem_timedwait(&conn->sendsem, |
| 780 | _SO_TIMEOUT(conn->sconn.s_sndtimeo)); |
| 781 | if (!conn->ept.rdev || conn->unbind) |
| 782 | { |
| 783 | ret = -ECONNRESET; |
| 784 | } |
| 785 | |
| 786 | if (ret < 0) |
| 787 | { |
| 788 | rpmsg_unregister_callback(conn, |
| 789 | rpmsg_socket_device_created, |
| 790 | NULL, |
| 791 | NULL, |
| 792 | NULL); |
| 793 | rpmsg_socket_destroy_ept(conn); |
| 794 | } |
| 795 | } |
| 796 | else |
| 797 | { |
| 798 | nxmutex_unlock(&conn->sendlock); |
| 799 | } |
| 800 | |
| 801 | return ret; |
| 802 | } |
| 803 | |
| 804 | static int rpmsg_socket_connect(FAR struct socket *psock, |
| 805 | FAR const struct sockaddr *addr, |
no test coverage detected