author | Alberto Bertogli
<albertito@gmail.com> 2007-09-02 01:26:10 UTC |
committer | Alberto Bertogli
<albertito@gmail.com> 2007-09-02 01:26:10 UTC |
parent | 4e157bb7b31e8b7c451ac1677e04ac11e2164607 |
nmdb/dbloop.c | +11 | -11 |
nmdb/parse.c | +13 | -13 |
nmdb/req.h | +2 | -5 |
nmdb/sctp.c | +7 | -30 |
nmdb/tcp.c | +7 | -30 |
nmdb/tipc.c | +7 | -30 |
nmdb/udp.c | +7 | -30 |
diff --git a/nmdb/dbloop.c b/nmdb/dbloop.c index 11f4f11..998720d 100644 --- a/nmdb/dbloop.c +++ b/nmdb/dbloop.c @@ -106,7 +106,7 @@ static void process_op(db_t *db, struct queue_entry *e) e->req->reply_err(e->req, ERR_DB); return; } - e->req->reply_set(e->req, REP_OK); + e->req->reply_mini(e->req, REP_OK); } else if (e->operation == REQ_SET_ASYNC) { db_set(db, e->key, e->ksize, e->val, e->vsize); @@ -122,20 +122,20 @@ static void process_op(db_t *db, struct queue_entry *e) } rv = db_get(db, e->key, e->ksize, val, &vsize); if (rv == 0) { - e->req->reply_get(e->req, REP_NOTIN, NULL, 0); + e->req->reply_mini(e->req, REP_NOTIN); free(val); return; } - e->req->reply_get(e->req, REP_OK, val, vsize); + e->req->reply_long(e->req, REP_OK, val, vsize); free(val); } else if (e->operation == REQ_DEL_SYNC) { rv = db_del(db, e->key, e->ksize); if (rv == 0) { - e->req->reply_del(e->req, REP_NOTIN); + e->req->reply_mini(e->req, REP_NOTIN); return; } - e->req->reply_del(e->req, REP_OK); + e->req->reply_mini(e->req, REP_OK); } else if (e->operation == REQ_DEL_ASYNC) { db_del(db, e->key, e->ksize); @@ -152,7 +152,7 @@ static void process_op(db_t *db, struct queue_entry *e) } rv = db_get(db, e->key, e->ksize, dbval, &dbvsize); if (rv == 0) { - e->req->reply_cas(e->req, REP_NOTIN); + e->req->reply_mini(e->req, REP_NOTIN); free(dbval); return; } @@ -166,12 +166,12 @@ static void process_op(db_t *db, struct queue_entry *e) return; } - e->req->reply_cas(e->req, REP_OK); + e->req->reply_mini(e->req, REP_OK); free(dbval); return; } - e->req->reply_cas(e->req, REP_NOMATCH); + e->req->reply_mini(e->req, REP_NOMATCH); free(dbval); } else if (e->operation == REQ_INCR) { @@ -186,14 +186,14 @@ static void process_op(db_t *db, struct queue_entry *e) } rv = db_get(db, e->key, e->ksize, dbval, &dbvsize); if (rv == 0) { - e->req->mini_reply(e->req, REP_NOTIN); + e->req->reply_mini(e->req, REP_NOTIN); free(dbval); return; } /* val must be NULL terminated; see cache_incr() */ if (dbval && dbval[dbvsize - 1] != '\0') { - e->req->mini_reply(e->req, REP_NOMATCH); + e->req->reply_mini(e->req, REP_NOMATCH); free(dbval); return; } @@ -216,7 +216,7 @@ static void process_op(db_t *db, struct queue_entry *e) return; } - e->req->mini_reply(e->req, REP_OK); + e->req->reply_mini(e->req, REP_OK); free(dbval); diff --git a/nmdb/parse.c b/nmdb/parse.c index 2fad1e1..368e67e 100644 --- a/nmdb/parse.c +++ b/nmdb/parse.c @@ -213,7 +213,7 @@ static void parse_get(struct req_info *req, int impact_db) hit = cache_get(cache_table, key, ksize, &val, &vsize); if (!hit && !impact_db) { - req->mini_reply(req, REP_CACHE_MISS); + req->reply_mini(req, REP_CACHE_MISS); return; } else if (!hit && impact_db) { struct queue_entry *e; @@ -228,7 +228,7 @@ static void parse_get(struct req_info *req, int impact_db) queue_signal(op_queue); return; } else { - req->reply_get(req, REP_CACHE_HIT, val, vsize); + req->reply_long(req, REP_CACHE_HIT, val, vsize); return; } } @@ -292,7 +292,7 @@ static void parse_set(struct req_info *req, int impact_db, int async) queue_unlock(op_queue); if (async) { - req->mini_reply(req, REP_OK); + req->reply_mini(req, REP_OK); } else { /* Signal the DB thread it has work only if it's a * synchronous operation, asynchronous don't mind @@ -303,7 +303,7 @@ static void parse_set(struct req_info *req, int impact_db, int async) } return; } else { - req->mini_reply(req, REP_OK); + req->reply_mini(req, REP_OK); } return; @@ -329,9 +329,9 @@ static void parse_del(struct req_info *req, int impact_db, int async) hit = cache_del(cache_table, key, ksize); if (!impact_db && hit) { - req->mini_reply(req, REP_OK); + req->reply_mini(req, REP_OK); } else if (!impact_db && !hit) { - req->mini_reply(req, REP_NOTIN); + req->reply_mini(req, REP_NOTIN); } else if (impact_db) { struct queue_entry *e; uint32_t request; @@ -350,7 +350,7 @@ static void parse_del(struct req_info *req, int impact_db, int async) queue_unlock(op_queue); if (async) { - req->mini_reply(req, REP_OK); + req->reply_mini(req, REP_OK); } else { /* See comment on parse_set(). */ queue_signal(op_queue); @@ -408,16 +408,16 @@ static void parse_cas(struct req_info *req, int impact_db) if (rv == 0) { /* If the cache doesn't match, there is no need to bother the * DB even if we were asked to impact. */ - req->mini_reply(req, REP_NOMATCH); + req->reply_mini(req, REP_NOMATCH); return; } if (!impact_db) { if (rv == -1) { - req->mini_reply(req, REP_NOTIN); + req->reply_mini(req, REP_NOTIN); return; } else { - req->mini_reply(req, REP_OK); + req->reply_mini(req, REP_OK); return; } } else { @@ -503,7 +503,7 @@ static void parse_incr(struct req_info *req, int impact_db) return; } else if (cres == -2) { /* the value was not NULL terminated */ - req->mini_reply(req, REP_NOMATCH); + req->reply_mini(req, REP_NOMATCH); return; } @@ -527,9 +527,9 @@ static void parse_incr(struct req_info *req, int impact_db) queue_signal(op_queue); } else { if (cres == -1) - req->mini_reply(req, REP_NOTIN); + req->reply_mini(req, REP_NOTIN); else - req->mini_reply(req, REP_OK); + req->reply_mini(req, REP_OK); } return; diff --git a/nmdb/req.h b/nmdb/req.h index 68ce4d8..4637307 100644 --- a/nmdb/req.h +++ b/nmdb/req.h @@ -29,13 +29,10 @@ struct req_info { size_t psize; /* operations */ - void (*mini_reply)(struct req_info *req, uint32_t reply); + void (*reply_mini)(struct req_info *req, uint32_t reply); void (*reply_err)(struct req_info *req, uint32_t reply); - void (*reply_get)(struct req_info *req, uint32_t reply, + void (*reply_long)(struct req_info *req, uint32_t reply, unsigned char *val, size_t vsize); - void (*reply_set)(struct req_info *req, uint32_t reply); - void (*reply_del)(struct req_info *req, uint32_t reply); - void (*reply_cas)(struct req_info *req, uint32_t reply); }; #endif diff --git a/nmdb/sctp.c b/nmdb/sctp.c index ef8064c..42fdb4c 100644 --- a/nmdb/sctp.c +++ b/nmdb/sctp.c @@ -17,13 +17,10 @@ #include "log.h" -static void sctp_mini_reply(struct req_info *req, uint32_t reply); +static void sctp_reply_mini(struct req_info *req, uint32_t reply); static void sctp_reply_err(struct req_info *req, uint32_t reply); -static void sctp_reply_get(struct req_info *req, uint32_t reply, +static void sctp_reply_long(struct req_info *req, uint32_t reply, unsigned char *val, size_t vsize); -static void sctp_reply_set(struct req_info *req, uint32_t reply); -static void sctp_reply_del(struct req_info *req, uint32_t reply); -static void sctp_reply_cas(struct req_info *req, uint32_t reply); /* @@ -72,7 +69,7 @@ static int rep_send(const struct req_info *req, const unsigned char *buf, /* Send small replies, consisting in only a value. */ -static void sctp_mini_reply(struct req_info *req, uint32_t reply) +static void sctp_reply_mini(struct req_info *req, uint32_t reply) { /* We use a mini buffer to speedup the small replies, to avoid the * malloc() overhead. */ @@ -97,12 +94,12 @@ void sctp_reply_err(struct req_info *req, uint32_t reply) rep_send_error(req, reply); } -void sctp_reply_get(struct req_info *req, uint32_t reply, +void sctp_reply_long(struct req_info *req, uint32_t reply, unsigned char *val, size_t vsize) { if (val == NULL) { /* miss */ - sctp_mini_reply(req, reply); + sctp_reply_mini(req, reply); } else { unsigned char *buf; size_t bsize; @@ -134,23 +131,6 @@ void sctp_reply_get(struct req_info *req, uint32_t reply, } -void sctp_reply_set(struct req_info *req, uint32_t reply) -{ - sctp_mini_reply(req, reply); -} - - -void sctp_reply_del(struct req_info *req, uint32_t reply) -{ - sctp_mini_reply(req, reply); -} - -void sctp_reply_cas(struct req_info *req, uint32_t reply) -{ - sctp_mini_reply(req, reply); -} - - /* * Main functions for receiving and parsing */ @@ -241,12 +221,9 @@ void sctp_recv(int fd, short event, void *arg) req.type = REQTYPE_SCTP; req.clisa = (struct sockaddr *) &clisa; req.clilen = clilen; - req.mini_reply = sctp_mini_reply; + req.reply_mini = sctp_reply_mini; req.reply_err = sctp_reply_err; - req.reply_get = sctp_reply_get; - req.reply_set = sctp_reply_set; - req.reply_del = sctp_reply_del; - req.reply_cas = sctp_reply_cas; + req.reply_long = sctp_reply_long; /* parse the message */ parse_message(&req, static_buf, rv); diff --git a/nmdb/tcp.c b/nmdb/tcp.c index 555241c..dc98c26 100644 --- a/nmdb/tcp.c +++ b/nmdb/tcp.c @@ -44,13 +44,10 @@ static void tcp_recv(int fd, short event, void *arg); static void process_buf(struct tcp_socket *tcpsock, unsigned char *buf, size_t len); -static void tcp_mini_reply(struct req_info *req, uint32_t reply); +static void tcp_reply_mini(struct req_info *req, uint32_t reply); static void tcp_reply_err(struct req_info *req, uint32_t reply); -static void tcp_reply_get(struct req_info *req, uint32_t reply, +static void tcp_reply_long(struct req_info *req, uint32_t reply, unsigned char *val, size_t vsize); -static void tcp_reply_set(struct req_info *req, uint32_t reply); -static void tcp_reply_del(struct req_info *req, uint32_t reply); -static void tcp_reply_cas(struct req_info *req, uint32_t reply); /* @@ -72,12 +69,9 @@ static void init_req(struct tcp_socket *tcpsock) tcpsock->req.type = REQTYPE_TCP; tcpsock->req.clisa = (struct sockaddr *) &tcpsock->clisa; tcpsock->req.clilen = tcpsock->clilen; - tcpsock->req.mini_reply = tcp_mini_reply; + tcpsock->req.reply_mini = tcp_reply_mini; tcpsock->req.reply_err = tcp_reply_err; - tcpsock->req.reply_get = tcp_reply_get; - tcpsock->req.reply_set = tcp_reply_set; - tcpsock->req.reply_del = tcp_reply_del; - tcpsock->req.reply_cas = tcp_reply_cas; + tcpsock->req.reply_long = tcp_reply_long; } static void rep_send_error(const struct req_info *req, const unsigned int code) @@ -150,7 +144,7 @@ static int rep_send(const struct req_info *req, const unsigned char *buf, /* Send small replies, consisting in only a value. */ -void tcp_mini_reply(struct req_info *req, uint32_t reply) +void tcp_reply_mini(struct req_info *req, uint32_t reply) { /* We use a mini buffer to speedup the small replies, to avoid the * malloc() overhead. */ @@ -175,12 +169,12 @@ void tcp_reply_err(struct req_info *req, uint32_t reply) rep_send_error(req, reply); } -void tcp_reply_get(struct req_info *req, uint32_t reply, +void tcp_reply_long(struct req_info *req, uint32_t reply, unsigned char *val, size_t vsize) { if (val == NULL) { /* miss */ - tcp_mini_reply(req, reply); + tcp_reply_mini(req, reply); } else { unsigned char *buf; size_t bsize; @@ -216,23 +210,6 @@ void tcp_reply_get(struct req_info *req, uint32_t reply, } -void tcp_reply_set(struct req_info *req, uint32_t reply) -{ - tcp_mini_reply(req, reply); -} - - -void tcp_reply_del(struct req_info *req, uint32_t reply) -{ - tcp_mini_reply(req, reply); -} - -void tcp_reply_cas(struct req_info *req, uint32_t reply) -{ - tcp_mini_reply(req, reply); -} - - /* * Main functions for receiving and parsing */ diff --git a/nmdb/tipc.c b/nmdb/tipc.c index 8cf340e..658a056 100644 --- a/nmdb/tipc.c +++ b/nmdb/tipc.c @@ -16,13 +16,10 @@ #include "log.h" -static void tipc_mini_reply(struct req_info *req, uint32_t reply); +static void tipc_reply_mini(struct req_info *req, uint32_t reply); static void tipc_reply_err(struct req_info *req, uint32_t reply); -static void tipc_reply_get(struct req_info *req, uint32_t reply, +static void tipc_reply_long(struct req_info *req, uint32_t reply, unsigned char *val, size_t vsize); -static void tipc_reply_set(struct req_info *req, uint32_t reply); -static void tipc_reply_del(struct req_info *req, uint32_t reply); -static void tipc_reply_cas(struct req_info *req, uint32_t reply); /* @@ -71,7 +68,7 @@ static int rep_send(const struct req_info *req, const unsigned char *buf, /* Send small replies, consisting in only a value. */ -static void tipc_mini_reply(struct req_info *req, uint32_t reply) +static void tipc_reply_mini(struct req_info *req, uint32_t reply) { /* We use a mini buffer to speedup the small replies, to avoid the * malloc() overhead. */ @@ -96,12 +93,12 @@ void tipc_reply_err(struct req_info *req, uint32_t reply) rep_send_error(req, reply); } -void tipc_reply_get(struct req_info *req, uint32_t reply, +void tipc_reply_long(struct req_info *req, uint32_t reply, unsigned char *val, size_t vsize) { if (val == NULL) { /* miss */ - tipc_mini_reply(req, reply); + tipc_reply_mini(req, reply); } else { unsigned char *buf; size_t bsize; @@ -133,23 +130,6 @@ void tipc_reply_get(struct req_info *req, uint32_t reply, } -void tipc_reply_set(struct req_info *req, uint32_t reply) -{ - tipc_mini_reply(req, reply); -} - - -void tipc_reply_del(struct req_info *req, uint32_t reply) -{ - tipc_mini_reply(req, reply); -} - -void tipc_reply_cas(struct req_info *req, uint32_t reply) -{ - tipc_mini_reply(req, reply); -} - - /* * Main functions for receiving and parsing */ @@ -225,12 +205,9 @@ void tipc_recv(int fd, short event, void *arg) req.type = REQTYPE_TIPC; req.clisa = (struct sockaddr *) &clisa; req.clilen = clilen; - req.mini_reply = tipc_mini_reply; + req.reply_mini = tipc_reply_mini; req.reply_err = tipc_reply_err; - req.reply_get = tipc_reply_get; - req.reply_set = tipc_reply_set; - req.reply_del = tipc_reply_del; - req.reply_cas = tipc_reply_cas; + req.reply_long = tipc_reply_long; /* parse the message */ parse_message(&req, static_buf, rv); diff --git a/nmdb/udp.c b/nmdb/udp.c index 50beb9c..c9c51ea 100644 --- a/nmdb/udp.c +++ b/nmdb/udp.c @@ -17,13 +17,10 @@ #include "log.h" -static void udp_mini_reply(struct req_info *req, uint32_t reply); +static void udp_reply_mini(struct req_info *req, uint32_t reply); static void udp_reply_err(struct req_info *req, uint32_t reply); -static void udp_reply_get(struct req_info *req, uint32_t reply, +static void udp_reply_long(struct req_info *req, uint32_t reply, unsigned char *val, size_t vsize); -static void udp_reply_set(struct req_info *req, uint32_t reply); -static void udp_reply_del(struct req_info *req, uint32_t reply); -static void udp_reply_cas(struct req_info *req, uint32_t reply); /* @@ -72,7 +69,7 @@ static int rep_send(const struct req_info *req, const unsigned char *buf, /* Send small replies, consisting in only a value. */ -static void udp_mini_reply(struct req_info *req, uint32_t reply) +static void udp_reply_mini(struct req_info *req, uint32_t reply) { /* We use a mini buffer to speedup the small replies, to avoid the * malloc() overhead. */ @@ -97,12 +94,12 @@ void udp_reply_err(struct req_info *req, uint32_t reply) rep_send_error(req, reply); } -void udp_reply_get(struct req_info *req, uint32_t reply, +void udp_reply_long(struct req_info *req, uint32_t reply, unsigned char *val, size_t vsize) { if (val == NULL) { /* miss */ - udp_mini_reply(req, reply); + udp_reply_mini(req, reply); } else { unsigned char *buf; size_t bsize; @@ -134,23 +131,6 @@ void udp_reply_get(struct req_info *req, uint32_t reply, } -void udp_reply_set(struct req_info *req, uint32_t reply) -{ - udp_mini_reply(req, reply); -} - - -void udp_reply_del(struct req_info *req, uint32_t reply) -{ - udp_mini_reply(req, reply); -} - -void udp_reply_cas(struct req_info *req, uint32_t reply) -{ - udp_mini_reply(req, reply); -} - - /* * Main functions for receiving and parsing */ @@ -225,12 +205,9 @@ void udp_recv(int fd, short event, void *arg) req.type = REQTYPE_UDP; req.clisa = (struct sockaddr *) &clisa; req.clilen = clilen; - req.mini_reply = udp_mini_reply; + req.reply_mini = udp_reply_mini; req.reply_err = udp_reply_err; - req.reply_get = udp_reply_get; - req.reply_set = udp_reply_set; - req.reply_del = udp_reply_del; - req.reply_cas = udp_reply_cas; + req.reply_long = udp_reply_long; /* parse the message */ parse_message(&req, static_buf, rv);