Changeset 498ced1 in mainline for uspace/srv/net/tcp/conn.c


Ignore:
Timestamp:
2018-08-11T02:43:32Z (6 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
05882233
Parents:
b13d80b
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-11 02:29:02)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-11 02:43:32)
Message:

Unify reference counting and remove some unnecessary instances of <atomic.h>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tcp/conn.c

    rb13d80b r498ced1  
    128128
    129129        /* One for the user, one for not being in closed state */
    130         atomic_set(&conn->refcnt, 2);
     130        refcount_init(&conn->refcnt);
     131        refcount_up(&conn->refcnt);
    131132
    132133        /* Allocate receive buffer */
     
    238239void tcp_conn_addref(tcp_conn_t *conn)
    239240{
    240         log_msg(LOG_DEFAULT, LVL_DEBUG2, "%s: tcp_conn_addref(%p) before=%zu",
    241             conn->name, conn, atomic_get(&conn->refcnt));
    242         atomic_inc(&conn->refcnt);
     241        log_msg(LOG_DEFAULT, LVL_DEBUG2, "%s: tcp_conn_addref(%p)",
     242            conn->name, conn);
     243
     244        refcount_up(&conn->refcnt);
    243245}
    244246
     
    251253void tcp_conn_delref(tcp_conn_t *conn)
    252254{
    253         log_msg(LOG_DEFAULT, LVL_DEBUG2, "%s: tcp_conn_delref(%p) before=%zu",
    254             conn->name, conn, atomic_get(&conn->refcnt));
    255 
    256         if (atomic_predec(&conn->refcnt) == 0)
     255        log_msg(LOG_DEFAULT, LVL_DEBUG2, "%s: tcp_conn_delref(%p)",
     256            conn->name, conn);
     257
     258        if (refcount_down(&conn->refcnt))
    257259                tcp_conn_free(conn);
    258260}
Note: See TracChangeset for help on using the changeset viewer.