flags= fcntl(ptr->hosts[server_key].fd, F_GETFL, 0);
if (flags != -1)
+ {
(void)fcntl(ptr->hosts[server_key].fd, F_SETFL, flags | O_NONBLOCK);
+
+ flags= 1;
+ setsockopt(ptr->hosts[server_key].fd, IPPROTO_TCP, SO_LINGER,
+ &flags, (socklen_t)sizeof(int));
+ }
}
if (ptr->flags & MEM_TCP_NODELAY)
memcached_return memcached_io_close(memcached_st *ptr, unsigned int server_key)
{
- memcached_return rc;
-
- rc= MEMCACHED_SUCCESS;
- if (ptr->flags & MEM_NO_BLOCK)
- {
- int error;
- struct pollfd fds[1];
- short flags= 0;
-
- flags= POLLHUP | POLLERR;
-
- memset(&fds, 0, sizeof(struct pollfd));
- fds[0].fd= ptr->hosts[server_key].fd;
- fds[0].events= flags;
- fds[0].revents= 0;
-
- error= poll(fds, 1, ptr->poll_timeout == -1 ? 100 : ptr->poll_timeout);
-
- if (error == -1)
- {
- memcached_quit_server(ptr, server_key, 1);
- return MEMCACHED_FAILURE;
- }
- else if (error == 0)
- return MEMCACHED_FAILURE; /* Timeout occurred */
- }
-
close(ptr->hosts[server_key].fd);
- return rc;
+ return MEMCACHED_SUCCESS;
}
static ssize_t io_flush(memcached_st *ptr, unsigned int server_key,