projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Fix return type from test functions (should be TEST_SUCCESS and not 0)
[awesomized/libmemcached]
/
example
/
memcached_light.c
diff --git
a/example/memcached_light.c
b/example/memcached_light.c
index 4343b835e265b9e5ca4a85bc5fff86414990dd1a..741ef82e002b863c4679a50fcab015dd7a8e4b8a 100644
(file)
--- a/
example/memcached_light.c
+++ b/
example/memcached_light.c
@@
-15,8
+15,15
@@
* the more "logical" interface.
* memcached_light.c - This file sets up all of the sockets and run the main
* message loop.
* the more "logical" interface.
* memcached_light.c - This file sets up all of the sockets and run the main
* message loop.
+ *
+ *
+ * config.h is included so that I can use the ntohll/htonll on platforms that
+ * doesn't have that (this is a private function inside libmemcached, so you
+ * cannot use it directly from libmemcached without special modifications to
+ * the library)
*/
*/
+#include "config.h"
#include <assert.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/socket.h>
@@
-34,8
+41,8
@@
#include <libmemcached/byteorder.h>
#include "storage.h"
#include <libmemcached/byteorder.h>
#include "storage.h"
-extern
struct
memcached_binary_protocol_callback_st interface_v0_impl;
-extern
struct
memcached_binary_protocol_callback_st interface_v1_impl;
+extern memcached_binary_protocol_callback_st interface_v0_impl;
+extern memcached_binary_protocol_callback_st interface_v1_impl;
static int server_sockets[1024];
static int num_server_sockets= 0;
static int server_sockets[1024];
static int num_server_sockets= 0;
@@
-220,7
+227,7
@@
int main(int argc, char **argv)
{
bool port_specified= false;
int cmd;
{
bool port_specified= false;
int cmd;
-
struct
memcached_binary_protocol_callback_st *interface= &interface_v0_impl;
+ memcached_binary_protocol_callback_st *interface= &interface_v0_impl;
while ((cmd= getopt(argc, argv, "v1p:?")) != EOF)
{
while ((cmd= getopt(argc, argv, "v1p:?")) != EOF)
{
@@
-286,7
+293,7
@@
int main(int argc, char **argv)
return 0;
}
return 0;
}
-static void work(void)
+static void work(void)
{
#define MAX_SERVERS_TO_POLL 100
struct pollfd fds[MAX_SERVERS_TO_POLL];
{
#define MAX_SERVERS_TO_POLL 100
struct pollfd fds[MAX_SERVERS_TO_POLL];
@@
-357,17
+364,16
@@
static void work(void)
assert(c != NULL);
fds[max_poll].events= 0;
assert(c != NULL);
fds[max_poll].events= 0;
- switch (memcached_protocol_client_work(c))
- {
- case WRITE_EVENT:
- case READ_WRITE_EVENT:
+ memcached_protocol_event_t events= memcached_protocol_client_work(c);
+ if (events & MEMCACHED_PROTOCOL_WRITE_EVENT)
fds[max_poll].events= POLLOUT;
fds[max_poll].events= POLLOUT;
- /* FALLTHROUGH */
- case READ_EVENT:
- fds[max_poll].events |= POLLIN;
- break;
- case ERROR_EVENT:
- default: /* ERROR or unknown state.. close */
+
+ if (events & MEMCACHED_PROTOCOL_READ_EVENT)
+ fds[max_poll].events= POLLIN;
+
+ if (!(events & MEMCACHED_PROTOCOL_PAUSE_EVENT ||
+ fds[max_poll].events != 0))
+ {
memcached_protocol_client_destroy(c);
close(fds[x].fd);
fds[x].events= 0;
memcached_protocol_client_destroy(c);
close(fds[x].fd);
fds[x].events= 0;