projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Server logging cleanup/functionality
[fio.git]
/
server.c
diff --git
a/server.c
b/server.c
index 1749e7365bb446076366ad50f6a0db4c8a7be81d..4a78f38396c2a2eb0fc99808d565288c7e695705 100644
(file)
--- a/
server.c
+++ b/
server.c
@@
-1,5
+1,6
@@
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
@@
-367,11
+368,12
@@
int fio_server(void)
return ret;
}
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;
{
struct fio_net_cmd *cmd;
+ int size = sizeof(*cmd) + len;
- cmd = malloc(size
of(*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_init_net_cmd(cmd);
cmd->opcode = cpu_to_le16(FIO_NET_CMD_TEXT);
cmd->pdu_len = cpu_to_le32(len);
@@
-379,6
+381,19
@@
void fio_server_text_output(const char *buf, unsigned int len)
fio_net_cmd_crc(cmd);
fio_net_cmd_crc(cmd);
- fio_send_data(server_fd, cmd, size
of(*cmd) + len
);
+ fio_send_data(server_fd, cmd, size);
free(cmd);
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));
}
}