Changeset ef5be68 in mainline
- Timestamp:
- 2012-07-14T11:42:41Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2e39656
- Parents:
- f6bc83a
- Location:
- uspace/srv/logger
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/logger/logger.h
rf6bc83a ref5be68 62 62 void namespace_destroy(logging_namespace_t *); 63 63 logging_namespace_t *namespace_reader_attach(const char *); 64 logging_namespace_t *namespace_writer_attach(const char *); 64 65 void namespace_reader_detach(logging_namespace_t *); 65 66 void namespace_writer_detach(logging_namespace_t *); -
uspace/srv/logger/main.c
rf6bc83a ref5be68 47 47 #include "logger.h" 48 48 49 static logging_namespace_t * register_namespace(void)49 static logging_namespace_t *find_namespace_and_attach_writer(void) 50 50 { 51 51 ipc_call_t call; … … 65 65 } 66 66 67 logging_namespace_t *result = namespace_ create((const char *) name);67 logging_namespace_t *result = namespace_writer_attach((const char *) name); 68 68 69 69 free(name); … … 224 224 /* First call has to be the registration. */ 225 225 async_answer_0(iid, EOK); 226 namespace = register_namespace();226 namespace = find_namespace_and_attach_writer(); 227 227 if (namespace == NULL) { 228 228 fprintf(stderr, NAME ": failed to register namespace.\n"); -
uspace/srv/logger/namespace.c
rf6bc83a ref5be68 42 42 struct logging_namespace { 43 43 fibril_mutex_t guard; 44 bool has_writer;44 size_t writers_count; 45 45 bool has_reader; 46 46 const char *name; … … 114 114 prodcons_initialize(&namespace->messages); 115 115 namespace->has_reader = false; 116 namespace-> has_writer = true;116 namespace->writers_count = 0; 117 117 link_initialize(&namespace->link); 118 118 … … 135 135 136 136 fibril_mutex_lock(&namespace->guard); 137 if (namespace->has_reader || namespace->has_writer) {137 if (namespace->has_reader || (namespace->writers_count > 0)) { 138 138 fibril_mutex_unlock(&namespace->guard); 139 139 fibril_mutex_unlock(&namespace_list_guard); … … 175 175 } 176 176 177 logging_namespace_t *namespace_writer_attach(const char *name) 178 { 179 logging_namespace_t *namespace = NULL; 180 181 fibril_mutex_lock(&namespace_list_guard); 182 183 namespace = namespace_find_no_lock(name); 184 185 if (namespace == NULL) { 186 namespace = namespace_create(name); 187 } 188 189 fibril_mutex_lock(&namespace->guard); 190 namespace->writers_count++; 191 fibril_mutex_unlock(&namespace->guard); 192 193 fibril_mutex_unlock(&namespace_list_guard); 194 195 return namespace; 196 } 197 177 198 void namespace_reader_detach(logging_namespace_t *namespace) 178 199 { … … 187 208 { 188 209 fibril_mutex_lock(&namespace->guard); 189 namespace->has_writer = false; 210 assert(namespace->writers_count > 0); 211 namespace->writers_count--; 190 212 fibril_mutex_unlock(&namespace->guard); 191 213
Note:
See TracChangeset
for help on using the changeset viewer.