Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 703242 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/interfaces/libpq/fe-connect.c (-28 / +58 lines)
Lines 1965-1975 connectDBStart(PGconn *conn) Link Here
1965
	 */
1965
	 */
1966
	resetPQExpBuffer(&conn->errorMessage);
1966
	resetPQExpBuffer(&conn->errorMessage);
1967
1967
1968
#ifdef ENABLE_GSS
1969
	if (conn->gssencmode[0] == 'd') /* "disable" */
1970
		conn->try_gss = false;
1971
#endif
1972
1973
	/*
1968
	/*
1974
	 * Set up to try to connect to the first host.  (Setting whichhost = -1 is
1969
	 * Set up to try to connect to the first host.  (Setting whichhost = -1 is
1975
	 * a bit of a cheat, but PQconnectPoll will advance it to 0 before
1970
	 * a bit of a cheat, but PQconnectPoll will advance it to 0 before
Lines 2409-2414 keep_going: /* We will come back to here until there is Link Here
2409
		conn->allow_ssl_try = (conn->sslmode[0] != 'd');	/* "disable" */
2404
		conn->allow_ssl_try = (conn->sslmode[0] != 'd');	/* "disable" */
2410
		conn->wait_ssl_try = (conn->sslmode[0] == 'a'); /* "allow" */
2405
		conn->wait_ssl_try = (conn->sslmode[0] == 'a'); /* "allow" */
2411
#endif
2406
#endif
2407
		
2408
#ifdef ENABLE_GSS
2409
	if (conn->gssencmode[0] == 'd') /* "disable" */
2410
		conn->try_gss = false;
2411
#endif
2412
		
2413
		conn->did_negotiate = false;
2412
2414
2413
		reset_connection_state_machine = false;
2415
		reset_connection_state_machine = false;
2414
		need_new_connection = true;
2416
		need_new_connection = true;
Lines 2431-2436 keep_going: /* We will come back to here until there is Link Here
2431
		/* Reset conn->status to put the state machine in the right state */
2433
		/* Reset conn->status to put the state machine in the right state */
2432
		conn->status = CONNECTION_NEEDED;
2434
		conn->status = CONNECTION_NEEDED;
2433
2435
2436
		conn->did_negotiate = false;
2437
2434
		need_new_connection = false;
2438
		need_new_connection = false;
2435
	}
2439
	}
2436
2440
Lines 2971-2994 keep_going: /* We will come back to here until there is Link Here
2971
							goto error_return;
2975
							goto error_return;
2972
						}
2976
						}
2973
						/* Otherwise, proceed with normal startup */
2977
						/* Otherwise, proceed with normal startup */
2978
						conn->did_negotiate = true;
2974
						conn->allow_ssl_try = false;
2979
						conn->allow_ssl_try = false;
2975
						conn->status = CONNECTION_MADE;
2980
						conn->status = CONNECTION_MADE;
2976
						return PGRES_POLLING_WRITING;
2981
						return PGRES_POLLING_WRITING;
2977
					}
2982
					}
2978
					else if (SSLok == 'E')
2983
					else if (SSLok == 'E')
2979
					{
2984
					{
2980
						/*
2985
						if (conn->did_negotiate) {
2981
						 * Server failure of some sort, such as failure to
2986
							/*
2982
						 * fork a backend process.  We need to process and
2987
							 * Postmaster used to allow only a single negotiation attempt.
2983
						 * report the error message, which might be formatted
2988
							 * If we get an error on the second negotiation attempt,
2984
						 * according to either protocol 2 or protocol 3.
2989
							 * we reconnect and try again.
2985
						 * Rather than duplicate the code for that, we flip
2990
							 */
2986
						 * into AWAITING_RESPONSE state and let the code there
2991
							need_new_connection = true;
2987
						 * deal with it.  Note we have *not* consumed the "E"
2992
							goto keep_going;
2988
						 * byte here.
2993
						}
2989
						 */
2994
						else
2990
						conn->status = CONNECTION_AWAITING_RESPONSE;
2995
						{
2991
						goto keep_going;
2996
							/*
2997
							 * Server failure of some sort, such as failure to
2998
							 * fork a backend process.  We need to process and
2999
							 * report the error message, which might be formatted
3000
							 * according to either protocol 2 or protocol 3.
3001
							 * Rather than duplicate the code for that, we flip
3002
							 * into AWAITING_RESPONSE state and let the code there
3003
							 * deal with it.  Note we have *not* consumed the "E"
3004
							 * byte here.
3005
							 */
3006
							conn->status = CONNECTION_AWAITING_RESPONSE;
3007
							goto keep_going;
3008
						}
2992
					}
3009
					}
2993
					else
3010
					else
2994
					{
3011
					{
Lines 3061-3077 keep_going: /* We will come back to here until there is Link Here
3061
3078
3062
					if (gss_ok == 'E')
3079
					if (gss_ok == 'E')
3063
					{
3080
					{
3064
						/*
3081
						if (conn->did_negotiate) {
3065
						 * Server failure of some sort.  Assume it's a
3082
							/*
3066
						 * protocol version support failure, and let's see if
3083
							 * Postmaster used to allow only a single negotiation attempt.
3067
						 * we can't recover (if it's not, we'll get a better
3084
							 * If we get an error on the second negotiation attempt,
3068
						 * error message on retry).  Server gets fussy if we
3085
							 * we reconnect and try again.
3069
						 * don't hang up the socket, though.
3086
							 */
3070
						 */
3087
							need_new_connection = true;
3071
						conn->try_gss = false;
3088
							goto keep_going;
3072
						pqDropConnection(conn, true);
3089
						}
3073
						conn->status = CONNECTION_NEEDED;
3090
						else
3074
						goto keep_going;
3091
						{
3092
							/*
3093
							 * Server failure of some sort.  Assume it's a
3094
							 * protocol version support failure, and let's see if
3095
							 * we can't recover (if it's not, we'll get a better
3096
							 * error message on retry).  Server gets fussy if we
3097
							 * don't hang up the socket, though.
3098
							 */
3099
							conn->try_gss = false;
3100
							pqDropConnection(conn, true);
3101
							conn->status = CONNECTION_NEEDED;
3102
							goto keep_going;
3103
						}
3075
					}
3104
					}
3076
3105
3077
					/* mark byte consumed */
3106
					/* mark byte consumed */
Lines 3087-3092 keep_going: /* We will come back to here until there is Link Here
3087
							goto error_return;
3116
							goto error_return;
3088
						}
3117
						}
3089
3118
3119
						conn->did_negotiate = true;
3090
						conn->try_gss = false;
3120
						conn->try_gss = false;
3091
						conn->status = CONNECTION_MADE;
3121
						conn->status = CONNECTION_MADE;
3092
						return PGRES_POLLING_WRITING;
3122
						return PGRES_POLLING_WRITING;
(-)a/src/interfaces/libpq/libpq-int.h (-1 / +3 lines)
Lines 507-512 struct pg_conn Link Here
507
								 * connection */
507
								 * connection */
508
#endif
508
#endif
509
509
510
	/* Did we try negotiating SSL or GSS? Postmaster used to allow only a single attempt */
511
	bool did_negotiate;
512
	
510
	/* Buffer for current error message */
513
	/* Buffer for current error message */
511
	PQExpBufferData errorMessage;	/* expansible string */
514
	PQExpBufferData errorMessage;	/* expansible string */
512
515
513
- 

Return to bug 703242