PostgreSQL Source Code git master
oauth-curl.h File Reference
#include "libpq-fe.h"
Include dependency graph for oauth-curl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

PGDLLEXPORT PostgresPollingStatusType pg_fe_run_oauth_flow (PGconn *conn)
 
PGDLLEXPORT void pg_fe_cleanup_oauth_flow (PGconn *conn)
 

Function Documentation

◆ pg_fe_cleanup_oauth_flow()

PGDLLEXPORT void pg_fe_cleanup_oauth_flow ( PGconn conn)

Definition at line 340 of file oauth-curl.c.

341{
343
344 if (state->async_ctx)
345 {
346 free_async_ctx(conn, state->async_ctx);
347 state->async_ctx = NULL;
348 }
349
351}
#define set_conn_altsock(CONN, VAL)
Definition: oauth-curl.c:61
static void free_async_ctx(PGconn *conn, struct async_ctx *actx)
Definition: oauth-curl.c:273
#define conn_sasl_state(CONN)
Definition: oauth-curl.c:59
#define PGINVALID_SOCKET
Definition: port.h:31
PGconn * conn
Definition: streamutil.c:52
Definition: regguts.h:323

References conn, conn_sasl_state, free_async_ctx(), PGINVALID_SOCKET, and set_conn_altsock.

◆ pg_fe_run_oauth_flow()

PGDLLEXPORT PostgresPollingStatusType pg_fe_run_oauth_flow ( PGconn conn)

Definition at line 2906 of file oauth-curl.c.

2907{
2909#ifndef WIN32
2910 sigset_t osigset;
2911 bool sigpipe_pending;
2912 bool masked;
2913
2914 /*---
2915 * Ignore SIGPIPE on this thread during all Curl processing.
2916 *
2917 * Because we support multiple threads, we have to set up libcurl with
2918 * CURLOPT_NOSIGNAL, which disables its default global handling of
2919 * SIGPIPE. From the Curl docs:
2920 *
2921 * libcurl makes an effort to never cause such SIGPIPE signals to
2922 * trigger, but some operating systems have no way to avoid them and
2923 * even on those that have there are some corner cases when they may
2924 * still happen, contrary to our desire.
2925 *
2926 * Note that libcurl is also at the mercy of its DNS resolution and SSL
2927 * libraries; if any of them forget a MSG_NOSIGNAL then we're in trouble.
2928 * Modern platforms and libraries seem to get it right, so this is a
2929 * difficult corner case to exercise in practice, and unfortunately it's
2930 * not really clear whether it's necessary in all cases.
2931 */
2932 masked = (pq_block_sigpipe(&osigset, &sigpipe_pending) == 0);
2933#endif
2934
2936
2937#ifndef WIN32
2938 if (masked)
2939 {
2940 /*
2941 * Undo the SIGPIPE mask. Assume we may have gotten EPIPE (we have no
2942 * way of knowing at this level).
2943 */
2944 pq_reset_sigpipe(&osigset, sigpipe_pending, true /* EPIPE, maybe */ );
2945 }
2946#endif
2947
2948 return result;
2949}
PostgresPollingStatusType
Definition: libpq-fe.h:114
static PostgresPollingStatusType pg_fe_run_oauth_flow_impl(PGconn *conn)
Definition: oauth-curl.c:2668
void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, bool got_epipe)
Definition: oauth-utils.c:208
int pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending)
Definition: oauth-utils.c:172

References conn, pg_fe_run_oauth_flow_impl(), pq_block_sigpipe(), and pq_reset_sigpipe().