at work
This commit is contained in:
12
cworker.c
12
cworker.c
@@ -45,7 +45,7 @@
|
||||
#include <cworker.h>
|
||||
#include <logger.h>
|
||||
|
||||
static const int64_t default_port = 9701;
|
||||
static const int64_t default_port = 9002;
|
||||
static cworker_t* pworker = NULL;
|
||||
|
||||
static int mkdirall(const char* path, mode_t mode);
|
||||
@@ -288,11 +288,16 @@ int cworker_handler(const cworker_t* worker, int socket) {
|
||||
}
|
||||
|
||||
int64_t id = 0;
|
||||
int64_t timeout = 0;
|
||||
char* name = "none";
|
||||
|
||||
if (jparser_bind(&parser, JVALTYPE_NUM, "id", (void *)&id) < 0) {
|
||||
log_error("Cannot bind id");
|
||||
}
|
||||
if (jparser_bind(&parser, JVALTYPE_NUM, "timeout", (void *)&timeout) < 0) {
|
||||
log_error("Cannot bind timeout");
|
||||
}
|
||||
|
||||
if (jparser_bind(&parser, JVALTYPE_STR, "name", (void *)&name) < 0) {
|
||||
log_error("Cannot bind name");
|
||||
}
|
||||
@@ -306,7 +311,12 @@ int cworker_handler(const cworker_t* worker, int socket) {
|
||||
jblock_addstr(&jb, "message", msg);
|
||||
jblock_addbool(&jb, "error", false);
|
||||
jblock_addint(&jb, "id", id);
|
||||
jblock_addint(&jb, "timeout", timeout);
|
||||
|
||||
for (int64_t i = 0; i < timeout; i++) {
|
||||
log_debug("The handler slept for %ld second from %ld", i + 1, timeout);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
char* jsonstr = NULL;
|
||||
jblock_outjson(&jb, &jsonstr);
|
||||
|
||||
Reference in New Issue
Block a user