| the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+--------------------------------------------------------------------+
| Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ | Copyright (c) 2020-2021 Michael Wallner https://awesome.co/ |
+--------------------------------------------------------------------+
*/
# include <unistd.h>
#endif
-#ifndef HAVE_GETOPT_H
-# include "../../win32/getopt.h"
-#endif
+#include "p9y/getopt.hpp"
+#include "p9y/socket.hpp"
+#include "p9y/poll.hpp"
#include "libmemcached-1.0/memcached.h"
-#include "libmemcached/poll.h"
-#include "libmemcached/socket.hpp"
#include "libmemcachedprotocol-0.0/binary.h"
#include "libmemcached/byteorder.h"
int flags = fcntl(sock, F_GETFL, 0);
if (flags == -1) {
perror("Failed to get socket flags");
- memcached_close_socket(sock);
+ closesocket(sock);
return INVALID_SOCKET;
}
if ((flags & O_NONBLOCK) != O_NONBLOCK) {
if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) == -1) {
perror("Failed to set socket to nonblocking mode");
- memcached_close_socket(sock);
+ closesocket(sock);
return INVALID_SOCKET;
}
}
} else {
ret = recv(fd, const_cast<char *>(buf), len, 0);
}
-
- if (ret == SOCKET_ERROR && get_socket_errno() == EWOULDBLOCK) {
+ int local_errno = get_socket_errno();
+ if (ret == SOCKET_ERROR && local_errno == EWOULDBLOCK || (EAGAIN != EWOULDBLOCK && local_errno == EAGAIN)) {
struct pollfd fds;
memset(&fds, 0, sizeof(struct pollfd));
fds.events = direction;
"\t\t\tEverything else will start the test\n"
"\t-T n\tJust run the test named n\n"
"\t-a\tOnly test the ascii protocol\n"
- "\t-b\tOnly test the binary protocol\n",
+ "\t-b\tOnly test the binary protocol\n\n"
+ "WARNING: This will FLUSH your server!\n\n",
argv[0]);
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}
- #ifdef _WIN32
+#ifdef _WIN32
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 2), &wsaData)) {
fprintf(stderr, "Socket Initialization Error.\n");