Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset f6bc83a in mainline


Ignore:
Timestamp:
2012-07-04T13:21:52Z (10 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial
Children:
ef5be68
Parents:
e1eda1e9
Message:

Send log messages only when they are read

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/log.c

    re1eda1e9 rf6bc83a  
    8787        async_exchange_end(exchange);
    8888
     89        /*
     90         * Getting ENAK means no-one wants our message. That is not an
     91         * error at all.
     92         */
     93        if (rc == ENAK)
     94                rc = EOK;
     95
    8996        if (rc != EOK) {
    9097                return rc;
  • uspace/srv/logger/logger.h

    re1eda1e9 rf6bc83a  
    6565void namespace_writer_detach(logging_namespace_t *);
    6666
     67bool namespace_has_reader(logging_namespace_t *);
    6768void namespace_add_message(logging_namespace_t *, const char *, log_level_t);
    6869log_message_t *namespace_get_next_message(logging_namespace_t *);
  • uspace/srv/logger/main.c

    re1eda1e9 rf6bc83a  
    7474static int handle_receive_message(logging_namespace_t *namespace, int level)
    7575{
     76        bool skip_message = (level > DEFAULT_LOGGING_LEVEL) || !namespace_has_reader(namespace);
     77        if (skip_message) {
     78                /* Abort the actual message buffer transfer. */
     79                ipc_callid_t callid;
     80                size_t size;
     81                int rc = ENAK;
     82                if (!async_data_write_receive(&callid, &size))
     83                        rc = EINVAL;
     84
     85                async_answer_0(callid, rc);
     86                return rc;
     87        }
     88
    7689        void *message;
    7790        int rc = async_data_write_accept(&message, true, 0, 0, 0, NULL);
  • uspace/srv/logger/namespace.c

    re1eda1e9 rf6bc83a  
    193193}
    194194
     195bool namespace_has_reader(logging_namespace_t *namespace)
     196{
     197        fibril_mutex_lock(&namespace->guard);
     198        bool has_reader = namespace->has_reader;
     199        fibril_mutex_unlock(&namespace->guard);
     200        return has_reader;
     201}
    195202
    196203
Note: See TracChangeset for help on using the changeset viewer.