Skip to content

Commit

Permalink
small clean-up and update ccommon (#177)
Browse files Browse the repository at this point in the history
* consolidate code a bit

* Squashed 'deps/ccommon/' changes from bb298bc..dd56abd

dd56abd break up ASSERT in buf_sock_read (#153)
727905b adding a new API to duration timer (#152)
9406717 add missing "extern C" qualifiers to a few headers for C++ linking; (#150)
a0aafdf Add missing semicolon to ring array example code in documentation. (#149)
9264bbb Zero byte (#147) (emergency fix needed for pelikan)
d4002d7 simplify cc_print_int64 (#146)
b164fcf Clean-up hash functions and introduce MurmurHash3 (#145)
b1babb2 change wheel's sleep timer to make it less flaky (#143)
ce0b9ea allow printing negative integers in cc_print (#141)
ab0edc8 add metrics to track buf_sock objects (#138)
ae02038 add travis ci (copied from pelikan) (#139)
964645a Merge pull request #135 from paegun/fix_cmake_install
70710c2 fixed and re-added cmake install instructions, w/ following notes: include directory made proper relative; opened pattern match b/c include directory should only contain files meant for inclusion.
5b095bc Merge pull request #126 from kevyang/kevyang/120
426d56a return NULL when cc_alloc/cc_realloc is called with size == 0
ad271d4 Merge pull request #133 from kevyang/132
47dbdba suppress unused parameter warning in debug_log_flush
648d19e Merge pull request #127 from kevyang/56
780941a Merge pull request #130 from kevyang/129
b8af6c0 Merge pull request #131 from kevyang/128
6ecc318 fix duplicate symbols in cc_signal
080c41d cc_array - stop doing arithmetic on void *
d526f7a add debug oriented memory management
a4fb927 Update bool member rules in style guide
05c6e1e explicitly make ccommon a C project to avoid checking for CXX related variables

git-subtree-dir: deps/ccommon
git-subtree-split: dd56abd
  • Loading branch information
Yao Yue authored Jul 2, 2018
1 parent 352085d commit 5b559d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 32 deletions.
5 changes: 3 additions & 2 deletions deps/ccommon/src/stream/cc_sockio.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ buf_tcp_read(struct buf_sock *s)
rstatus_i status = CC_OK;
ssize_t cap, n;

ASSERT(c != NULL && h != NULL && buf != NULL);
ASSERT(h->recv != NULL);
ASSERT(c != NULL);
ASSERT(buf != NULL);
ASSERT(h != NULL && h->recv != NULL);

cap = buf_wsize(buf);

Expand Down
38 changes: 8 additions & 30 deletions src/core/data/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,20 @@ static channel_handler_st *hdl = &handlers;

struct data_processor *processor;

static inline rstatus_i
_worker_write(struct buf_sock *s)
{
rstatus_i status;

log_verb("writing on buf_sock %p", s);

ASSERT(s != NULL);
ASSERT(s->wbuf != NULL && s->rbuf != NULL);

status = buf_tcp_write(s);

return status;
}

/* the caller only needs to check the return status of this function if
* it previously received a write event and wants to re-register the
* read event upon full, successful write.
*/
static inline rstatus_i
_worker_event_write(struct buf_sock *s)
{
ASSERT(s != NULL);

rstatus_i status;
struct tcp_conn *c = s->ch;

status = _worker_write(s);
log_verb("writing on buf_sock %p", s);
status = buf_tcp_write(s);
if (status == CC_ERETRY || status == CC_EAGAIN) { /* retry write */
/* by removing current masks and only listen to write event(s), we are
* effectively stopping processing incoming data until we can write
Expand All @@ -80,19 +68,6 @@ _worker_event_write(struct buf_sock *s)
return status;
}

static inline void
_worker_read(struct buf_sock *s)
{
log_verb("reading on buf_sock %p", s);

ASSERT(s != NULL);
ASSERT(s->wbuf != NULL && s->rbuf != NULL);

/* TODO(kyang): consider refactoring dbuf_tcp_read and buf_tcp_read to have no return status
at all, since the return status is already given by the connection state */
buf_tcp_read(s);
}

static inline void
worker_close(struct buf_sock *s)
{
Expand All @@ -110,7 +85,10 @@ _worker_event_read(struct buf_sock *s)
{
ASSERT(s != NULL);

_worker_read(s);
log_verb("reading on buf_sock %p", s);
/* TODO(kyang): consider refactoring dbuf_tcp_read and buf_tcp_read to have no return status
at all, since the return status is already given by the connection state */
buf_tcp_read(s);
if (processor->read(&s->rbuf, &s->wbuf, &s->data) < 0) {
log_debug("handler signals channel termination");
s->ch->state = CHANNEL_TERM;
Expand Down

0 comments on commit 5b559d5

Please sign in to comment.