mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-02 11:57:43 +08:00
use acl_socket_alive as the new method for checking the socket's aliving status.
This commit is contained in:
parent
c0c1b22e69
commit
3217e70bb5
@ -39,9 +39,8 @@ static acl_poll_fn __sys_poll = poll;
|
|||||||
|
|
||||||
int acl_readable(ACL_SOCKET fd)
|
int acl_readable(ACL_SOCKET fd)
|
||||||
{
|
{
|
||||||
const char *myname = "poll_read_wait";
|
|
||||||
struct pollfd fds;
|
struct pollfd fds;
|
||||||
int delay = 0;
|
int delay = 0;
|
||||||
|
|
||||||
fds.events = POLLIN | POLLPRI;
|
fds.events = POLLIN | POLLPRI;
|
||||||
fds.fd = fd;
|
fds.fd = fd;
|
||||||
@ -59,7 +58,7 @@ int acl_readable(ACL_SOCKET fd)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
acl_msg_error("%s(%d), %s: poll error(%s), fd: %d",
|
acl_msg_error("%s(%d), %s: poll error(%s), fd: %d",
|
||||||
__FILE__, __LINE__, myname,
|
__FILE__, __LINE__, __FUNCTION__,
|
||||||
acl_last_serror(), (int) fd);
|
acl_last_serror(), (int) fd);
|
||||||
return -1;
|
return -1;
|
||||||
case 0:
|
case 0:
|
||||||
@ -80,7 +79,6 @@ int acl_readable(ACL_SOCKET fd)
|
|||||||
|
|
||||||
int acl_readable(ACL_SOCKET fd)
|
int acl_readable(ACL_SOCKET fd)
|
||||||
{
|
{
|
||||||
const char *myname = "acl_readable";
|
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
fd_set rfds, xfds;
|
fd_set rfds, xfds;
|
||||||
int errnum;
|
int errnum;
|
||||||
@ -90,7 +88,7 @@ int acl_readable(ACL_SOCKET fd)
|
|||||||
*/
|
*/
|
||||||
if ((unsigned) fd >= FD_SETSIZE)
|
if ((unsigned) fd >= FD_SETSIZE)
|
||||||
acl_msg_fatal("%s(%d), %s: fd %d does not fit in "
|
acl_msg_fatal("%s(%d), %s: fd %d does not fit in "
|
||||||
"FD_SETSIZE: %d", __FILE__, __LINE__, myname,
|
"FD_SETSIZE: %d", __FILE__, __LINE__, __FUNCTION__,
|
||||||
(int) fd, FD_SETSIZE);
|
(int) fd, FD_SETSIZE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -126,7 +124,7 @@ int acl_readable(ACL_SOCKET fd)
|
|||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
acl_msg_error("%s(%d), %s: select error(%s), fd: %d",
|
acl_msg_error("%s(%d), %s: select error(%s), fd: %d",
|
||||||
__FILE__, __LINE__, myname,
|
__FILE__, __LINE__, __FUNCTION__,
|
||||||
acl_last_serror(), (int) fd);
|
acl_last_serror(), (int) fd);
|
||||||
return -1;
|
return -1;
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -269,7 +269,14 @@ bool socket_stream::alive(void) const
|
|||||||
{
|
{
|
||||||
if (stream_ == NULL)
|
if (stream_ == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
#if 0
|
||||||
|
if (acl_vstream_probe_status(stream_) == 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
return acl_socket_alive(ACL_VSTREAM_SOCK(stream_)) ? true : false;
|
return acl_socket_alive(ACL_VSTREAM_SOCK(stream_)) ? true : false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
socket_stream& socket_stream::set_tcp_nodelay(bool on)
|
socket_stream& socket_stream::set_tcp_nodelay(bool on)
|
||||||
|
Loading…
Reference in New Issue
Block a user