MCPcopy Create free account
hub / github.com/apache/cloudberry / PQsetnonblocking

Function PQsetnonblocking

src/interfaces/libpq/fe-exec.c:3748–3779  ·  view source on GitHub ↗

PQsetnonblocking: * sets the PGconn's database connection non-blocking if the arg is true * or makes it blocking if the arg is false, this will not protect * you from PQexec(), you'll only be safe when using the non-blocking API. * Needs to be called only on a connected database connection. */

Source from the content-addressed store, hash-verified

3746 * Needs to be called only on a connected database connection.
3747 */
3748int
3749PQsetnonblocking(PGconn *conn, int arg)
3750{
3751 bool barg;
3752
3753 if (!conn || conn->status == CONNECTION_BAD)
3754 return -1;
3755
3756 barg = (arg ? true : false);
3757
3758 /* early out if the socket is already in the state requested */
3759 if (barg == conn->nonblocking)
3760 return 0;
3761
3762 /*
3763 * to guarantee constancy for flushing/query/result-polling behavior we
3764 * need to flush the send queue at this point in order to guarantee proper
3765 * behavior. this is ok because either they are making a transition _from_
3766 * or _to_ blocking mode, either way we can block them.
3767 *
3768 * Clear errorMessage in case pqFlush adds to it.
3769 */
3770 resetPQExpBuffer(&conn->errorMessage);
3771
3772 /* if we are going from blocking to non-blocking flush here */
3773 if (pqFlush(conn))
3774 return -1;
3775
3776 conn->nonblocking = barg;
3777
3778 return 0;
3779}
3780
3781/*
3782 * return the blocking status of the database connection

Callers 3

ManageCronTaskFunction · 0.85
test_pipelined_insertFunction · 0.85
test_uniqviolFunction · 0.85

Calls 2

resetPQExpBufferFunction · 0.85
pqFlushFunction · 0.85

Tested by 2

test_pipelined_insertFunction · 0.68
test_uniqviolFunction · 0.68