Signed-off-by: Jens Axboe <axboe@kernel.dk>
struct fio_net_cmd *cmd;
int done = 0;
struct fio_net_cmd *cmd;
int done = 0;
- while ((cmd = fio_net_recv_cmd(client->fd)) != NULL) {
+ while ((cmd = fio_net_recv_cmd(client->fd, 1)) != NULL) {
dprint(FD_NET, "%s: got cmd op %d\n", client->hostname,
cmd->opcode);
dprint(FD_NET, "%s: got cmd op %d\n", client->hostname,
cmd->opcode);
if (is_backend)
fio_server_idle_loop();
if (is_backend)
fio_server_idle_loop();
/*
* Read (and defragment, if necessary) incoming commands
*/
/*
* Read (and defragment, if necessary) incoming commands
*/
-struct fio_net_cmd *fio_net_recv_cmd(int sk)
+struct fio_net_cmd *fio_net_recv_cmd(int sk, int block)
{
struct fio_net_cmd cmd, *cmdret = NULL;
size_t cmd_size = 0, pdu_offset = 0;
{
struct fio_net_cmd cmd, *cmdret = NULL;
size_t cmd_size = 0, pdu_offset = 0;
pfd.events = POLLIN;
ret = 0;
do {
pfd.events = POLLIN;
ret = 0;
do {
- ret = poll(&pfd, 1, 100);
+ int timeo = block ? 100 : 10;
+
+ ret = poll(&pfd, 1, timeo);
if (ret < 0) {
if (errno == EINTR)
break;
log_err("fio: poll: %s\n", strerror(errno));
break;
if (ret < 0) {
if (errno == EINTR)
break;
log_err("fio: poll: %s\n", strerror(errno));
break;
+ } else if (!ret) {
+ if (!block)
+ return NULL;
if (pfd.revents & POLLIN)
break;
if (pfd.revents & POLLIN)
break;
+ } while (ret >= 0 && block);
-static int handle_connection(int sk)
+static int handle_connection(int sk, int block)
{
struct fio_net_cmd *cmd = NULL;
int ret = 0;
/* read forever */
while (!exit_backend) {
{
struct fio_net_cmd *cmd = NULL;
int ret = 0;
/* read forever */
while (!exit_backend) {
- cmd = fio_net_recv_cmd(sk);
+ cmd = fio_net_recv_cmd(sk, block);
if (!cmd) {
ret = -1;
break;
if (!cmd) {
ret = -1;
break;
void fio_server_idle_loop(void)
{
if (server_fd != -1)
void fio_server_idle_loop(void)
{
if (server_fd != -1)
- handle_connection(server_fd);
+ handle_connection(server_fd, 0);
}
static int accept_loop(int listen_sk)
}
static int accept_loop(int listen_sk)
- exitval = handle_connection(sk);
+ exitval = handle_connection(sk, 1);
server_fd = -1;
close(sk);
server_fd = -1;
close(sk);
extern int fio_recv_data(int sk, void *p, unsigned int len);
extern int fio_send_data(int sk, const void *p, unsigned int len);
extern void fio_net_cmd_crc(struct fio_net_cmd *);
extern int fio_recv_data(int sk, void *p, unsigned int len);
extern int fio_send_data(int sk, const void *p, unsigned int len);
extern void fio_net_cmd_crc(struct fio_net_cmd *);
-extern struct fio_net_cmd *fio_net_recv_cmd(int sk);
+extern struct fio_net_cmd *fio_net_recv_cmd(int sk, int block);
extern int exit_backend;
extern int fio_net_port;
extern int exit_backend;
extern int fio_net_port;