inline ssize_t fiber_sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen) { ACL_FIBER *me; while (1) { ssize_t n = __sys_sendto(sockfd, buf, len, flags, dest_addr, addrlen); if (!acl_var_hook_sys_api) return n; if (n >= 0) return n; fiber_save_errno(); #if EAGAIN == EWOULDBLOCK if (errno != EAGAIN) #else if (errno != EAGAIN && errno != EWOULDBLOCK) #endif return -1; fiber_wait_write(sockfd); me = acl_fiber_running(); if (acl_fiber_killed(me)) acl_msg_info("%s(%d), %s: fiber-%d is existing", __FILE__, __LINE__, __FUNCTION__, acl_fiber_id(me)); } }
inline ssize_t fiber_sendmsg(int sockfd, const struct msghdr *msg, int flags) { ACL_FIBER *me; while (1) { ssize_t n = __sys_sendmsg(sockfd, msg, flags); if (!acl_var_hook_sys_api) return n; if (n >= 0) return n; fiber_save_errno(); #if EAGAIN == EWOULDBLOCK if (errno != EAGAIN) #else if (errno != EAGAIN && errno != EWOULDBLOCK) #endif return -1; fiber_wait_write(sockfd); me = acl_fiber_running(); if (acl_fiber_killed(me)) acl_msg_info("%s(%d), %s: fiber-%d is existing", __FILE__, __LINE__, __FUNCTION__, acl_fiber_id(me)); } }
ssize_t sendfile64(int out_fd, int in_fd, off64_t *offset, size_t count) { ACL_FIBER *me; if (__sys_sendfile64 == NULL) hook_io(); while (1) { ssize_t n = __sys_sendfile64(out_fd, in_fd, offset, count); if (!acl_var_hook_sys_api || n >= 0) return n; fiber_save_errno(); #if EAGAIN == EWOULDBLOCK if (errno != EAGAIN) #else if (errno != EAGAIN && errno != EWOULDBLOCK) #endif return -1; fiber_wait_write(out_fd); me = acl_fiber_running(); if (acl_fiber_killed(me)) { acl_msg_info("%s(%d), %s: fiber-%u is existing", __FILE__, __LINE__, __FUNCTION__, acl_fiber_id(me)); return -1; } } }
inline ssize_t fiber_write(int fd, const void *buf, size_t count) { ACL_FIBER *me; while (1) { ssize_t n = __sys_write(fd, buf, count); if (!acl_var_hook_sys_api) return n; if (n >= 0) return n; fiber_save_errno(); #if EAGAIN == EWOULDBLOCK if (errno != EAGAIN) #else if (errno != EAGAIN && errno != EWOULDBLOCK) #endif return -1; fiber_wait_write(fd); me = acl_fiber_running(); if (acl_fiber_killed(me)) acl_msg_info("%s(%d), %s: fiber-%d is existing", __FILE__, __LINE__, __FUNCTION__, acl_fiber_id(me)); } }
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen) { while (1) { ssize_t n = __sys_sendto(sockfd, buf, len, flags, dest_addr, addrlen); if (!acl_var_hook_sys_api) return n; if (n >= 0) return n; fiber_save_errno(); #if EAGAIN == EWOULDBLOCK if (errno != EAGAIN) #else if (errno != EAGAIN && errno != EWOULDBLOCK) #endif return -1; fiber_wait_write(sockfd); } }
ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags) { while (1) { ssize_t n = __sys_sendmsg(sockfd, msg, flags); if (!acl_var_hook_sys_api) return n; if (n >= 0) return n; fiber_save_errno(); #if EAGAIN == EWOULDBLOCK if (errno != EAGAIN) #else if (errno != EAGAIN && errno != EWOULDBLOCK) #endif return -1; fiber_wait_write(sockfd); } }
ssize_t send(int sockfd, const void *buf, size_t len, int flags) { while (1) { ssize_t n = __sys_send(sockfd, buf, len, flags); if (!acl_var_hook_sys_api) return n; if (n >= 0) return n; fiber_save_errno(); #if EAGAIN == EWOULDBLOCK if (errno != EAGAIN) #else if (errno != EAGAIN && errno != EWOULDBLOCK) #endif return -1; fiber_wait_write(sockfd); } }
ssize_t writev(int fd, const struct iovec *iov, int iovcnt) { while (1) { ssize_t n = __sys_writev(fd, iov, iovcnt); if (!acl_var_hook_sys_api) return n; if (n >= 0) return n; fiber_save_errno(); #if EAGAIN == EWOULDBLOCK if (errno != EAGAIN) #else if (errno != EAGAIN && errno != EWOULDBLOCK) #endif return -1; fiber_wait_write(fd); } }
ssize_t write(int fd, const void *buf, size_t count) { while (1) { ssize_t n = __sys_write(fd, buf, count); if (!acl_var_hook_sys_api) return n; if (n >= 0) return n; fiber_save_errno(); #if EAGAIN == EWOULDBLOCK if (errno != EAGAIN) #else if (errno != EAGAIN && errno != EWOULDBLOCK) #endif return -1; fiber_wait_write(fd); } }
inline ssize_t fiber_send(int sockfd, const void *buf, size_t len, int flags) { ACL_FIBER *me; if (__sys_send == NULL) hook_io(); while (1) { ssize_t n = __sys_send(sockfd, buf, len, flags); if (!acl_var_hook_sys_api) return n; if (n >= 0) return n; fiber_save_errno(); #if EAGAIN == EWOULDBLOCK if (errno != EAGAIN) #else if (errno != EAGAIN && errno != EWOULDBLOCK) #endif return -1; fiber_wait_write(sockfd); me = acl_fiber_running(); if (acl_fiber_killed(me)) { acl_msg_info("%s(%d), %s: fiber-%u is existing", __FILE__, __LINE__, __FUNCTION__, acl_fiber_id(me)); return -1; } } }
inline ssize_t fiber_writev(int fd, const struct iovec *iov, int iovcnt) { ACL_FIBER *me; if (__sys_writev == NULL) hook_io(); while (1) { ssize_t n = __sys_writev(fd, iov, iovcnt); if (!acl_var_hook_sys_api) return n; if (n >= 0) return n; fiber_save_errno(); #if EAGAIN == EWOULDBLOCK if (errno != EAGAIN) #else if (errno != EAGAIN && errno != EWOULDBLOCK) #endif return -1; fiber_wait_write(fd); me = acl_fiber_running(); if (acl_fiber_killed(me)) { acl_msg_info("%s(%d), %s: fiber-%u is existing", __FILE__, __LINE__, __FUNCTION__, acl_fiber_id(me)); return -1; } } }