Changeset d5cca04 in mainline


Ignore:
Timestamp:
2019-08-17T13:10:27Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
ff20afc
Parents:
87a31ef2
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-12-04 13:30:06)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-17 13:10:27)
Message:

sysman: Remove unsynchronized access to observer hash table

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/sysman/sysman.c

    r87a31ef2 rd5cca04  
    6363} observed_object_t;
    6464
     65typedef struct {
     66        job_t *job;
     67        callback_handler_t callback;
     68        void *callback_arg;
     69} job_args_t;
     70
    6571static LIST_INITIALIZE(event_queue);
    6672static fibril_mutex_t event_queue_mtx;
     
    214220        }
    215221
    216         if (callback != NULL) {
    217                 job_add_ref(job);
    218                 //TODO sysman_object_observer is not fibril-safe CANNOT BE CALLED HERE!
    219                 sysman_object_observer(job, callback, callback_arg);
    220         }
    221 
    222         /* Pass reference to event */
    223         sysman_raise_event(&sysman_event_job_process, job);
     222        job_args_t *job_args = malloc(sizeof(job_args_t));
     223        if (job_args == NULL) {
     224                job_del_ref(&job);
     225                return ENOMEM;
     226        }
     227
     228        /* Pass reference to job_args */
     229        job_args->job = job;
     230        job_args->callback = callback;
     231        job_args->callback_arg = callback_arg;
     232
     233        sysman_raise_event(&sysman_event_job_process, job_args);
    224234
    225235        return EOK;
     
    354364void sysman_event_job_process(void *data)
    355365{
    356         job_t *job = data;
     366        job_args_t *job_args = data;
     367        job_t *job = job_args->job;
    357368        dyn_array_t job_closure;
    358369        dyn_array_initialize(&job_closure, job_t *);
     370
     371        if (job_args->callback != NULL) {
     372                job_add_ref(job);
     373                sysman_object_observer(job, job_args->callback, job_args->callback_arg);
     374        }
     375        free(job_args);
    359376
    360377        int rc = job_create_closure(job, &job_closure);
Note: See TracChangeset for help on using the changeset viewer.