projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Fix problem where hostname would end up with trailing . and be accepted as
[m6w6/libmemcached]
/
libmemcached
/
io.c
diff --git
a/libmemcached/io.c
b/libmemcached/io.c
index 3b5d44f570e2003313963a6c70a1600287f382ba..2515dc1ea7c72b5f5e2a42404d3aa11f23233c4f 100644
(file)
--- a/
libmemcached/io.c
+++ b/
libmemcached/io.c
@@
-12,8
+12,6
@@
#include "common.h"
#include "common.h"
-#include <assert.h>
-
typedef enum {
MEM_READ,
MEM_WRITE
typedef enum {
MEM_READ,
MEM_WRITE
@@
-107,6
+105,11
@@
static memcached_return_t io_wait(memcached_server_write_instance_st ptr,
return MEMCACHED_FAILURE;
}
return MEMCACHED_FAILURE;
}
+memcached_return_t memcached_io_wait_for_write(memcached_server_write_instance_st ptr)
+{
+ return io_wait(ptr, MEM_WRITE);
+}
+
/**
* Try to fill the input buffer for a server with as much
* data as possible.
/**
* Try to fill the input buffer for a server with as much
* data as possible.
@@
-311,7
+314,7
@@
memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr,
and protocol enforcement happens at memcached_response()
looking for '\n'. We do not care for UDB which requests 8 bytes
at once. Generally, this means that connection went away. Since
and protocol enforcement happens at memcached_response()
looking for '\n'. We do not care for UDB which requests 8 bytes
at once. Generally, this means that connection went away. Since
- for blocking I/O we do not return
0
and for non-blocking case
+ for blocking I/O we do not return
EXIT_SUCCESS
and for non-blocking case
it will return EGAIN if data is not immediatly available.
*/
WATCHPOINT_STRING("We had a zero length recv()");
it will return EGAIN if data is not immediatly available.
*/
WATCHPOINT_STRING("We had a zero length recv()");
@@
-384,7
+387,6
@@
static ssize_t _io_write(memcached_server_write_instance_st ptr,
should_write= length;
if (ptr->write_buffer_offset + should_write > buffer_end)
{
should_write= length;
if (ptr->write_buffer_offset + should_write > buffer_end)
{
- fprintf(stderr, "%s:%d (%s)\n", __FILE__, __LINE__,__func__);fflush(stdout);
return -1;
}
}
return -1;
}
}
@@
-427,7
+429,6
@@
static ssize_t _io_write(memcached_server_write_instance_st ptr,
WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
if (io_flush(ptr, &rc) == -1)
{
WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
if (io_flush(ptr, &rc) == -1)
{
- fprintf(stderr, "%s:%d (%s)\n", __FILE__, __LINE__,__func__);fflush(stdout);
return -1;
}
return -1;
}
@@
-579,7
+580,6
@@
static ssize_t io_flush(memcached_server_write_instance_st ptr,
if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_STORED)
{
if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_STORED)
{
- fprintf(stderr, "%s:%d (%s)\n", __FILE__, __LINE__,__func__);fflush(stdout);
return -1;
}
}
return -1;
}
}
@@
-595,13
+595,12
@@
static ssize_t io_flush(memcached_server_write_instance_st ptr,
// UDP Sanity check, make sure that we are not sending somthing too big
if (ptr->type == MEMCACHED_CONNECTION_UDP && write_length > MAX_UDP_DATAGRAM_LENGTH)
{
// UDP Sanity check, make sure that we are not sending somthing too big
if (ptr->type == MEMCACHED_CONNECTION_UDP && write_length > MAX_UDP_DATAGRAM_LENGTH)
{
- fprintf(stderr, "%s:%d (%s)\n", __FILE__, __LINE__,__func__);fflush(stdout);
return -1;
}
if (ptr->write_buffer_offset == 0 || (ptr->type == MEMCACHED_CONNECTION_UDP
&& ptr->write_buffer_offset == UDP_DATAGRAM_HEADER_LENGTH))
return -1;
}
if (ptr->write_buffer_offset == 0 || (ptr->type == MEMCACHED_CONNECTION_UDP
&& ptr->write_buffer_offset == UDP_DATAGRAM_HEADER_LENGTH))
- return
0
;
+ return
EXIT_SUCCESS
;
/* Looking for memory overflows */
#if defined(DEBUG)
/* Looking for memory overflows */
#if defined(DEBUG)
@@
-619,8
+618,8
@@
static ssize_t io_flush(memcached_server_write_instance_st ptr,
if (ptr->type == MEMCACHED_CONNECTION_UDP)
increment_udp_message_id(ptr);
if (ptr->type == MEMCACHED_CONNECTION_UDP)
increment_udp_message_id(ptr);
-
assert
(ptr->fd != -1);
- sent_length= send(ptr->fd, local_write_ptr, write_length,
0
);
+
WATCHPOINT_ASSERT
(ptr->fd != -1);
+ sent_length= send(ptr->fd, local_write_ptr, write_length,
MSG_NOSIGNAL|MSG_DONTWAIT
);
if (sent_length == SOCKET_ERROR)
{
ptr->cached_errno= get_socket_errno();
if (sent_length == SOCKET_ERROR)
{
ptr->cached_errno= get_socket_errno();
@@
-654,17
+653,14
@@
static ssize_t io_flush(memcached_server_write_instance_st ptr,
continue;
memcached_quit_server(ptr, true);
continue;
memcached_quit_server(ptr, true);
- fprintf(stderr, "%s:%d (%s)\n", __FILE__, __LINE__,__func__);fflush(stdout);
return -1;
}
case ENOTCONN:
case EPIPE:
default:
return -1;
}
case ENOTCONN:
case EPIPE:
default:
- fprintf(stderr, "%s %u %u %u\n", ptr->hostname, ptr->port, ptr->io_bytes_sent, ptr->server_failure_counter);
- fprintf(stderr, "%s:%d (%s)(%s)\n", __FILE__, __LINE__,__func__, strerror(errno));fflush(stdout);
memcached_quit_server(ptr, true);
*error= MEMCACHED_ERRNO;
memcached_quit_server(ptr, true);
*error= MEMCACHED_ERRNO;
-
assert
(ptr->fd == -1);
+
WATCHPOINT_ASSERT
(ptr->fd == -1);
return -1;
}
}
return -1;
}
}
@@
-673,7
+669,6
@@
static ssize_t io_flush(memcached_server_write_instance_st ptr,
(size_t)sent_length != write_length)
{
memcached_quit_server(ptr, true);
(size_t)sent_length != write_length)
{
memcached_quit_server(ptr, true);
- fprintf(stderr, "%s:%d (%s)\n", __FILE__, __LINE__,__func__);fflush(stdout);
return -1;
}
return -1;
}