Changeset 7c15d6f in mainline


Ignore:
Timestamp:
2015-06-06T15:20:52Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9362cc2
Parents:
1ede059
Message:

Never clear timer inside its handler.

Location:
uspace
Files:
3 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;
  • uspace/lib/c/include/fibril_synch.h

    r1ede059 r7c15d6f  
    135135        fid_t fibril;
    136136        fibril_timer_state_t state;
    137         bool handler_running;
     137        /** FID of fibril executing handler or 0 if handler is not running */
     138        fid_t handler_fid;
    138139
    139140        suseconds_t delay;
  • uspace/srv/net/tcp/tqueue.c

    r1ede059 r7c15d6f  
    351351
    352352        /* Reset retransmission timer */
    353         tcp_tqueue_timer_set(tqe->conn);
     353        fibril_timer_set_locked(conn->retransmit.timer, RETRANSMIT_TIMEOUT,
     354            retransmit_timeout_func, (void *) conn);
    354355
    355356        tcp_conn_unlock(conn);
    356         tcp_conn_delref(conn);
    357357
    358358        log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: retransmit_timeout_func(%p) end", conn->name, conn);
Note: See TracChangeset for help on using the changeset viewer.