From: Trond Norbye Date: Wed, 28 Jul 2010 18:48:18 +0000 (+0200) Subject: Socket should be memcached_socket_t X-Git-Tag: 0.44~12^2~1 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=1c0e12077080d4cdbf5313daab562deab94c2b72;p=m6w6%2Flibmemcached Socket should be memcached_socket_t --- diff --git a/clients/memcapable.c b/clients/memcapable.c index 051c6457..25278617 100644 --- a/clients/memcapable.c +++ b/clients/memcapable.c @@ -44,7 +44,7 @@ /* Should we generate coredumps when we enounter an error (-c) */ static bool do_core= false; /* connection to the server */ -static SOCKET sock; +static memcached_socket_t sock; /* Should the output from test failures be verbose or quiet? */ static bool verbose= false; @@ -108,7 +108,7 @@ static struct addrinfo *lookuphost(const char *hostname, const char *port) * Set the socket in nonblocking mode * @return -1 if failure, the socket otherwise */ -static SOCKET set_noblock(void) +static memcached_socket_t set_noblock(void) { #ifdef WIN32 u_long arg = 1; @@ -146,7 +146,7 @@ static SOCKET set_noblock(void) * @param port the port number (or service) to connect to * @return positive integer if success, -1 otherwise */ -static SOCKET connect_server(const char *hostname, const char *port) +static memcached_socket_t connect_server(const char *hostname, const char *port) { struct addrinfo *ai= lookuphost(hostname, port); sock= INVALID_SOCKET; @@ -177,7 +177,7 @@ static SOCKET connect_server(const char *hostname, const char *port) return sock; } -static ssize_t timeout_io_op(SOCKET fd, short direction, void *buf, size_t len) +static ssize_t timeout_io_op(memcached_socket_t fd, short direction, void *buf, size_t len) { ssize_t ret; diff --git a/example/memcached_light.c b/example/memcached_light.c index 96c74d7e..0b434a5f 100644 --- a/example/memcached_light.c +++ b/example/memcached_light.c @@ -42,7 +42,7 @@ extern memcached_binary_protocol_callback_st interface_v0_impl; extern memcached_binary_protocol_callback_st interface_v1_impl; -static SOCKET server_sockets[1024]; +static memcached_socket_t server_sockets[1024]; static int num_server_sockets= 0; struct connection @@ -72,7 +72,7 @@ typedef struct options_st options_st; * @param which identifying the event that occurred (not used) * @param arg the connection structure for the client */ -static void drive_client(SOCKET fd, short which, void *arg) +static void drive_client(memcached_socket_t fd, short which, void *arg) { (void)which; struct connection *client= arg; @@ -114,14 +114,14 @@ static void drive_client(SOCKET fd, short which, void *arg) * @param which identifying the event that occurred (not used) * @param arg the connection structure for the server */ -static void accept_handler(SOCKET fd, short which, void *arg) +static void accept_handler(memcached_socket_t fd, short which, void *arg) { (void)which; struct connection *server= arg; /* accept new client */ struct sockaddr_storage addr; socklen_t addrlen= sizeof(addr); - SOCKET sock= accept(fd, (struct sockaddr *)&addr, &addrlen); + memcached_socket_t sock= accept(fd, (struct sockaddr *)&addr, &addrlen); if (sock == INVALID_SOCKET) { @@ -187,7 +187,7 @@ static int server_socket(const char *port) for (struct addrinfo *next= ai; next; next= next->ai_next) { - SOCKET sock= socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); + memcached_socket_t sock= socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (sock == INVALID_SOCKET) { perror("Failed to create socket"); diff --git a/libmemcached/platform.h b/libmemcached/platform.h index 8b30f773..9eafbb14 100644 --- a/libmemcached/platform.h +++ b/libmemcached/platform.h @@ -16,8 +16,9 @@ #include #include typedef short in_port_t; +typedef SOCKET memcached_socket_t; #else -typedef int SOCKET; +typedef int memcached_socket_t; #include #include #include diff --git a/libmemcached/protocol/common.h b/libmemcached/protocol/common.h index 0a64df66..f7fa6044 100644 --- a/libmemcached/protocol/common.h +++ b/libmemcached/protocol/common.h @@ -98,7 +98,7 @@ enum ascii_cmd { struct memcached_protocol_client_st { memcached_protocol_st *root; - SOCKET sock; + memcached_socket_t sock; int error; /* Linked list of data to send */ diff --git a/libmemcached/protocol/protocol_handler.c b/libmemcached/protocol/protocol_handler.c index 77d6814d..fcab1419 100644 --- a/libmemcached/protocol/protocol_handler.c +++ b/libmemcached/protocol/protocol_handler.c @@ -28,7 +28,7 @@ * @return the number of bytes transferred of -1 upon error */ static ssize_t default_recv(const void *cookie, - SOCKET sock, + memcached_socket_t sock, void *buf, size_t nbytes) { @@ -48,7 +48,7 @@ static ssize_t default_recv(const void *cookie, * @return the number of bytes transferred of -1 upon error */ static ssize_t default_send(const void *cookie, - SOCKET fd, + memcached_socket_t fd, const void *buf, size_t nbytes) { @@ -269,7 +269,7 @@ void memcached_protocol_destroy_instance(struct memcached_protocol_st *instance) free(instance); } -struct memcached_protocol_client_st *memcached_protocol_create_client(struct memcached_protocol_st *instance, SOCKET sock) +struct memcached_protocol_client_st *memcached_protocol_create_client(struct memcached_protocol_st *instance, memcached_socket_t sock) { struct memcached_protocol_client_st *ret= calloc(1, sizeof(*ret)); if (ret != NULL) diff --git a/libmemcached/protocol_handler.h b/libmemcached/protocol_handler.h index 0e65ea9c..9f61187f 100644 --- a/libmemcached/protocol_handler.h +++ b/libmemcached/protocol_handler.h @@ -49,7 +49,7 @@ extern "C" { * or -1 upon error (errno should contain more information) */ typedef ssize_t (*memcached_protocol_recv_func)(const void *cookie, - SOCKET fd, + memcached_socket_t fd, void *buf, size_t nbuf); @@ -65,7 +65,7 @@ typedef ssize_t (*memcached_protocol_recv_func)(const void *cookie, * or -1 upon error (errno should contain more information) */ typedef ssize_t (*memcached_protocol_send_func)(const void *cookie, - SOCKET fd, + memcached_socket_t fd, const void *buf, size_t nbuf); @@ -140,7 +140,7 @@ void memached_protocol_set_io_functions(memcached_protocol_st *instance, * @return NULL if allocation fails, otherwise an instance */ LIBMEMCACHED_API -memcached_protocol_client_st *memcached_protocol_create_client(memcached_protocol_st *instance, SOCKET sock); +memcached_protocol_client_st *memcached_protocol_create_client(memcached_protocol_st *instance, memcached_socket_t sock); /** * Destroy a client handle. @@ -192,7 +192,7 @@ memcached_protocol_event_t memcached_protocol_client_work(memcached_protocol_cli * @return the socket handle */ LIBMEMCACHED_API -SOCKET memcached_protocol_client_get_socket(memcached_protocol_client_st *client); +memcached_socket_t memcached_protocol_client_get_socket(memcached_protocol_client_st *client); /** * Get the error id socket attached to a client handle diff --git a/libmemcached/server.h b/libmemcached/server.h index 4de191ef..2206c7b8 100644 --- a/libmemcached/server.h +++ b/libmemcached/server.h @@ -24,7 +24,7 @@ struct memcached_server_st { uint32_t cursor_active; in_port_t port; int cached_errno; - SOCKET fd; + memcached_socket_t fd; uint32_t io_bytes_sent; /* # bytes sent since last read */ uint32_t server_failure_counter; uint32_t weight;