#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/socket.h>
struct sk_entry *entry;
entry = smalloc(sizeof(*entry));
+ if (!entry)
+ return NULL;
+
INIT_FLIST_HEAD(&entry->next);
entry->opcode = opcode;
if (flags & SK_F_COPY) {
{
dprint(FD_NET, "server: sending quit\n");
- return fio_net_queue_cmd(FIO_NET_CMD_QUIT, NULL, 0, NULL, SK_F_SIMPLE | SK_F_INLINE);
+ return fio_net_queue_cmd(FIO_NET_CMD_QUIT, NULL, 0, NULL, SK_F_SIMPLE);
}
int fio_net_send_quit(int sk)
epdu.error = __cpu_to_le32(error);
epdu.signal = __cpu_to_le32(signal);
- return fio_net_queue_cmd(FIO_NET_CMD_STOP, &epdu, sizeof(epdu), &tag, SK_F_COPY | SK_F_INLINE);
+ return fio_net_queue_cmd(FIO_NET_CMD_STOP, &epdu, sizeof(epdu), &tag, SK_F_COPY);
}
static int fio_net_queue_stop(int error, int signal)
dprint(FD_NET, "server: connect from %s\n", from);
- sk_out = smalloc(sizeof(*sk_out));
+ sk_out = scalloc(1, sizeof(*sk_out));
+ if (!sk_out) {
+ close(sk);
+ return -1;
+ }
+
sk_out->sk = sk;
INIT_FLIST_HEAD(&sk_out->list);
__fio_sem_init(&sk_out->lock, FIO_SEM_UNLOCKED);
*last_entry = fio_net_prep_cmd(FIO_NET_CMD_IOLOG, out_pdu, this_len,
NULL, SK_F_VEC | SK_F_INLINE | SK_F_FREE);
- flist_add_tail(&(*last_entry)->list, &first->next);
-
+ if (*last_entry)
+ flist_add_tail(&(*last_entry)->list, &first->next);
}
/*
stream->next_in = next_in;
stream->avail_in = next_sz;
do {
- if (! stream->avail_out) {
-
+ if (!stream->avail_out) {
__fio_net_prep_tail(stream, *out_pdu, last_entry, first);
+ if (*last_entry == NULL)
+ return 1;
*out_pdu = malloc(FIO_SERVER_MAX_FRAGMENT_PDU);
}
__fio_net_prep_tail(stream, out_pdu, &entry, first);
-
- return 0;
+ return entry == NULL;
}
static int __fio_append_iolog_gz(struct sk_entry *first, struct io_log *log,
entry = fio_net_prep_cmd(FIO_NET_CMD_IOLOG, out_pdu, this_len,
NULL, SK_F_VEC | SK_F_INLINE | SK_F_FREE);
+ if (!entry) {
+ free(out_pdu);
+ return 1;
+ }
flist_add_tail(&entry->list, &first->next);
} while (stream->avail_in);
entry = fio_net_prep_cmd(FIO_NET_CMD_IOLOG, out_pdu, this_len,
NULL, SK_F_VEC | SK_F_INLINE | SK_F_FREE);
+ if (!entry) {
+ free(out_pdu);
+ break;
+ }
flist_add_tail(&entry->list, &first->next);
} while (ret != Z_STREAM_END);
{
struct sk_entry *entry;
struct flist_head *node;
+ int ret = 0;
pthread_mutex_lock(&log->chunk_lock);
flist_for_each(node, &log->chunk_list) {
c = flist_entry(node, struct iolog_compress, list);
entry = fio_net_prep_cmd(FIO_NET_CMD_IOLOG, c->buf, c->len,
NULL, SK_F_VEC | SK_F_INLINE);
+ if (!entry) {
+ ret = 1;
+ break;
+ }
flist_add_tail(&entry->list, &first->next);
}
pthread_mutex_unlock(&log->chunk_lock);
-
- return 0;
+ return ret;
}
static int fio_append_text_log(struct sk_entry *first, struct io_log *log)
{
struct sk_entry *entry;
+ int ret = 0;
while (!flist_empty(&log->io_logs)) {
struct io_logs *cur_log;
entry = fio_net_prep_cmd(FIO_NET_CMD_IOLOG, cur_log->log, size,
NULL, SK_F_VEC | SK_F_INLINE);
+ if (!entry) {
+ ret = 1;
+ break;
+ }
flist_add_tail(&entry->list, &first->next);
}
- return 0;
+ return ret;
}
int fio_send_iolog(struct thread_data *td, struct io_log *log, const char *name)
* Assemble header entry first
*/
first = fio_net_prep_cmd(FIO_NET_CMD_IOLOG, &pdu, sizeof(pdu), NULL, SK_F_VEC | SK_F_INLINE | SK_F_COPY);
+ if (!first)
+ return 1;
/*
* Now append actual log entries. If log compression was enabled on