rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
lib/num2str.c $(wildcard crc/*.c) engines/cpu.c \
engines/mmap.c engines/sync.c engines/null.c engines/net.c \
- memalign.c server.c client.c
+ memalign.c server.c client.c infolog.c
ifeq ($(UNAME), Linux)
SOURCE += diskutil.c fifo.c blktrace.c helpers.c cgroup.c trim.c \
while (!exit_backend) {
cmd = fio_net_cmd_read(fio_client_fd);
+ if (!cmd)
+ continue;
if (cmd->opcode == FIO_NET_CMD_ACK) {
free(cmd);
--- /dev/null
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "fio.h"
+
+int log_info(const char *format, ...)
+{
+ char buffer[1024];
+ va_list args;
+ size_t len;
+
+ va_start(args, format);
+ len = vsprintf(buffer, format, args);
+ va_end(args);
+
+ if (is_backend)
+ return fio_server_text_output(buffer, len);
+ else
+ return fwrite(buffer, len, 1, f_out);
+}
+
+int log_err(const char *format, ...)
+{
+ char buffer[1024];
+ va_list args;
+ size_t len;
+
+ va_start(args, format);
+ len = vsprintf(buffer, format, args);
+ va_end(args);
+
+ if (is_backend)
+ return fio_server_text_output(buffer, len);
+ else
+ return fwrite(buffer, len, 1, f_err);
+}
},
};
-FILE *get_f_out()
-{
- return f_out;
-}
-
-FILE *get_f_err()
-{
- return f_err;
-}
-
/*
* Return a free job structure.
*/
extern FILE *f_out;
extern FILE *f_err;
-/*
- * If logging output to a file, stderr should go to both stderr and f_err
- */
-#define log_err(args, ...) do { \
- fprintf(f_err, args, ##__VA_ARGS__); \
- if (f_err != stderr) \
- fprintf(stderr, args, ##__VA_ARGS__); \
- } while (0)
+extern int log_err(const char *format, ...);
+extern int log_info(const char *format, ...);
-#define log_info(args, ...) fprintf(f_out, args, ##__VA_ARGS__)
#define log_valist(str, args) vfprintf(f_out, (str), (args))
-FILE *get_f_out(void);
-FILE *get_f_err(void);
-
#endif
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
return ret;
}
-void fio_server_text_output(const char *buf, unsigned int len)
+int fio_server_text_output(const char *buf, unsigned int len)
{
struct fio_net_cmd *cmd;
+ int size = sizeof(*cmd) + len;
- cmd = malloc(sizeof(*cmd) + len);
+ cmd = malloc(size);
fio_init_net_cmd(cmd);
cmd->opcode = cpu_to_le16(FIO_NET_CMD_TEXT);
cmd->pdu_len = cpu_to_le32(len);
fio_net_cmd_crc(cmd);
- fio_send_data(server_fd, cmd, sizeof(*cmd) + len);
+ fio_send_data(server_fd, cmd, size);
free(cmd);
+ return size;
+}
+
+int fio_server_log(const char *format, ...)
+{
+ char buffer[1024];
+ va_list args;
+
+ va_start(args, format);
+ sprintf(buffer, format, args);
+ va_end(args);
+
+ return fio_server_text_output(buffer, strlen(buffer));
}
#define FIO_SERVER_H
#include <inttypes.h>
+#include <string.h>
#include <endian.h>
/*
};
extern int fio_server(void);
-extern void fio_server_text_output(const char *, unsigned int len);
+extern int fio_server_text_output(const char *, unsigned int len);
+extern int fio_server_log(const char *format, ...);
extern int fio_client_connect(const char *);
extern int fio_client_send_ini(const char *);