- ssize_t sent_length= memcached_io_writev(instance, vector, count, with_flush);
- size_t command_length= 0;
- for (uint32_t x= 0; x < count; ++x, vector++)
- {
- command_length+= vector->length;
+ increment_udp_message_id(instance);
+ vector[0].buffer= instance->write_buffer;
+ vector[0].length= UDP_DATAGRAM_HEADER_LENGTH;
+
+ msg.msg_iov= (struct iovec*)vector;
+#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+ msg.msg_iovlen= int(count);
+#else
+ msg.msg_iovlen= count;
+#endif
+
+ uint32_t retry= 5;
+ while (--retry)
+ {
+ ssize_t sendmsg_length= ::sendmsg(instance->fd, &msg, 0);
+ if (sendmsg_length > 0)
+ {
+ break;
+ }
+ else if (sendmsg_length < 0)
+ {
+ if (errno == EMSGSIZE)
+ {
+ return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT);
+ }
+
+ return memcached_set_errno(*instance, errno, MEMCACHED_AT);
+ }
+ }
+
+ return MEMCACHED_SUCCESS;