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

Function pong

lua/sp.c:488–515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488static void pong(Lua L, dbconsumer_t *q)
489{
490 SP sp = getsp(L);
491 struct sqlclntstate *clnt = sp->clnt;
492 int timeout = q->emit_timeoutms / 1000;
493 if (q->emit_timeoutms && timeout == 0) {
494 timeout = 1;
495 }
496 while (1) {
497 switch (read_response(clnt, RESPONSE_PING_PONG, NULL, 0)) {
498 case 0: sp->pingpong = 0; return;
499 case -1: if (stop_waiting(L, q)) luaL_error(L, sp->error); break;
500 case -2: luaL_error(L, "client disconnect");
501 case -3: luaL_error(L, "client protocol error");
502 default: luaL_error(L, "failed reading event ack from client");
503 }
504 if (q->emit_timeoutms) {
505 if (timeout) {
506 --timeout;
507 } else if (sp->pingpong == 1) {
508 logmsg(LOGMSG_USER,
509 "%s:%s suspending heartbeat timeout:%dms\n",
510 q->type, q->info.spname, q->emit_timeoutms);
511 sp->pingpong = 2;
512 }
513 }
514 }
515}
516
517static int dbtype_to_client_type(lua_dbtypes_t *t)
518{

Callers 1

dbconsumer_emitFunction · 0.85

Calls 4

read_responseFunction · 0.85
stop_waitingFunction · 0.85
luaL_errorFunction · 0.85
logmsgFunction · 0.50

Tested by

no test coverage detected