Changeset: 0e3eeec0cb3e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/0e3eeec0cb3e Modified Files: sql/backends/monet5/sql.c Branch: Jul2021 Log Message:
Do not hang up if client refuses COPY .. INTO 'file' ON CLIENT Before, the server would consume the error message sent by the client, but not the flush that followed it. Then, when reading the next command, it would receive the flush and interpret it as "connection closed". With this change, the error handling code properly consumes the flush and the server no longer hangs up on the client. diffs (48 lines): diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c --- a/sql/backends/monet5/sql.c +++ b/sql/backends/monet5/sql.c @@ -2638,10 +2638,10 @@ mvc_export_table_wrap( Client cntxt, Mal if ((sz = mnstr_readline(m->scanner.rs->s, buf, sizeof(buf))) > 1) { /* non-empty line indicates failure on client */ msg = createException(IO, "streams.open", "%s", buf); - /* deal with ridiculously long response from client */ - while (buf[sz - 1] != '\n' && - (sz = mnstr_readline(m->scanner.rs->s, buf, sizeof(buf))) > 0) - ; + /* discard until client flushes */ + while (mnstr_read(m->scanner.rs->s, buf, 1, sizeof(buf)) > 0) { + /* ignore remainder of error message */ + } goto wrapup_result_set1; } } @@ -2869,10 +2869,10 @@ mvc_export_row_wrap( Client cntxt, MalBl if ((sz = mnstr_readline(m->scanner.rs->s, buf, sizeof(buf))) > 1) { /* non-empty line indicates failure on client */ msg = createException(IO, "streams.open", "%s", buf); - /* deal with ridiculously long response from client */ - while (buf[sz - 1] != '\n' && - (sz = mnstr_readline(m->scanner.rs->s, buf, sizeof(buf))) > 0) - ; + /* discard until client flushes */ + while (mnstr_read(m->scanner.rs->s, buf, 1, sizeof(buf)) > 0) { + /* ignore remainder of error message */ + } goto wrapup_result_set; } } @@ -4627,10 +4627,10 @@ SQLhot_snapshot_wrap(Client cntxt, MalBl if ((sz = mnstr_readline(mvc->scanner.rs->s, buf, sizeof(buf))) > 1) { /* non-empty line indicates failure on client */ msg = createException(IO, "streams.open", "%s", buf); - /* deal with ridiculously long response from client */ - while (buf[sz - 1] != '\n' && - (sz = mnstr_readline(mvc->scanner.rs->s, buf, sizeof(buf))) > 0) - ; + /* discard until client flushes */ + while (mnstr_read(mvc->scanner.rs->s, buf, 1, sizeof(buf)) > 0) { + /* ignore remainder of error message */ + } goto end; } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list