@@ 1,5 1,5 @@
/*
- * Copyright (c) 2014-2020,2022 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2014-2020,2022,2024 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ 138,7 138,7 @@ static void log_request(struct req *req)
if (request_fd < 0) {
cmn_err(CE_WARN, "Failed to open request file: %s",
xstrerror(request_fd));
- goto err;
+ return;
}
}
@@ 150,8 150,10 @@ static void log_request(struct req *req)
* allocate a log entry & store some misc info
*/
logentry = nvl_alloc();
- if (IS_ERR(logentry))
+ if (IS_ERR(logentry)) {
+ ret = PTR_ERR(logentry);
goto err;
+ }
nvl_set_int(logentry, "time-stamp", now);
nvl_set_int(logentry, "pid", getpid());
nvl_set_str(logentry, "hostname", STR_DUP(xgethostname()));
@@ 160,8 162,10 @@ static void log_request(struct req *req)
* store the version info
*/
tmp = nvl_alloc();
- if (IS_ERR(tmp))
+ if (IS_ERR(tmp)) {
+ ret = PTR_ERR(tmp);
goto err_free;
+ }
nvl_set_str(tmp, "blahgd", STATIC_STR(version_string));
nvl_set_str(tmp, "libjeffpc", STATIC_STR(jeffpc_version));
nvl_set_nvl(logentry, "version", tmp);
@@ 170,8 174,10 @@ static void log_request(struct req *req)
* store the request
*/
tmp = nvl_alloc();
- if (IS_ERR(tmp))
+ if (IS_ERR(tmp)) {
+ ret = PTR_ERR(tmp);
goto err_free;
+ }
nvl_set_int(tmp, "id", scgi->id);
nvl_set_nvl(tmp, "headers", nvl_getref(scgi->request.headers));
nvl_set_nvl(tmp, "query", nvl_getref(scgi->request.query));
@@ 188,8 194,10 @@ static void log_request(struct req *req)
* store the response
*/
tmp = nvl_alloc();
- if (IS_ERR(tmp))
+ if (IS_ERR(tmp)) {
+ ret = PTR_ERR(tmp);
goto err_free;
+ }
nvl_set_int(tmp, "status", scgi->response.status);
nvl_set_nvl(tmp, "headers", nvl_getref(scgi->response.headers));
nvl_set_int(tmp, "body-length", scgi->response.bodylen);
@@ 199,8 207,10 @@ static void log_request(struct req *req)
* store the stats
*/
tmp = nvl_alloc();
- if (IS_ERR(tmp))
+ if (IS_ERR(tmp)) {
+ ret = PTR_ERR(tmp);
goto err_free;
+ }
nvl_set_time(tmp, "conn-selected", scgi->conn_stats.selected_time);
nvl_set_time(tmp, "conn-accepted", scgi->conn_stats.accepted_time);
nvl_set_time(tmp, "conn-dequeued", scgi->conn_stats.dequeued_time);
@@ 215,15 225,19 @@ static void log_request(struct req *req)
* store the options
*/
tmp = nvl_alloc();
- if (IS_ERR(tmp))
+ if (IS_ERR(tmp)) {
+ ret = PTR_ERR(tmp);
goto err_free;
+ }
nvl_set_int(tmp, "index-stories", req->opts.index_stories);
nvl_set_nvl(logentry, "options", tmp);
/* serialize */
buf = nvl_pack(logentry, VF_CBOR);
- if (IS_ERR(buf))
+ if (IS_ERR(buf)) {
+ ret = PTR_ERR(buf);
goto err_free;
+ }
/* write out cpio header */
snprintf(cpio_hdr, sizeof(cpio_hdr), "%06o%06o%06o%06o%06o%06o%06o%06o%011lo%06zo%011zo",
@@ 265,7 279,8 @@ err_free:
nvl_putref(logentry);
err:
- DBG("Failed to log request");
+ cmn_err(CE_WARN, "Failed to log request, will rotate log: %s",
+ xstrerror(ret));
}
void req_destroy(struct req *req)