| 486 | } |
| 487 | |
| 488 | static 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 | |
| 517 | static int dbtype_to_client_type(lua_dbtypes_t *t) |
| 518 | { |
no test coverage detected