@@ -183,7 +183,7 @@ memcached_send_meta(memcached_st *ptr, memcached_instance_st *instance,
183183 time_t expiration, uint32_t flags, uint64_t cas,
184184 bool flush, memcached_storage_action_t verb) {
185185 static const char modes[] = " SREPAS" ;
186- char fl_buf[32 ] = " F" , cs_buf[32 ] = " C" , ex_buf[32 ] = " T" , sz_buf[32 ] = " S " ;
186+ char fl_buf[32 ] = " F" , cs_buf[32 ] = " C" , ex_buf[32 ] = " T" , sz_buf[32 ] = " " ;
187187 size_t io_num = 0 , fl_len = strlen (fl_buf), cs_len = strlen (cs_buf), ex_len = strlen (ex_buf), sz_len = strlen (sz_buf);
188188 libmemcached_io_vector_st io_vec[16 ] = {};
189189
@@ -192,6 +192,9 @@ memcached_send_meta(memcached_st *ptr, memcached_instance_st *instance,
192192 memcached_array_size (ptr->_namespace )};
193193 io_vec[io_num++] = {key, key_len};
194194
195+ sz_len += snprintf (sz_buf + sz_len, sizeof (sz_buf) - sz_len, " %" PRIu64, (uint64_t ) val_len);
196+ io_vec[io_num++] = {sz_buf, sz_len};
197+
195198 if (verb != SET_OP) {
196199 io_vec[io_num++] = {memcached_literal_param (" M" )};
197200 io_vec[io_num++] = {&modes[verb], 1 };
@@ -213,8 +216,6 @@ memcached_send_meta(memcached_st *ptr, memcached_instance_st *instance,
213216 }
214217
215218 /* we have to send a data block even if it's empty, else memcached errors out with ITEM TOO BIG */
216- sz_len += snprintf (sz_buf + sz_len, sizeof (sz_buf) - sz_len, " %" PRIu64, (uint64_t ) val_len);
217- io_vec[io_num++] = {sz_buf, sz_len};
218219 io_vec[io_num++] = {memcached_literal_param (" \r\n " )};
219220 io_vec[io_num++] = {val, val_len};
220221 io_vec[io_num++] = {memcached_literal_param (" \r\n " )};
0 commit comments