MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / push_trigger_args_int

Function push_trigger_args_int

lua/sp.c:6667–6761  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6665}
6666
6667static int push_trigger_args_int(Lua L, dbconsumer_t *q, struct qfound *f, char **err)
6668{
6669 uint8_t *payload = ((uint8_t *)f->item) + f->item->data_offset;
6670 size_t len = f->item->data_len;
6671 memcpy(&q->genid, &q->fnd.genid, sizeof(genid_t));
6672 /*
6673 char header[] = "CDB2_UPD";
6674 if (memcmp(payload, header, sizeof(header)) != 0) {
6675 *err = strdup("bad payload header");
6676 return -1;
6677 }
6678 */
6679 uint8_t zeros[4] = {0};
6680 if (memcmp(payload + len - 4, zeros, sizeof(zeros)) != 0) {
6681 *err = strdup("bad payload tail");
6682 return -1;
6683 }
6684
6685 len -= 4; // 4 bytes of zeroes
6686 uint8_t *end = payload + len;
6687 payload += 40; // 8 + 32
6688
6689 int32_t flags = ntohl(*(int *)(payload));
6690 payload += 4;
6691
6692 int sztbl = ntohs(*(short *)(payload)) + 1;
6693 payload += 2;
6694
6695 char tbl[sztbl];
6696 strcpy(tbl, (char *)payload);
6697 payload += sztbl;
6698
6699 lua_newtable(L);
6700 lua_pushstring(L, tbl);
6701 lua_setfield(L, -2, "name");
6702
6703 blob_t id = {.length = sizeof(genid_t), .data = &q->genid};
6704 luabb_pushblob(L, &id);
6705 lua_setfield(L, -2, "id");
6706
6707 if (q->push_tid) {
6708 luabb_pushinteger(L, f->item->trans.tid);
6709 lua_setfield (L, -2, "tid");
6710 }
6711 if (q->push_seq) {
6712 luabb_pushinteger(L, f->seq);
6713 lua_setfield (L, -2, "sequence");
6714 }
6715 if (q->push_epoch) {
6716 luabb_pushinteger(L, f->item->epoch);
6717 lua_setfield (L, -2, "epoch");
6718 }
6719 if (flags & TYPE_TAGGED_ADD) {
6720 lua_newtable(L);
6721 lua_setfield(L, -2, "new");
6722 lua_pushstring(L, "add");
6723 lua_setfield(L, -2, "type");
6724 } else if (flags & TYPE_TAGGED_DEL) {

Callers 1

dbq_poll_intFunction · 0.85

Calls 7

lua_pushstringFunction · 0.85
lua_setfieldFunction · 0.85
luabb_pushblobFunction · 0.85
luabb_pushintegerFunction · 0.85
consume_fieldFunction · 0.85
lua_setmetatableFunction · 0.85
strdupFunction · 0.50

Tested by

no test coverage detected