Skip to content

Commit ed9cab4

Browse files
committed
resolves boazsegev/iodine/issues/161 , credit to @MtFootFrontier (Taku YAMAMOTO)
1 parent 92091a3 commit ed9cab4

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

examples/server.c

+11-4
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,20 @@ HTTP Callbacks (see later)
7373
static void http_respond(fio_http_s *h);
7474

7575
/* *****************************************************************************
76-
Main
76+
Timers
7777
***************************************************************************** */
78-
7978
static int heartbeat(void *i1, void *i2) {
8079
(void)i1, (void)i2;
81-
if (!fio_io_is_master())
80+
if (i1 && !fio_io_is_master())
8281
return -1;
8382
FIO_LOG_INFO("(%d) heartbeat", fio_io_pid());
8483
return 0;
8584
}
8685

86+
/* *****************************************************************************
87+
Main
88+
***************************************************************************** */
89+
8790
int main(int argc, char const *argv[]) {
8891
static fio_io_async_s http_queue; /* async queue for worker threads. */
8992

@@ -166,16 +169,20 @@ int main(int argc, char const *argv[]) {
166169
"Containers sometimes impose file-system restrictions, i.e.,"),
167170
FIO_CLI_PRINT("the IPC Unix Socket might need to be placed in `/tmp`."),
168171
FIO_CLI_INT("--heartbeat -ph Prints a heartbeat every requested number "
169-
"of seconds."));
172+
"of seconds."),
173+
FIO_CLI_BOOL("-phw Prints the heartbeat also on worker processes."));
170174

171175
/* review CLI for logging */
172176
if (fio_cli_get_bool("-V")) {
173177
FIO_LOG_LEVEL = FIO_LOG_LEVEL_DEBUG;
174178
}
179+
if (fio_cli_get_bool("-phw") && !fio_cli_get_i("-ph"))
180+
fio_cli_set_i("-ph", 1);
175181
/* schedule heartbeat */
176182
if (fio_cli_get_i("-ph"))
177183
fio_io_run_every(.every = (fio_cli_get_i("-ph") * 1000),
178184
.fn = heartbeat,
185+
.udata1 = (void *)(uintptr_t)fio_cli_get_bool("-phw"),
179186
.repetitions = -1);
180187

181188
if (fio_cli_get_bool("-C")) { /* container - place pub/sub socket in tmp */

fio-stl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -44449,8 +44449,8 @@ SFUNC int fio_http_static_file_response(fio_http_s *h,
4444944449
struct {
4445044450
char *value;
4445144451
fio_buf_info_s ext;
44452-
} options[] = {{(char *)"gzip", FIO_BUF_INFO2((char *)".gz", 3)},
44453-
{(char *)"br", FIO_BUF_INFO2((char *)".br", 3)},
44452+
} options[] = {{(char *)"br", FIO_BUF_INFO2((char *)".br", 3)},
44453+
{(char *)"gzip", FIO_BUF_INFO2((char *)".gz", 3)},
4445444454
{(char *)"deflate", FIO_BUF_INFO2((char *)".zip", 4)},
4445544455
{NULL}};
4445644456
for (size_t i = 0; options[i].value; ++i) {

fio-stl/431 http handle.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3135,8 +3135,8 @@ SFUNC int fio_http_static_file_response(fio_http_s *h,
31353135
struct {
31363136
char *value;
31373137
fio_buf_info_s ext;
3138-
} options[] = {{(char *)"gzip", FIO_BUF_INFO2((char *)".gz", 3)},
3139-
{(char *)"br", FIO_BUF_INFO2((char *)".br", 3)},
3138+
} options[] = {{(char *)"br", FIO_BUF_INFO2((char *)".br", 3)},
3139+
{(char *)"gzip", FIO_BUF_INFO2((char *)".gz", 3)},
31403140
{(char *)"deflate", FIO_BUF_INFO2((char *)".zip", 4)},
31413141
{NULL}};
31423142
for (size_t i = 0; options[i].value; ++i) {

0 commit comments

Comments
 (0)