# HG changeset patch # User Josef 'Jeff' Sipek # Date 1706583107 18000 # Mon Jan 29 21:51:47 2024 -0500 # Node ID 3fafcc8035ad336f2e04955258733bf041ae48a5 # Parent a3c884b3ea903b5c77e7230fb04a01db4621b987 req: log the reason for log request failure This will include the session and thread ids. That should make sifting through any partially written logs easier. Signed-off-by: Josef 'Jeff' Sipek diff --git a/req.c b/req.c --- a/req.c +++ b/req.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2020,2022 Josef 'Jeff' Sipek + * Copyright (c) 2014-2020,2022,2024 Josef 'Jeff' Sipek * * 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 @@ if (request_fd < 0) { cmn_err(CE_WARN, "Failed to open request file: %s", xstrerror(request_fd)); - goto err; + return; } } @@ -150,8 +150,10 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ * 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 @@ 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)