Skip to content

Commit d1b3948

Browse files
committed
Force close max-autoconsume drains
Signed-off-by: Mark Hannum <[email protected]>
1 parent ba57646 commit d1b3948

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

cdb2api/cdb2api.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,7 @@ static int newsql_connect(cdb2_hndl_tp *hndl, int node_indx)
25432543
return rc;
25442544
}
25452545

2546-
static void newsql_disconnect(cdb2_hndl_tp *hndl, SBUF2 *sb, int line)
2546+
static void newsql_disconnect_int(cdb2_hndl_tp *hndl, SBUF2 *sb, int line, int dontdonate)
25472547
{
25482548
if (sb == NULL)
25492549
return;
@@ -2553,13 +2553,10 @@ static void newsql_disconnect(cdb2_hndl_tp *hndl, SBUF2 *sb, int line)
25532553
int fd = sbuf2fileno(sb);
25542554

25552555
int timeoutms = 10 * 1000;
2556-
if (hndl->is_admin ||
2556+
if (hndl->is_admin || dontdonate ||
25572557
(hndl->firstresponse &&
2558-
(!hndl->lastresponse ||
2559-
(hndl->lastresponse->response_type != RESPONSE_TYPE__LAST_ROW))) ||
2560-
(!hndl->firstresponse) ||
2561-
(hndl->in_trans) ||
2562-
((hndl->flags & CDB2_TYPE_IS_FD) != 0)) {
2558+
(!hndl->lastresponse || (hndl->lastresponse->response_type != RESPONSE_TYPE__LAST_ROW))) ||
2559+
(!hndl->firstresponse) || (hndl->in_trans) || ((hndl->flags & CDB2_TYPE_IS_FD) != 0)) {
25632560
sbuf2close(sb);
25642561
} else if (sbuf2free(sb) == 0) {
25652562
cdb2_socket_pool_donate_ext(hndl->newsql_typestr, fd, timeoutms / 1000,
@@ -2570,9 +2567,13 @@ static void newsql_disconnect(cdb2_hndl_tp *hndl, SBUF2 *sb, int line)
25702567
return;
25712568
}
25722569

2570+
static void newsql_disconnect(cdb2_hndl_tp *hndl, SBUF2 *sb, int line)
2571+
{
2572+
return newsql_disconnect_int(hndl, sb, line, 0);
2573+
}
2574+
25732575
/* returns port number, or -1 for error*/
2574-
static int cdb2portmux_get(cdb2_hndl_tp *hndl, const char *type,
2575-
const char *remote_host, const char *app,
2576+
static int cdb2portmux_get(cdb2_hndl_tp *hndl, const char *type, const char *remote_host, const char *app,
25762577
const char *service, const char *instance)
25772578
{
25782579
char name[128]; /* app/service/dbname */
@@ -4457,7 +4458,7 @@ static inline void consume_previous_query(cdb2_hndl_tp *hndl)
44574458
while (cdb2_next_record_int(hndl, 0) == CDB2_OK) {
44584459
hardbound++;
44594460
if (hardbound > hndl->max_auto_consume_rows) {
4460-
newsql_disconnect(hndl, hndl->sb, __LINE__);
4461+
newsql_disconnect_int(hndl, hndl->sb, __LINE__, 1);
44614462
break;
44624463
}
44634464
}

0 commit comments

Comments
 (0)