* @param c, pointer of the concurrency
* @param is_udp, whether it's udp
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_conn_udp_init(ms_conn_t *c, const bool is_udp)
{
memset(c->udppkt, 0, MAX_UDP_PACKET * sizeof(ms_udppkt_t));
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_conn_udp_init */
* @param read_buffer_size
* @param is_udp, whether it's udp
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_conn_init(ms_conn_t *c,
const int init_state,
atomic_add_32(&ms_stats.active_conns, 1);
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_conn_init */
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_item_win_init(ms_conn_t *c)
{
ms_warmup_num_init(c);
- return 0;
+ return EXIT_SUCCESS;
} /* ms_item_win_init */
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_conn_sock_init(ms_conn_t *c)
{
return -1;
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_conn_sock_init */
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_conn_event_init(ms_conn_t *c)
{
return -1;
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_conn_event_init */
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
int ms_setup_conn(ms_conn_t *c)
{
return -1;
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_setup_conn */
*
* @param ai, server address information
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_new_socket(struct addrinfo *ai)
{
* @param is_udp, whether it's udp
* @param ret_sfd, the connected socket file descriptor
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_network_connect(ms_conn_t *c,
char *srv_host_name,
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_reconn(ms_conn_t *c)
{
c->alive_sfds--;
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_reconn */
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
int ms_reconn_socks(ms_conn_t *c)
{
if ((c->total_sfds == 1) || (c->total_sfds == c->alive_sfds))
{
- return 0;
+ return EXIT_SUCCESS;
}
for (uint32_t i= 0; i < c->total_sfds; i++)
}
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_reconn_socks */
* @param c, pointer of the concurrency
* @param command, the string responded by server
*
- * @return int, if the command completed return 0, else return
+ * @return int, if the command completed return EXIT_SUCCESS, else return
* -1
*/
static int ms_ascii_process_line(ms_conn_t *c, char *command)
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_try_read_line(ms_conn_t *c)
{
if ((uint64_t)c->rbytes < sizeof(c->binary_header))
{
/* need more data! */
- return 0;
+ return EXIT_SUCCESS;
}
else
{
fprintf(stderr, "Invalid magic: %x\n",
c->binary_header.response.magic);
ms_conn_set_state(c, conn_closing);
- return 0;
+ return EXIT_SUCCESS;
}
/* process this complete response */
assert(c->rcurr <= (c->rbuf + c->rsize));
if (c->rbytes == 0)
- return 0;
+ return EXIT_SUCCESS;
el= memchr(c->rcurr, '\n', (size_t)c->rbytes);
if (! el)
- return 0;
+ return EXIT_SUCCESS;
cont= el + 1;
if (((el - c->rcurr) > 1) && (*(el - 1) == '\r'))
* close.
* before reading, move the remaining incomplete fragment of a command
* (if any) to the beginning of the buffer.
- * return 0 if there's nothing to read on the first read.
+ * return EXIT_SUCCESS if there's nothing to read on the first read.
*/
/**
* @param c, pointer of the concurrency
*
* @return int,
- * return 0 if there's nothing to read on the first read.
- * return 1 if get data
+ * return EXIT_SUCCESS if there's nothing to read on the first read.
+ * return EXIT_FAILURE if get data
* return -1 if error happens
*/
static int ms_try_read_network(ms_conn_t *c)
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_add_msghdr(ms_conn_t *c)
{
return ms_add_iov(c, NULL, UDP_HEADER_SIZE);
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_add_msghdr */
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_ensure_iov_space(ms_conn_t *c)
{
}
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_ensure_iov_space */
* @param buf, the buffer includes data to send
* @param len, the data length in the buffer
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_add_iov(ms_conn_t *c, const void *buf, int len)
{
}
while (leftover > 0);
- return 0;
+ return EXIT_SUCCESS;
} /* ms_add_iov */
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_build_udp_headers(ms_conn_t *c)
{
+ UDP_HEADER_SIZE));
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_build_udp_headers */
* @param c, pointer of the concurrency
* @param cmd, command(get or set )
*
- * @return int, if success, return the index, else return 0
+ * @return int, if success, return the index, else return EXIT_SUCCESS
*/
static uint32_t ms_get_rep_sock_index(ms_conn_t *c, int cmd)
{
if (c->total_sfds == 1)
{
- return 0;
+ return EXIT_SUCCESS;
}
if (ms_setting.rep_write_srv == 0)
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_update_conn_sock_event(ms_conn_t *c)
{
}
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_update_conn_sock_event */
* @param item, pointer of task item which includes the object
* information
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_build_ascii_write_buf_set(ms_conn_t *c, ms_task_item_t *item)
{
return -1;
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_build_ascii_write_buf_set */
* @param item, pointer of task item which includes the object
* information
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
int ms_mcd_set(ms_conn_t *c, ms_task_item_t *item)
{
item->key_size + item->value_size);
atomic_add_size(&ms_stats.cmd_set, 1);
- return 0;
+ return EXIT_SUCCESS;
} /* ms_mcd_set */
* @param item, pointer of task item which includes the object
* information
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_build_ascii_write_buf_get(ms_conn_t *c, ms_task_item_t *item)
{
return -1;
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_build_ascii_write_buf_get */
* @param item, pointer of task item which includes the object
* information
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
int ms_mcd_get(ms_conn_t *c, ms_task_item_t *item)
{
atomic_add_size(&ms_stats.cmd_get, 1);
- return 0;
+ return EXIT_SUCCESS;
} /* ms_mcd_get */
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_build_ascii_write_buf_mlget(ms_conn_t *c)
{
return -1;
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_build_ascii_write_buf_mlget */
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
int ms_mcd_mlget(ms_conn_t *c)
{
atomic_add_size(&ms_stats.cmd_get, 1);
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_mcd_mlget */
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_bin_process_response(ms_conn_t *c)
{
{
c->rvbytes= (int32_t)bodylen;
c->readval= true;
- return 1;
+ return EXIT_FAILURE;
}
else
{
}
}
- return 0;
+ return EXIT_SUCCESS;
} /* ms_bin_process_response */
* @param item, pointer of task item which includes the object
* information
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_build_bin_write_buf_set(ms_conn_t *c, ms_task_item_t *item)
{
}
ms_add_iov(c, &ms_setting.char_block[value_offset], item->value_size);
- return 0;
+ return EXIT_SUCCESS;
} /* ms_build_bin_write_buf_set */
* @param item, pointer of task item which includes the object
* information
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_build_bin_write_buf_get(ms_conn_t *c, ms_task_item_t *item)
{
(uint32_t)item->key_size);
ms_add_key_to_iov(c, item);
- return 0;
+ return EXIT_SUCCESS;
} /* ms_build_bin_write_buf_get */
* @param item, pointer of task item which includes the object
* information
*
- * @return int, if success, return 0, else return -1
+ * @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_build_bin_write_buf_mlget(ms_conn_t *c)
{
c->wcurr= c->wbuf;
- return 0;
+ return EXIT_SUCCESS;
} /* ms_build_bin_write_buf_mlget */