Changeset ee1c2d9 in mainline for uspace/lib/c/generic/fibril_synch.c


Ignore:
Timestamp:
2015-06-13T18:30:18Z (9 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a157846
Parents:
0453261 (diff), 2f9a8e8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

mainline changes

File:
1 edited

Legend:

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

    r0453261 ree1c2d9  
    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;
     
    477477        /* Acknowledge timer fibril has finished cleanup. */
    478478        timer->state = fts_clean;
     479        fibril_condvar_broadcast(&timer->cv);
    479480        fibril_mutex_unlock(timer->lockp);
    480         free(timer);
    481481
    482482        return 0;
     
    525525        timer->state = fts_cleanup;
    526526        fibril_condvar_broadcast(&timer->cv);
     527
     528        /* Wait for timer fibril to terminate */
     529        while (timer->state != fts_clean)
     530                fibril_condvar_wait(&timer->cv, timer->lockp);
    527531        fibril_mutex_unlock(timer->lockp);
     532
     533        free(timer);
    528534}
    529535
     
    608614        assert(fibril_mutex_is_locked(timer->lockp));
    609615
    610         while (timer->handler_running)
     616        while (timer->handler_fid != 0) {
     617                if (timer->handler_fid == fibril_get_id()) {
     618                        printf("Deadlock detected.\n");
     619                        stacktrace_print();
     620                        printf("Fibril %zx is trying to clear timer %p from "
     621                            "inside its handler %p.\n",
     622                            fibril_get_id(), timer, timer->fun);
     623                        abort();
     624                }
     625
    611626                fibril_condvar_wait(&timer->cv, timer->lockp);
     627        }
    612628
    613629        old_state = timer->state;
Note: See TracChangeset for help on using the changeset viewer.