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

Changeset 7c15d6f in mainline for uspace/lib/c/generic/fibril_synch.c


Ignore:
Timestamp:
2015-06-06T15:20:52Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
9362cc2
Parents:
1ede059
Message:

Never clear timer inside its handler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/fibril_synch.c

    r1ede059 r7c15d6f  
    461461                        if (rc == ETIMEOUT && timer->state == fts_active) {
    462462                                timer->state = fts_fired;
    463                                 timer->handler_running = true;
     463                                timer->handler_fid = fibril_get_id();
    464464                                fibril_mutex_unlock(timer->lockp);
    465465                                timer->fun(timer->arg);
    466466                                fibril_mutex_lock(timer->lockp);
    467                                 timer->handler_running = false;
     467                                timer->handler_fid = 0;
    468468                        }
    469469                        break;
     
    608608        assert(fibril_mutex_is_locked(timer->lockp));
    609609
    610         while (timer->handler_running)
     610        while (timer->handler_fid != 0) {
     611                if (timer->handler_fid == fibril_get_id()) {
     612                        printf("Deadlock detected.\n");
     613                        stacktrace_print();
     614                        printf("Fibril %zx is trying to clear timer %p from "
     615                            "inside its handler %p.\n",
     616                            fibril_get_id(), timer, timer->fun);
     617                        abort();
     618                }
     619
    611620                fibril_condvar_wait(&timer->cv, timer->lockp);
     621        }
    612622
    613623        old_state = timer->state;
Note: See TracChangeset for help on using the changeset viewer.