summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1d1e565)
raw | patch | inline | side by side (parent: 1d1e565)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Tue, 26 Sep 2017 19:41:18 +0000 (02:41 +0700) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Tue, 26 Sep 2017 19:48:23 +0000 (02:48 +0700) |
src/memcached.c | patch | blob | history |
diff --git a/src/memcached.c b/src/memcached.c
index 36b3c9a97c15831abf11ee9dd520f81c995750b0..1eb02a3c649c8b956dcdebe4865be8b1cc9ecb4a 100644 (file)
--- a/src/memcached.c
+++ b/src/memcached.c
if (st->fd >= 0) {
shutdown(st->fd, SHUT_RDWR);
close(st->fd);
+ st->fd = -1;
}
sfree(st->name);
}
/* Wait until connection establishes */
- struct pollfd pollfd;
- pollfd.fd = fd;
- pollfd.events = POLLOUT;
+ struct pollfd pollfd = {
+ .fd = fd, .events = POLLOUT,
+ };
do
status = poll(&pollfd, 1, MEMCACHED_CONNECT_TIMEOUT);
while (status < 0 && errno == EINTR);
/* Check if all is good */
int socket_error;
- socklen_t socket_error_len = sizeof(socket_error);
status = getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&socket_error,
- &socket_error_len);
+ &(socklen_t){sizeof(socket_error)});
if (status != 0 || socket_error != 0) {
close(fd);
fd = -1;
return -1;
}
- struct pollfd pollfd;
- pollfd.fd = st->fd;
- pollfd.events = POLLOUT;
+ struct pollfd pollfd = {
+ .fd = st->fd, .events = POLLOUT,
+ };
do
status = poll(&pollfd, 1, MEMCACHED_IO_TIMEOUT);