projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Add missing files.
[awesomized/libmemcached]
/
libmemcached
/
quit.c
diff --git
a/libmemcached/quit.c
b/libmemcached/quit.c
index ebeffa5c0bd2f134a039ed881fa78f87152f5e67..6d72906cb8022a92ed69f2ab7dfafb0bd616eba8 100644
(file)
--- a/
libmemcached/quit.c
+++ b/
libmemcached/quit.c
@@
-9,15
+9,17
@@
will force data to be completed.
*/
will force data to be completed.
*/
-void memcached_quit_server(memcached_server_st *ptr,
uint8_t
io_death)
+void memcached_quit_server(memcached_server_st *ptr,
bool
io_death)
{
{
- if (ptr->fd !=
-1
)
+ if (ptr->fd !=
INVALID_SOCKET
)
{
{
- if (io_death ==
0 && ptr->type != MEMCACHED_CONNECTION_UDP
)
+ if (io_death ==
false && ptr->type != MEMCACHED_CONNECTION_UDP && ptr->options.is_shutting_down == false
)
{
memcached_return_t rc;
char buffer[MEMCACHED_MAX_BUFFER];
{
memcached_return_t rc;
char buffer[MEMCACHED_MAX_BUFFER];
+ ptr->options.is_shutting_down= true;
+
if (ptr->root->flags.binary_protocol)
{
protocol_binary_request_quit request = {.bytes= {0}};
if (ptr->root->flags.binary_protocol)
{
protocol_binary_request_quit request = {.bytes= {0}};
@@
-28,7
+30,7
@@
void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death)
}
else
{
}
else
{
- rc= memcached_do(ptr, "quit\r\n", sizeof("quit\r\n"), true);
+ rc= memcached_do(ptr, "quit\r\n", sizeof("quit\r\n")
-1
, true);
}
WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_FETCH_NOTFINISHED);
}
WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_FETCH_NOTFINISHED);
@@
-38,10
+40,17
@@
void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death)
* closing the socket before all data is read
* results in server throwing away all data which is
* not read
* closing the socket before all data is read
* results in server throwing away all data which is
* not read
+ *
+ * In .40 we began to only do this if we had been doing buffered
+ * requests of had replication enabled.
*/
*/
- ssize_t nread;
- while (memcached_io_read(ptr, buffer, sizeof(buffer)/sizeof(*buffer),
- &nread) == MEMCACHED_SUCCESS);
+ if (ptr->root->flags.buffer_requests || ptr->root->number_of_replicas)
+ {
+ ssize_t nread;
+ while (memcached_io_read(ptr, buffer, sizeof(buffer)/sizeof(*buffer),
+ &nread) == MEMCACHED_SUCCESS);
+ }
+
/*
* memcached_io_read may call memcached_quit_server with io_death if
/*
* memcached_io_read may call memcached_quit_server with io_death if
@@
-55,33
+64,42
@@
void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death)
memcached_io_close(ptr);
}
memcached_io_close(ptr);
}
- ptr->fd= -1;
+ ptr->fd= INVALID_SOCKET;
+ ptr->io_bytes_sent= 0;
ptr->write_buffer_offset= (size_t) ((ptr->type == MEMCACHED_CONNECTION_UDP) ? UDP_DATAGRAM_HEADER_LENGTH : 0);
ptr->read_buffer_length= 0;
ptr->read_ptr= ptr->read_buffer;
ptr->write_buffer_offset= (size_t) ((ptr->type == MEMCACHED_CONNECTION_UDP) ? UDP_DATAGRAM_HEADER_LENGTH : 0);
ptr->read_buffer_length= 0;
ptr->read_ptr= ptr->read_buffer;
+ ptr->options.is_shutting_down= false;
memcached_server_response_reset(ptr);
memcached_server_response_reset(ptr);
- if(io_death)
+ // We reset the version so that if we end up talking to a different server
+ // we don't have stale server version information.
+ ptr->major_version= ptr->minor_version= ptr->micro_version= UINT8_MAX;
+
+ if (io_death)
{
ptr->server_failure_counter++;
{
ptr->server_failure_counter++;
+ set_last_disconnected_host(ptr);
}
}
}
}
-void
memcache
d_quit(memcached_st *ptr)
+void
sen
d_quit(memcached_st *ptr)
{
{
- uint32_t x;
+ for (uint32_t x= 0; x < memcached_server_count(ptr); x++)
+ {
+ memcached_server_write_instance_st instance=
+ memcached_server_instance_fetch(ptr, x);
- if (memcached_server_count(ptr) == 0)
- return;
+ memcached_quit_server(instance, false);
+ }
+}
- if (memcached_server_count(ptr))
+void memcached_quit(memcached_st *ptr)
+{
+ if (initialize_query(ptr) != MEMCACHED_SUCCESS)
{
{
- for (x= 0; x < memcached_server_count(ptr); x++)
- {
- memcached_server_instance_st *instance=
- memcached_server_instance_fetch(ptr, x);
-
- memcached_quit_server(instance, 0);
- }
+ return;
}
}
+
+ send_quit(ptr);
}
}