WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
if (with_flush)
{
- sent_length= send(ptr->fd, local_write_ptr, write_length, MSG_NOSIGNAL|MSG_DONTWAIT);
+ sent_length= ::send(ptr->fd, local_write_ptr, write_length, MSG_NOSIGNAL|MSG_DONTWAIT);
}
else
{
- sent_length= send(ptr->fd, local_write_ptr, write_length, MSG_NOSIGNAL|MSG_DONTWAIT|MSG_MORE);
+ sent_length= ::send(ptr->fd, local_write_ptr, write_length, MSG_NOSIGNAL|MSG_DONTWAIT|MSG_MORE);
}
if (sent_length == SOCKET_ERROR)
return _io_write(ptr, buffer, length, with_flush);
}
+size_t io_vector_total_size(libmemcached_io_vector_st* vector, const size_t number_of)
+{
+ ssize_t total= 0;
+
+ for (size_t x= 0; x < number_of; x++)
+ {
+ total+= vector->length;
+ }
+
+ return total;
+}
+
ssize_t memcached_io_writev(memcached_server_write_instance_st ptr,
const struct libmemcached_io_vector_st *vector,
size_t number_of, bool with_flush)
{
ssize_t returnable;
- if ((returnable= _io_write(ptr, vector->buffer, vector->length, false)) == -1)
+ if (vector->length)
{
- return -1;
+ if ((returnable= _io_write(ptr, vector->buffer, vector->length, false)) == -1)
+ {
+ return -1;
+ }
+ total+= returnable;
}
- total+= returnable;
}
if (with_flush)
total_nr= 0;
bool line_complete= false;
- while (not line_complete)
+ while (line_complete == false)
{
if (ptr->read_buffer_length == 0)
{
}
if (*buffer_ptr == '\n')
+ {
line_complete= true;
+ }
++buffer_ptr;
++total_nr;
{
*buffer_ptr = *ptr->read_ptr;
if (*buffer_ptr == '\n')
+ {
line_complete = true;
+ }
--ptr->read_buffer_length;
++ptr->read_ptr;
++total_nr;
}
if (total_nr == size)
+ {
return MEMCACHED_PROTOCOL_ERROR;
+ }
}
return MEMCACHED_SUCCESS;
memcached_return_t memcached_io_init_udp_header(memcached_server_write_instance_st ptr, uint16_t thread_id)
{
if (thread_id > UDP_REQUEST_ID_MAX_THREAD_ID)
+ {
return MEMCACHED_FAILURE;
+ }
struct udp_datagram_header_st *header= (struct udp_datagram_header_st *)ptr->write_buffer;
header->request_id= htons((uint16_t) (generate_udp_request_thread_id(thread_id)));