Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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 354 of file oauth-curl.c.

355{
357
358 if (state->async_ctx)
359 {
360 free_async_ctx(conn, state->async_ctx);
361 state->async_ctx = NULL;
362 }
363
365}
#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:287
#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 2932 of file oauth-curl.c.

2933{
2935#ifndef WIN32
2936 sigset_t osigset;
2937 bool sigpipe_pending;
2938 bool masked;
2939
2940 /*---
2941 * Ignore SIGPIPE on this thread during all Curl processing.
2942 *
2943 * Because we support multiple threads, we have to set up libcurl with
2944 * CURLOPT_NOSIGNAL, which disables its default global handling of
2945 * SIGPIPE. From the Curl docs:
2946 *
2947 * libcurl makes an effort to never cause such SIGPIPE signals to
2948 * trigger, but some operating systems have no way to avoid them and
2949 * even on those that have there are some corner cases when they may
2950 * still happen, contrary to our desire.
2951 *
2952 * Note that libcurl is also at the mercy of its DNS resolution and SSL
2953 * libraries; if any of them forget a MSG_NOSIGNAL then we're in trouble.
2954 * Modern platforms and libraries seem to get it right, so this is a
2955 * difficult corner case to exercise in practice, and unfortunately it's
2956 * not really clear whether it's necessary in all cases.
2957 */
2958 masked = (pq_block_sigpipe(&osigset, &sigpipe_pending) == 0);
2959#endif
2960
2962
2963#ifndef WIN32
2964 if (masked)
2965 {
2966 /*
2967 * Undo the SIGPIPE mask. Assume we may have gotten EPIPE (we have no
2968 * way of knowing at this level).
2969 */
2970 pq_reset_sigpipe(&osigset, sigpipe_pending, true /* EPIPE, maybe */ );
2971 }
2972#endif
2973
2974 return result;
2975}
PostgresPollingStatusType
Definition: libpq-fe.h:114
static PostgresPollingStatusType pg_fe_run_oauth_flow_impl(PGconn *conn)
Definition: oauth-curl.c:2694
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().