get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/16517/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 16517,
    "url": "http://patches.dpdk.org/api/patches/16517/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20161012193832.5016-1-ouster@cs.stanford.edu/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20161012193832.5016-1-ouster@cs.stanford.edu>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20161012193832.5016-1-ouster@cs.stanford.edu",
    "date": "2016-10-12T19:38:32",
    "name": "[dpdk-dev,v4] log: respect rte_openlog_stream calls before rte_eal_init",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "c3f4046295f463f1e404a5c98a55df68696e1341",
    "submitter": {
        "id": 575,
        "url": "http://patches.dpdk.org/api/people/575/?format=api",
        "name": "John Ousterhout",
        "email": "ouster@cs.stanford.edu"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20161012193832.5016-1-ouster@cs.stanford.edu/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/16517/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/16517/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 5F5C637B3;\n\tWed, 12 Oct 2016 21:38:48 +0200 (CEST)",
            "from smtp2.cs.Stanford.EDU (smtp2.cs.stanford.edu [171.64.64.26])\n\tby dpdk.org (Postfix) with ESMTP id 15799374F\n\tfor <dev@dpdk.org>; Wed, 12 Oct 2016 21:38:47 +0200 (CEST)",
            "from ouster2016.stanford.edu ([172.24.67.36]:52456\n\thelo=localhost.localdomain) by smtp2.cs.Stanford.EDU with esmtpsa\n\t(TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128)\n\t(Exim 4.84_2) (envelope-from <ouster@cs.stanford.edu>)\n\tid 1buPMT-0006dF-2B; Wed, 12 Oct 2016 12:38:46 -0700"
        ],
        "From": "John Ousterhout <ouster@cs.stanford.edu>",
        "To": "dev@dpdk.org",
        "Cc": "John Ousterhout <ouster@cs.stanford.edu>",
        "Date": "Wed, 12 Oct 2016 12:38:32 -0700",
        "Message-Id": "<20161012193832.5016-1-ouster@cs.stanford.edu>",
        "X-Mailer": "git-send-email 2.8.3",
        "In-Reply-To": "<20160928204244.8288-1-ouster@cs.stanford.edu>",
        "References": "<20160928204244.8288-1-ouster@cs.stanford.edu>",
        "X-Spam-Score": "-101.4",
        "X-Spam-Checker-Version": "SpamAssassin on smtp2.cs.Stanford.EDU",
        "X-Scan-Signature": "6a149f75f046657cdb401126c5b86f6d",
        "Subject": "[dpdk-dev] [PATCH v4] log: respect rte_openlog_stream calls before\n\trte_eal_init",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Before this patch, application-specific loggers could not be\ninstalled before rte_eal_init completed (the initialization process\ncalled rte_openlog_stream, overwriting any previously installed\nlogger). This made it impossible for an application to capture the\ninitial log messages generated during rte_eal_init. This patch changes\ninitialization so that information from a previous call to\nrte_openlog_stream is not lost. Specifically:\n* The default log stream is now maintained separately from an\n  application-specific log stream installed with rte_openlog_stream.\n* rte_eal_common_log_init has been renamed to eal_log_set_default,\n  since this is all it does. It no longer invokes rte_openlog_stream; it\n  just updates the default stream. Also, this method now returns void,\n  rather than int, since there are no errors.\n\nThis patch also removes the \"early log\" mechanism and cleans up the\nlog initialization mechanism:\n* The default log stream defaults to stderr on all platforms if\n  eal_log_set_default hasn't been invoked (Linux used to use stdout\n  during the first part of initialization).\n* Removed rte_eal_log_early_init; all of the desired functionality can\n  be achieved by calling eal_log_set_default.\n* Removed lib/librte_eal/bsdapp/eal/eal_log.c: it contained only one\n  function, rte_eal_log_init, which is not needed or invoked for BSD.\n* Removed declaration for eal_default_log_stream in rte_log.h (it's now\n  private to eal_common_log.c).\n* Moved call to rte_eal_log_init earlier in rte_eal_init for Linux, so\n  that it starts using the preferrred log ASAP.\n\nSigned-off-by: John Ousterhout <ouster@cs.stanford.edu>\n----\nv4:\n* Fixed problems from checkpatches.\n\nv3:\n* Made stderr the initial default log stream for Linux.\n* Deleted lib/librte_eal/bsdapp/eal/eal_log.c.\n* Deleted declaration for eal_default_log_stream in rte_log.h.\n* Moved rte_eal_log_init call for Linux.\n\nv2:\n* Removed the early log mechanism, renamed rte_eal_common_log_init.\n---\n lib/librte_eal/bsdapp/eal/Makefile      |  3 +-\n lib/librte_eal/bsdapp/eal/eal.c         |  6 ----\n lib/librte_eal/bsdapp/eal/eal_log.c     | 57 ---------------------------------\n lib/librte_eal/common/eal_common_log.c  | 30 ++++++++++-------\n lib/librte_eal/common/eal_private.h     | 16 +++------\n lib/librte_eal/common/include/rte_log.h |  5 +--\n lib/librte_eal/linuxapp/eal/eal.c       |  9 ++----\n lib/librte_eal/linuxapp/eal/eal_log.c   | 40 +----------------------\n 8 files changed, 29 insertions(+), 137 deletions(-)\n delete mode 100644 lib/librte_eal/bsdapp/eal/eal_log.c",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile\nindex 7a0fea5..34340c1 100644\n--- a/lib/librte_eal/bsdapp/eal/Makefile\n+++ b/lib/librte_eal/bsdapp/eal/Makefile\n@@ -50,12 +50,11 @@ EXPORT_MAP := rte_eal_version.map\n \n LIBABIVER := 3\n \n-# specific to linuxapp exec-env\n+# specific to bsdapp exec-env\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) := eal.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_memory.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_hugepage_info.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_thread.c\n-SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_log.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_pci.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_debug.c\n SRCS-$(CONFIG_RTE_EXEC_ENV_BSDAPP) += eal_lcore.c\ndiff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c\nindex a0c8f8c..6a6ae86 100644\n--- a/lib/librte_eal/bsdapp/eal/eal.c\n+++ b/lib/librte_eal/bsdapp/eal/eal.c\n@@ -501,9 +501,6 @@ rte_eal_init(int argc, char **argv)\n \n \tthread_id = pthread_self();\n \n-\tif (rte_eal_log_early_init() < 0)\n-\t\trte_panic(\"Cannot init early logs\\n\");\n-\n \teal_log_level_parse(argc, argv);\n \n \t/* set log level as early as possible */\n@@ -552,9 +549,6 @@ rte_eal_init(int argc, char **argv)\n \tif (rte_eal_tailqs_init() < 0)\n \t\trte_panic(\"Cannot init tail queues for objects\\n\");\n \n-/*\tif (rte_eal_log_init(argv[0], internal_config.syslog_facility) < 0)\n-\t\trte_panic(\"Cannot init logs\\n\");*/\n-\n \tif (rte_eal_alarm_init() < 0)\n \t\trte_panic(\"Cannot init interrupt-handling thread\\n\");\n \ndiff --git a/lib/librte_eal/bsdapp/eal/eal_log.c b/lib/librte_eal/bsdapp/eal/eal_log.c\ndeleted file mode 100644\nindex a425f7a..0000000\n--- a/lib/librte_eal/bsdapp/eal/eal_log.c\n+++ /dev/null\n@@ -1,57 +0,0 @@\n-/*-\n- *   BSD LICENSE\n- *\n- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n- *   All rights reserved.\n- *\n- *   Redistribution and use in source and binary forms, with or without\n- *   modification, are permitted provided that the following conditions\n- *   are met:\n- *\n- *     * Redistributions of source code must retain the above copyright\n- *       notice, this list of conditions and the following disclaimer.\n- *     * Redistributions in binary form must reproduce the above copyright\n- *       notice, this list of conditions and the following disclaimer in\n- *       the documentation and/or other materials provided with the\n- *       distribution.\n- *     * Neither the name of Intel Corporation nor the names of its\n- *       contributors may be used to endorse or promote products derived\n- *       from this software without specific prior written permission.\n- *\n- *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n- *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n- *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n- *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n- *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n- *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n- *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n- *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n- *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n- *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n- */\n-\n-#include <stdio.h>\n-#include <rte_common.h>\n-#include <rte_log.h>\n-\n-#include <eal_private.h>\n-\n-/*\n- * set the log to default function, called during eal init process,\n- * once memzones are available.\n- */\n-int\n-rte_eal_log_init(const char *id __rte_unused, int facility __rte_unused)\n-{\n-\tif (rte_eal_common_log_init(stderr) < 0)\n-\t\treturn -1;\n-\treturn 0;\n-}\n-\n-int\n-rte_eal_log_early_init(void)\n-{\n-\trte_openlog_stream(stderr);\n-\treturn 0;\n-}\ndiff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c\nindex 967991a..e45d326 100644\n--- a/lib/librte_eal/common/eal_common_log.c\n+++ b/lib/librte_eal/common/eal_common_log.c\n@@ -48,11 +48,12 @@ struct rte_logs rte_logs = {\n \t.file = NULL,\n };\n \n+/* Stream to use for logging if rte_logs.file is NULL */\n static FILE *default_log_stream;\n \n /**\n  * This global structure stores some informations about the message\n- * that is currently beeing processed by one lcore\n+ * that is currently being processed by one lcore\n  */\n struct log_cur_msg {\n \tuint32_t loglevel; /**< log level - see rte_log.h */\n@@ -68,10 +69,7 @@ static RTE_DEFINE_PER_LCORE(struct log_cur_msg, log_cur_msg);\n int\n rte_openlog_stream(FILE *f)\n {\n-\tif (f == NULL)\n-\t\trte_logs.file = default_log_stream;\n-\telse\n-\t\trte_logs.file = f;\n+\trte_logs.file = f;\n \treturn 0;\n }\n \n@@ -127,6 +125,19 @@ rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)\n {\n \tint ret;\n \tFILE *f = rte_logs.file;\n+\tif (f == NULL) {\n+\t\tf = default_log_stream;\n+\t\tif (f == NULL) {\n+\t\t\t/*\n+\t\t\t * Grab the current value of stderr here, rather than\n+\t\t\t * just initializing default_log_stream to stderr. This\n+\t\t\t * ensures that we will always use the current value\n+\t\t\t * of stderr, even if the application closes and\n+\t\t\t * reopens it.\n+\t\t\t */\n+\t\t\tf = stderr;\n+\t\t}\n+\t}\n \n \tif ((level > rte_logs.level) || !(logtype & rte_logs.type))\n \t\treturn 0;\n@@ -158,17 +169,14 @@ rte_log(uint32_t level, uint32_t logtype, const char *format, ...)\n }\n \n /*\n- * called by environment-specific log init function\n+ * Called by environment-specific initialization functions.\n  */\n-int\n-rte_eal_common_log_init(FILE *default_log)\n+void\n+eal_log_set_default(FILE *default_log)\n {\n \tdefault_log_stream = default_log;\n-\trte_openlog_stream(default_log);\n \n #if RTE_LOG_LEVEL >= RTE_LOG_DEBUG\n \tRTE_LOG(NOTICE, EAL, \"Debug logs available - lower performance\\n\");\n #endif\n-\n-\treturn 0;\n }\ndiff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h\nindex 19f7535..0ab9eba 100644\n--- a/lib/librte_eal/common/eal_private.h\n+++ b/lib/librte_eal/common/eal_private.h\n@@ -47,7 +47,9 @@\n int rte_eal_memzone_init(void);\n \n /**\n- * Common log initialization function (private to eal).\n+ * Common log initialization function (private to eal).  Determines\n+ * where log data is written when no call to rte_openlog_stream is\n+ * in effect.\n  *\n  * @param default_log\n  *   The default log stream to be used.\n@@ -55,7 +57,7 @@ int rte_eal_memzone_init(void);\n  *   - 0 on success\n  *   - Negative on error\n  */\n-int rte_eal_common_log_init(FILE *default_log);\n+void eal_log_set_default(FILE *default_log);\n \n /**\n  * Fill configuration with number of physical and logical processors\n@@ -97,16 +99,6 @@ int rte_eal_memory_init(void);\n int rte_eal_timer_init(void);\n \n /**\n- * Init early logs\n- *\n- * This function is private to EAL.\n- *\n- * @return\n- *   0 on success, negative on error\n- */\n-int rte_eal_log_early_init(void);\n-\n-/**\n  * Init the default log stream\n  *\n  * This function is private to EAL.\ndiff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h\nindex 919563c..29f7d19 100644\n--- a/lib/librte_eal/common/include/rte_log.h\n+++ b/lib/librte_eal/common/include/rte_log.h\n@@ -54,7 +54,7 @@ extern \"C\" {\n struct rte_logs {\n \tuint32_t type;  /**< Bitfield with enabled logs. */\n \tuint32_t level; /**< Log level. */\n-\tFILE *file;     /**< Pointer to current FILE* for logs. */\n+\tFILE *file;     /**< Output file set by rte_openlog_stream, or NULL. */\n };\n \n /** Global log informations */\n@@ -100,9 +100,6 @@ extern struct rte_logs rte_logs;\n #define RTE_LOG_INFO     7U  /**< Informational.                    */\n #define RTE_LOG_DEBUG    8U  /**< Debug-level messages.             */\n \n-/** The default log stream. */\n-extern FILE *eal_default_log_stream;\n-\n /**\n  * Change the stream that will be used by the logging system.\n  *\ndiff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c\nindex d5b81a3..1c7bacc 100644\n--- a/lib/librte_eal/linuxapp/eal/eal.c\n+++ b/lib/librte_eal/linuxapp/eal/eal.c\n@@ -748,9 +748,6 @@ rte_eal_init(int argc, char **argv)\n \n \tthread_id = pthread_self();\n \n-\tif (rte_eal_log_early_init() < 0)\n-\t\trte_panic(\"Cannot init early logs\\n\");\n-\n \teal_log_level_parse(argc, argv);\n \n \t/* set log level as early as possible */\n@@ -789,6 +786,9 @@ rte_eal_init(int argc, char **argv)\n \n \trte_config_init();\n \n+\tif (rte_eal_log_init(logid, internal_config.syslog_facility) < 0)\n+\t\trte_panic(\"Cannot init logs\\n\");\n+\n \tif (rte_eal_pci_init() < 0)\n \t\trte_panic(\"Cannot init PCI\\n\");\n \n@@ -809,9 +809,6 @@ rte_eal_init(int argc, char **argv)\n \tif (rte_eal_tailqs_init() < 0)\n \t\trte_panic(\"Cannot init tail queues for objects\\n\");\n \n-\tif (rte_eal_log_init(logid, internal_config.syslog_facility) < 0)\n-\t\trte_panic(\"Cannot init logs\\n\");\n-\n \tif (rte_eal_alarm_init() < 0)\n \t\trte_panic(\"Cannot init interrupt-handling thread\\n\");\n \ndiff --git a/lib/librte_eal/linuxapp/eal/eal_log.c b/lib/librte_eal/linuxapp/eal/eal_log.c\nindex d391100..e3a50aa 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_log.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_log.c\n@@ -97,45 +97,7 @@ rte_eal_log_init(const char *id, int facility)\n \n \topenlog(id, LOG_NDELAY | LOG_PID, facility);\n \n-\tif (rte_eal_common_log_init(log_stream) < 0)\n-\t\treturn -1;\n-\n-\treturn 0;\n-}\n-\n-/* early logs */\n-\n-/*\n- * early log function, used before rte_eal_log_init\n- */\n-static ssize_t\n-early_log_write(__attribute__((unused)) void *c, const char *buf, size_t size)\n-{\n-\tssize_t ret;\n-\tret = fwrite(buf, size, 1, stdout);\n-\tfflush(stdout);\n-\tif (ret == 0)\n-\t\treturn -1;\n-\treturn ret;\n-}\n-\n-static cookie_io_functions_t early_log_func = {\n-\t.write = early_log_write,\n-};\n-static FILE *early_log_stream;\n+\teal_log_set_default(log_stream);\n \n-/*\n- * init the log library, called by rte_eal_init() to enable early\n- * logs\n- */\n-int\n-rte_eal_log_early_init(void)\n-{\n-\tearly_log_stream = fopencookie(NULL, \"w+\", early_log_func);\n-\tif (early_log_stream == NULL) {\n-\t\tprintf(\"Cannot configure early_log_stream\\n\");\n-\t\treturn -1;\n-\t}\n-\trte_openlog_stream(early_log_stream);\n \treturn 0;\n }\n",
    "prefixes": [
        "dpdk-dev",
        "v4"
    ]
}