Changeset 2e39656 in mainline for uspace/srv/logger/namespace.c


Ignore:
Timestamp:
2012-07-14T17:41:01Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ceafd1b
Parents:
ef5be68
Message:

Check for log readers in separate fibril

Do not even try to send when no reader was announced.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/logger/namespace.c

    ref5be68 r2e39656  
    4343        fibril_mutex_t guard;
    4444        size_t writers_count;
     45        fibril_condvar_t reader_appeared_cv;
    4546        bool has_reader;
    4647        const char *name;
     
    167168                fibril_mutex_lock(&namespace->guard);
    168169                namespace->has_reader = true;
     170                fibril_condvar_broadcast(&namespace->reader_appeared_cv);
    169171                fibril_mutex_unlock(&namespace->guard);
    170172        }
     
    200202        fibril_mutex_lock(&namespace->guard);
    201203        namespace->has_reader = false;
     204        fibril_condvar_broadcast(&namespace->reader_appeared_cv);
    202205        fibril_mutex_unlock(&namespace->guard);
    203206
     
    221224        fibril_mutex_unlock(&namespace->guard);
    222225        return has_reader;
     226}
     227
     228void namespace_wait_for_reader_change(logging_namespace_t *namespace, bool *has_reader_now)
     229{
     230        fibril_mutex_lock(&namespace->guard);
     231        bool had_reader = namespace->has_reader;
     232        while (had_reader == namespace->has_reader) {
     233                fibril_condvar_wait(&namespace->reader_appeared_cv, &namespace->guard);
     234        }
     235        *has_reader_now = namespace->has_reader;
     236        fibril_mutex_unlock(&namespace->guard);
    223237}
    224238
Note: See TracChangeset for help on using the changeset viewer.